What does Hibernate PostInsertEventListener.requiresPostCommitHanding do?

Viewed 914
1 Answers

It seems, when the PostInsertEventListener is registered as EventType.POST_INSERT, the method is not called at all and the listener is always executed before committing the transaction.

However, if the listener is registered as EventType.POST_COMMIT_INSERT the method is actually called and if it returns true the listener will be called after committing the transaction. If it returns false the listener will not be called at all.

Also, if the listener is of type PostInsertEventListener the onPostInsert method will be called regardless of whether the transaction was successful or not. If the listener is of type PostCommitInsertEventListener the onPostInsert method will only be called for successful transactions. Otherwise, the onPostInsertCommitFailed method is called.

Related