Sunday, June 2, 2013

Automatic Dirty checking and Transaction write-behind concepts of Hibernate

Hibernate uses a sophisticated algorithm to determine an efficient ordering that avoids database foreign key constraint violations but is still sufficiently predictable to the user. This feature is called transaction write-behind.

Automatic Dirty checkingIf object which is already saved is modified, then Hibernate automatically call update on that object.
Hibernate is capable of detecting all objects that are modified or are dirty. It is done with the help of PersistanceContext.
Within PersistanceContext, Hibernate has copy of all persistent objects that are loaded from database in Session. It compares persistent object to determine whether object is modified.


Hibernate allows implementation of custom dirty checking algorithm. This is done by implementing findDirty() method of org.hibernate.Interceptor interface for a Session.

No comments: