There is no JPA spec-mandated way to do this. In OpenJPA, you can do the following:
EntityManager em = OpenJPAPersistence.getEntityManager(this); Note that the JPA spec does not require that impls allow you to operate on the EM during a callback. OpenJPA does allow this behavior. You might also be interested in the OpenJPA transaction-level or lifecycle-level callbacks. See the listener interfaces in org.apache.openjpa.event. You can add these with a call to OpenJPAEntityManager.addTransactionListener() and OpenJPAEntityManager.addLifecycleListener(). -Patrick On 5/10/07, Majeed Arni <[EMAIL PROTECTED]> wrote:
If I have @PrePersist or @PreRemove, in the methods that gets called, how can I access the Transaction object? Example: @PrePersist public void prePersist() { em.persist(anotherObj); // How do I get access to em? .... } Thanks for the help. -- View this message in context: http://www.nabble.com/Accessing-Trasaction-or-EnityManager-in-LifeCycle-methods-tf3722974.html#a10417736 Sent from the open-jpa-dev mailing list archive at Nabble.com.
-- Patrick Linskey 202 669 5907