users@glassfish.java.net

Re: GF3 + OpenJPA 2.0 - Enhancer not working

From: <glassfish_at_javadesktop.org>
Date: Tue, 20 Jul 2010 08:42:45 PDT

Hi Mitesh,

I'm running a class, which is used for DB connections, let's call it MyEntityManager:

public class MyEntityManager {
  
  @PersistenceUnit(unitName="myApplicationPersistenceUnit")
  private EntityManagerFactory emfTmp;
  private EntityManager em;
  private EntityManager em2;

  @PersistenceContext(unitName="myApplicationPersistenceUnit")
  private EntityManager emTmp;

  public MyEntityManager(){
    em = emfTmp.createEntityManager();
  }

  public void someMethod(){

     em.createQuery(....);
  }
}

I also tried the @PersistenceContext EntityManager dependency injection, but both ways failed i.e. the variables stayed null.

Looking up the EntityManagerFactory using a Context.lookup method works, but then the Enhancer is not running.

Thanks again.

kniffte
[Message sent by forum member 'kniffte']

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