1 Reply Latest reply on Jul 17, 2009 8:20 PM by Miloslav Vlach

    More than one entity manager

    Miloslav Vlach Novice


      I need to use two entity manager. One to out local database and the second to he database located in other place.

      I don't know If seam can play with this. So, I have created in components.xml new entry

      <persistence:managed-persistence-context name="entityManager" auto-create="true" entity-manager-factory="#{A}" />
      <persistence:entity-manager-factory name="A" persistence-unit-name="nameOfTheFIrstPU" />
      <persistence:managed-persistence-context name="emCapitol" auto-create="true" entity-manager-factory="#{B}" />
      <persistence:entity-manager-factory name="B" persistence-unit-name="nameOfTheSecondPU" />

      All seems to work but I have recieved courious exception:

      Unknown entity: cz.entity.from.second.persistenceunit.Account

      I have note that the entity is from the second entity manager. This exception is throws after client pick Account from selectOneMenu and call the component action Find.

      Populating the selectOneMenu is without any problem.

      So, I would like to know I is the problem the second entity manager or is another problem.

      Thanks all for help.


        • 1. Re: More than one entity manager
          Miloslav Vlach Novice


          i have find that I need to use this:

          in components.xml

          If you want to use more than one entity manager with the entity converter, you can create a copy of the entity converter for each entity manager; in components.xml:

          <component name="myEntityConverter" class="org.jboss.seam.ui.converter.EntityConverter">
            <property name="entityManager">#{em}</property>

          But when I do this I get exception:

          Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.seam.ui.converter.EntityConverter

          Know somebody what is happen ?

          Thanks Mila