public class EntityCallbacksListener extends java.lang.ObjectA listener class to invoke entity callbacks in cases where Hibernate doesn't invoke the callback as expected.
JPA defines a few annotations, e.g.
PostLoad, that we can use for the application to react to certain events that occur inside the persistence mechanism. However, Hibernate only supports a few basic use cases, e.g. defining a
PostLoadmethod directly in an
Entityclass or in an
Embeddableclass. If the annotated method is defined in an
Embeddableclass that is a property of another
Embeddableclass, or it is defined in a parent class of the
Embeddableclass, Hibernate doesn't invoke it.
This listener is added in core/src/main/resources/META-INF/orm.xml as a default entity listener whose annotated methods will be invoked by Hibernate when corresponding events happen. For example,
prePersist(java.lang.Object)will be invoked before the entity is persisted to the database, then it will recursively invoke any other
PrePersistmethod that should be invoked but not handled by Hibernate due to the bug.
Constructors Constructor Description