I am trying do it throught this blog steps.
http://leakfromjavaheap.blogspot.com.es/2013/08/prepersist-and-preupdate-not-working.html
But starting from Hibernate 4.3, events package in hibernate-entitymanager.jar are removed.
In another hand, I had been reading about interceptors and events. http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#events
Are this only two ways to implement @PrePersist behaviour? or could use @EntityListeners annotation with SessionFactory?. Although I would prefer win @PrePersist annotation compatibility.
Thank you in advance.
With Hibernate 4, you can use Integerator spi approach.
Although the hibernate team suggest to use JPA EntityManager, but sometime you just want to keep using the good old SessionFactory with JPA annotations.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.*</version>
</dependency>
org.hibernate.jpa.event.spi.JpaIntegrator
Ref:
arkuarku.wordpress.com/2014/10/23/spring-hibernate4-enable-jpa-prepersistpreupdate-annotation-using-sessionfactroy/
See:
https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html
http://in.relation.to/2012/01/09/event-listener-registration/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With