Use @ChangeTracking to specify the org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy. This policy computes change sets for the EclipseLink commit process and optimizes the transaction by including objects in the change set calculation that have at least one changed attribute.
Table 2-9 describes this annotation's elements.
Table 2-9 @ChangeTracking Annotation Elements
| Annotation Element | Description | Default |
|---|---|---|
|
|
(Optional) The change tracking policy to use:
|
|
Use this annotation to configure an alternative change policy, if the automatic policy is having issues with your application. Using @ChangeTracking may improve commit performance for objects with few attributes or objects with many changed attributes.
Note:
When using change tracking with ATTRIBUTE or OBJECT, if you modify an object's field through reflection, EclipseLink will not detect the change. However, if you use DEFERRED, EclipseLink will detect the change.
Example 2-20 shows how to use @ChangeTracking to set the unit of work's change policy.
Example 2-20 Using @ChangeTracking Annotation
@ChangeTracking(DEFERRED)
@Entity
public class Employee {
...
}
Example 2-21 shows how to use the <change-tracking> element in the eclipselink-orm.xml file.
Example 2-21 Using <change-tracking> XML
<entity class="Employee"
<change-tracking type="DEFERRED"/>
...
</entity>
Example 2-22 shows how to configure change tracking in the persistence unit persistence.xml file or by importing a property map.
Example 2-22 Specifying Change Tracking in persistence.xml
Using persistence.xml file:
<property name="eclipselink.weaving.changetracking" value="false"/>
Using property map:
import org.eclipse.persistence.config.PersistenceUnitProperties;
propertiesMap.put(PersistenceUnitProperties.WEAVING_CHANGE_TRACKING, "false");
For more information, see:
"Enhancing Performance" in Solutions Guide for Oracle TopLink