users@glassfish.java.net

Re: PostLoad life cycle callbacks for Entities invoked twice

From: <glassfish_at_javadesktop.org>
Date: Thu, 25 Sep 2008 06:07:40 PDT

OK, I found another way. I've managed to have a superclass of all my EJB classes, that contains the injection of EntityManager :

@PersistenceContext protected EntityManager em;

and a method annotated @PostConstruct that sets the EntityManager on a ThreadLocal variable. So I can get my EntityManager in my POJO that serves as EntityListener.

Maybe this helps someone, one day.
[Message sent by forum member 'rjuncu' (rjuncu)]

http://forums.java.net/jive/thread.jspa?messageID=301571