How can I enable the Hibernate event listeners, that handle JPA callbacks?
Currently I am using using Hibernate 4 with SessionFactory configuration, but JPA callback
This question basically asked the same.
So it turns out, that these JPA entity listener annotations are only working when you are using EntityManager
in Hibernate (which is understandable). So if you want to use these annotations, you should ditch SessionFactory
, and use the JPA-complaint EntityManager
or EntityManagerFactory
.
I also recommend this approach, because if you are trying to use JPA annotations, it is logical to go for a pure JPA solution, without tying yourself to a Hibernate-specific solution - i.e. SessionFactory
.