Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the EventType.POST_UPDATE and EventType.POST_COMMIT_UPDATE in Hibernate?

Tags:

hibernate

This question was raised in comment section of Hibernate interceptor and event listeners .

Below is my answer on that.

like image 764
Rohit Gaikwad Avatar asked Nov 28 '17 14:11

Rohit Gaikwad


1 Answers

The POST_COMMIT_UPDATE and POST_UPDATE are the events of type PostUpdateEventListener that occurs after the datastore is updated.

1) The POST_COMMIT_UPDATE should be used, if after transaction hooks need to be registered.
The method requiresPostCommitHandling returns true if after transaction callbacks should be added.
Here, is an example that depicts the use of POST_COMMIT_UPDATE.

2) The plain POST_UPDATE event is triggered based on hibernate flushing logic.
Here is an example of POST_UPDATE.

like image 52
Rohit Gaikwad Avatar answered Sep 21 '22 18:09

Rohit Gaikwad