Hibernate event listeners for JPA callbacks

前端 未结 2 1114
忘了有多久
忘了有多久 2020-12-21 00:45

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

2条回答
  •  囚心锁ツ
    2020-12-21 01:10

    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.

提交回复
热议问题