Hibernate / EclipseLink Interview questions
How does EclipseLink implement change tracking for detecting entity modifications?
EclipseLink supports several change-tracking policies, chosen automatically based on whether weaving is applied, that determine how it figures out which fields of a managed entity actually changed and need to be included in the next update statement.
| Attribute change tracking | Deferred change detection |
| Requires weaving. | Works without weaving. |
| Tracks changes as they happen, via woven setter instrumentation. | Compares the entity's current state to a cached original copy at flush/commit time. |
| Only modified attributes are included in the generated UPDATE statement. | Requires cloning and comparing the full object, which is more memory- and CPU-intensive. |
| Change detection cost is spread across the transaction, not concentrated at commit. | Change detection happens all at once, right before commit. |
Attribute change tracking is the more efficient policy and is EclipseLink's default whenever weaving is active, since the woven setter methods can simply record that a specific field changed the moment it's set, rather than needing to keep and later diff an entire backup copy of the object's original state.
More Related questions...