我正在尝试通过这个博客步骤.
http://leakfromjavaheap.blogspot.com.es/2013/08/prepersist-and-preupdate-not-working.html
但是从Hibernate 4.3开始,hibernate-entitymanager.jar中的事件包被删除了.
另一方面,我一直在阅读有关拦截器和事件的内容. http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#events
这只是实现@PrePersist行为的两种方式吗?或者可以在SessionFactory中使用@EntityListeners注释?虽然我更喜欢win @PrePersist注释兼容性.
先感谢您.
使用Hibernate 4,您可以使用Integerator spi方法.
虽然hibernate团队建议使用JPA EntityManager,但有时你只想继续使用旧的SessionFactory和JPA注释.
<dependency>
<groupId> org.hibernate </ groupId>
<artifactId> hibernate-entitymanager </ artifactId>
<version> 4.*</ version>
</ dependency>
org.hibernate.jpa.event.spi.JpaIntegrator
参考:
arkuarku.wordpress.com/2014/10/23/spring-hibernate4-enable-jpa-prepersistpreupdate-annotation-using-sessionfactroy/ 
请参阅:
https://docs.oracle.com/javase/tutorial/sound/SPI- intro.html 
http://in.relation.to/2012/01/09/event-listener-registration/
| 归档时间: | 
 | 
| 查看次数: | 2581 次 | 
| 最近记录: |