1 Reply Latest reply on Nov 6, 2012 1:23 PM by gastaldi

    Persistence

    nickcave

      Hi guys...

      I changed my forge project to use 2 persistence units.

      But.. I need change the managed bean generated by "scaffold from-entity", to change units in runtime.

       

      I created a class to use this like a factory:

      @Named

      @Stateful

      @ConversationScoped

      public class AppEntityManagerFactory {

           

          public EntityManager getAppEntityManager(){

              EntityManagerFactory emf=Persistence.createEntityManagerFactory("forge-default");

              EntityManager em=emf.createEntityManager();

              return em;

           }

      }

       

      And in managed bean, I removed @PersistenceContext annotation at entityManager and I changed it to instanciate my class;

      private EntityManager entityManager=new AppEntityManagerFactory().getAppEntityManager();

      I get this error at debug.

      http://pastebin.com/h586Qmxy

       

      This is my persistence.xml

      http://pastebin.com/h0D9S933

        • 1. Re: Persistence
          gastaldi

          Hi Marcio,

           

          AFAIK, you can't use transaction-type="JTA" when creating entity managers using your approach.

           

          Best Regards,

           

          George