2 Replies Latest reply on Oct 13, 2006 2:03 PM by taprogge

    ne emf.createEntityManager(EXTENDED) any more?

    taprogge

      Hi!

      I am using ejb3-rc8 on JBoss-4.0.4.GA.

      I am trying to get an EXTENDED EntityManager inside a servlet. Doing this in a lervlet just seemed to be the simplest way to write some data to the DB while migrating to a new, rewritten version of our application.
      I look up the EntityManagerFactory and UserTransaction from JNDI, call em.join(utx) and would be happy if I did not need an EntityManager in EXTENDED PersistenceContext.

      The docs I found all mention using

      EntityManagerFactory.createEntityManager(PersistenceContextType.EXTENDED)
      

      but that method does not seem to be there. I can only find
      createEntityManager();
      createEntityManager(Map properties);
      


      How do I go about getting this job done?
      If injection into servlets worked, I just would do
      @PersistenceContext(type=EXTENDED)
      EntityManager em;
      

      in my Servlet, but since it doesn't, there has to be another way.

      Thanks for any hints you can offer.

      Regards,
      Phil

        • 1. Re: ne emf.createEntityManager(EXTENDED) any more?
          bill.burke

          EMF always returns an extended EM now.

          • 2. Re: ne emf.createEntityManager(EXTENDED) any more?
            taprogge

            Hmm... why then do I get "detached object passed to persist" when I try to persist a newly created entity with collection mapping?

            I can persist anything just fine, but when I create an entity that holds a List of other entities (even when the list is still empty), that fails.
            I have already tried to merge() the entit instead of persisting it, but then em.find will return null for it while still in the same transaction. I would expect to see and use the entity later on to fill that collection...

            I am confused,

            Phil