Getting changes to entity arrays in the current bundle

In addition to entity array properties supporting the isFieldChanged and getOriginalValue methods, you can test for changes to entity array contents in the current bundle. You use methods to compare the array on the persisted entity instance to the array on the cached version in the bundle.

The following methods are available only for properties directly defined on an entity in the data model configuration files as entity arrays. These methods do not work on other types of properties or methods. For example:

  • These methods do not work with Gosu enhancement properties that return entity arrays.
  • These methods do not work with other virtual properties such as those implemented in internal Java code.

Use the Data Dictionary to check whether a property is a database-backed property or a virtual property.

Entity methods for getting changes to array properties

The following table lists the methods on an entity instance that you can use to get entity array changes.

Entity method

Argument

Return type

Returns

getAddedArrayElements

Array property name

Entity array

A list of array elements that were added. If there are none, returns an empty array.

getChangedArrayElements

Array property name

Entity array

A list of array elements that were changed. If there are none, returns an empty array.

getRemovedArrayElements

Array property name

Entity array

A list of array elements that are marked for deletion if the bundle commits. If there are none, returns an empty array.

isArrayElementChanged

Array property name

boolean

true if and only if an element in an array changes, in other words if one or more properties change on the entity. If no existing element changes but elements add or remove, this returns false.

isArrayElementAddedOrRemoved

Array property name

boolean

true if and only if any array elements were added or removed.