开发者

JPA interceptor / event listener that doesn't fire with Hibernate

@PostLoad 
public void initThing() { ... }

I added that to my entity but it seems on the entity load it's not called...

I use jpa on a spring context without EJB Hibernate 3.2.7

We already have some hibernate interceptors (extending EmptyInterceptor) declared inside the "entityInterceptor" of the session factory

Is it possible to mix both styles of interceptor?

Is it possible to use @PostLoad without EJB/EntityManager?

Another reaso开发者_Go百科n?


I don't believe the EJB annotations work without EJB/EntityManager.


For those interested, i got a response from Steve Ebersole and it seems that when you create your own hibernate SessionFactory, you can't use the JPA annotations like @PostLoad without registering the corresponding EventListener in that session factory... Actually the entity manager system do all this stuff for you.

So i guess i have to add the EJB3PostLoadEventListener to the session factory

But as in my case i have to make this available just for my subproject, i'll use an hibernate interceptor because they can be session scoped, and also injected this interceptor in an overriden spring HibernateTemplate declaration

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜