4 Replies Latest reply on Jun 12, 2009 6:15 PM by Arbi Sookazian

    How many EntityManager instances can I inject in one component?

    Arbi Sookazian Master

      Let's assume I have a Web Beans component (SFSB, for example) that access four different local RDBMS databases.  Yes, I know that's bizarre, but stay with me.


      So something like:


      @PersistenceContext(type=EXTENDED) EntityManager em1;
      @PersistenceContext(type=EXTENDED) EntityManager em2;
      @PersistenceContext(type=EXTENDED) EntityManager em3;
      @PersistenceContext(type=EXTENDED) EntityManager em4;



      which means there are four separate PersistenceUnit instances defined.


      Are there any negative consequences in doing this (and yes, even if we create four SFSB beans, one for each EntityManager instance)?


      Or in the case where there's only one local db/datasource, one LRC (@ConversationScoped SFSBs), and we want to ensure that all updates to the tables are done in their own PCs (i.e. if the entities are managed in one extended PC, then when the entityManager.flush() occurs, assuming AUTO flush/default b/c I'm assuming we can't use Hibernate manual flush with JPA 2.0 and this is not Seam, just WBRI, then all dirty state for updateable entities would be sync'd with the db tables via update tx's).


      This question is related to the recent thread I started (and nobody answered) in the Seam forum regarding one main form and multiple modalPanel forms and atomic conversations.


      So perhaps this has become a Seam 3 question, I don't know, but in any event, I'd like to know what is the upper limit of PCs you can use in one JEE 6 app.  thx.