Hibernate / EclipseLink Interview questions
What is the difference between attribute change tracking and deferred change detection?
Both policies exist to answer the same question at commit time, "what actually changed on this entity", but they get there through different mechanisms with different runtime costs.
| Attribute change tracking | Deferred change detection |
| Records each change the instant a woven setter is called. | Detects changes by comparing to a stored backup copy at flush time. |
| No need to hold a full backup copy of the entity's original state. | Requires keeping an original clone of every managed entity in memory. |
| Change-detection cost is small and spread throughout the transaction. | Change-detection cost is concentrated as one comparison pass right before commit. |
| Only available when weaving is active. | Works regardless of whether weaving is applied. |
EclipseLink automatically selects attribute change tracking whenever weaving is available, since it's strictly more efficient; deferred change detection exists as the fallback for the (increasingly rare) cases where weaving genuinely can't be applied, ensuring change detection still functions correctly even without it, just at a higher memory and CPU cost.
More Related questions...