Hibernate / EclipseLink Interview questions
Explain the internal working of EclipseLink's Unit of Work commit process?
When a transaction backed by a UnitOfWork commits, EclipseLink doesn't simply replay every change immediately; it goes through a structured sequence designed to compute the minimal, correctly-ordered set of SQL statements needed.
The change-set computation step relies on whichever change-tracking policy is active (attribute change tracking or deferred detection) to determine exactly which entities and fields actually changed. Dependency ordering matters because, for example, a new child row referencing a new parent row via a foreign key can't be inserted before the parent row exists; EclipseLink topologically sorts the pending operations so inserts happen in an order that respects those relationships, and deletes happen in the reverse order to avoid violating constraints.
Only after every generated SQL statement succeeds does EclipseLink merge the now-committed changes into the shared cache, making them visible to other EntityManagers from the same factory; if any statement fails, the whole unit of work rolls back and none of the changes reach either the database or the shared cache.
More Related questions...