1 Reply Latest reply on Apr 21, 2009 11:10 PM by Arbi Sookazian

    Seam + JPA, couple questions...

    Gregory Nikle Apprentice

      I need to move my Seam app on Seam 2.0.1GA and jboss 4.2.1.GA to tomcat 6.


      My app works with couple databases. I use mostly 2 databases in one transaction like:
      sguniadm - administration db.
      sguni
      one, sgunitwo, sgunixxx


      So my questions:
      1. How can I configuree my EM in components.xml?
      Is this solution fine?



          <transaction:entity-transaction entity-manager="#{sguniAdm}" precedence="1" />                  
          <persistence:entity-manager-factory name="sguniAdmDatabase" />
          <persistence:managed-persistence-context name="sguniAdm" auto-create="true" entity-manager-factory="#{sguniAdmDatabase}"/>   
      
          <transaction:entity-transaction entity-manager="#{sguniOne}" precedence="2" />                  
          <persistence:entity-manager-factory name="sguniOneDatabase" />
          <persistence:managed-persistence-context name="sguniOne" auto-create="true" entity-manager-factory="#{sguniOneDatabase}"/>  




           @In
           private EntityManager sguniAdm;
           @In
           private EntityManager sguniOne;




      or maybe better to create each EM in transactional method:


      // Use persistence.xml configuration
      EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1")
      EntityManager em = emf.createEntityManager(); // Retrieve an application managed entity manager
      // Work with the EM
      em.close();
      ...
      emf.close(); //close at application end



      How can I manage transaction atomic in tomcat environment, using 2 db's in one transaction?
      In jboss it was simply to use xa-transaction, and ejb/jboss managed this in JTA.


      For now this conf will work on one server machine. Are there any problems to use it in clustered env.?


      My app uses Seam, Facelets, JSF 1.2 Quartz ram job asynch, postgres 8.1,