0 Replies Latest reply on Jul 9, 2007 4:37 AM by Marius Lessiak

    seam-gen, EJBs and different databases

    Marius Lessiak Newbie

      i searched the forums and the docs but could not find the answer to my question. setup is jboss as 4.0.5 GA, seam 1.2.1GA, mysql 5.1, mysql connector 5.0.6, eclipse europa.

      i have a seam-gen genereted app with EJBs reverse engineered through hibernate. the EJBs all use annotations and are connected to the db via a jndi datasource (as far as i understand). the datasource is defined in app-dev-ds.xml, then the jndi is referenced in persistence-dev.xml to get an EntityManagerFactory which is finally used in componments.xml:

      <core:managed-persistence-context name="entityManager"
       auto-create="true"
       persistence-unit-jndi-name="java:/appEntityManagerFactory"/>
      


      this setup is autogenerated and works nicely. the EJBs are all bound to the corresponding database tables.

      now i'd like to bring in a new EJB to access a different table in another database. so i duplicated the configuration: added a second datasource in persistence-dev.xml, a second entry in persistence-dev.xml and created a second managed-persistence-context in components.xml. that works fine and i see in the log output that the new managed-persistence-context is created. after that my problem occurs.

      after succesfully binding the EJBs to entityManager1 the JPA tries to (re)bind all EJBs to entityManager2 which is of course not possible since it ties into another database table. so i guess i have to exlicitly configure every EJB for a specific entityManager (1 or 2)? but where should i do that? i tried to use @PersistenceContext(unitName="entityManager1") in the EJBs but that did not work.

      i have some experience with spring and hibernate but i feel that i need better knowhow on the jboss-seam ejb hibernate integration to work that question out. so thx in advance for any advice.