lookup EntityManager within active TX in Model classes?

"Hans J. Prueller" <[email protected]> Tue, 15 Feb 2011 07:36:46 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Organization LBS logics GmbH
Message-ID <1297751806.2147.5.camel@kodos>
Hi all,

we are hard at work migrating our Java EE 1.4 based EAR application to
Java EE 5 and JOnAS 5.2.

Another issue that raised is the following:

Converting SLSB's to EJB3 works fine, also the injected EntityManager
for the business methods (@PersistenceContext ...)

In some special cases we need the EntityManager within the model classes
itself (as this is exsting code we simply have to take this as a 
given fact - whether it makes sense or not) - so for instance:

there is a static "clone" method of a model object or something like a
prePersist method of another model object and so on, and all of them
need to find/load other entities and traverse on the object graph, set
references/foreign keys, etc. -- so somehow the entitymanger is
required to to em.find(..); em.remove(); .... etc. operations

Is it possible and how  to lookup the current EntityManager of the
currently active transaction within a method of a model object ???

regards,
Hans