So I just had an interesting realization, Hibernate uses various default listeners in it’s poorly documented event system to do all of its persistence work.
For example, saving an object through a Hibernate
Session object quickly goes to the
Session.fireSaveOrUpdate, which by default calls
DefaultSaveOrUpdateEventListener does all the heavy lifting of checking to see if the object legal to save prior to actually saving the object.
These default listeners also invoke interceptors as briefly described in section 12.1 of the 3.2.0.cr4 manual.
This means that if someone starts adding event listeners of their own, they better make damn sure that they add in Hibernate’s as well. Otherwise Hibernate will very quietly do nothing!
I filed this bug in the hopes that the documentation would get changed:
Please add this (or equivalent) to the bottom of section 12.1. (Interceptors):
Interceptors are invoked by Hibernate’s default event listeners. For example, interceptors’ onSave() method is invoked by Hibernate’s DefaultSaveOrUpdateEventListener
Please add this (or equivalent) to the bottom of section 12.2 (Event System):
When changing the event listeners be sure to keep the various Hibernate default listeners. These listeners actually perform much of Hibernate’s persistence work, including invocation of the interceptors. Without those default listeners, Hibernate will quietly do nothing.
|Event||Default Hibernate EventListener||Interceptor method called by default listener|
(return true to veto the insertion)
(on HSQL EntityIdentityInsertAction – which gets the generated id after the insertion)
(called even if the PreInsertEvent vetoed the insertion)