Thursday, December 31, 2015

Hibernate write-behind technique

Hibernate implements a technique known as write-behind, to minimize the impact of network latency and duration of database lock.  This enables hibernate makes DML calls as late as possible.

What it actually means is: When objects associated with a persistence context are modified (by update/delete), the changes are not propagated immediately to the database.

Benefits of this technique

  1. If you made two updates to an entity in a session; hibernate doesn't have to make two SQL updates. It can manage both in the same update. 
  2. Hibernate can make use of JDBC batch update when it executes multiple INSERT, UPDATE or DELETE.
  3. Repeated flushing (synchronization of a persistence context with the database) of the persistence context also impacts performance. All dirty objects in the persistence context need to be detected (at the flush time), so if the size of persistent context is large then dirty checking can cause a lot of performance penalty. 

No comments:

Post a Comment