3 Replies Latest reply on Oct 13, 2011 7:47 AM by pradeep kumar

    Config multiple entityManagers in Seam

    pradeep kumar Newbie

      Hi Seamers


      i have situation, i am configuring two entityManagers successfull with out no errors, following by this url
      http://seamframework.org/Documentation/HowDoIUseMultipleDynamicEntityManagersInSeam


      everythig is fine, but, i have a problem,


      the problem is


      1st database tables is copying into 2nd database. I dont know why? and i dont want that, i cant really find the bug.
      here is my configuration details



      Persistence-prod.xml


      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
              version="1.0">
      
              <persistence-unit name="admin1" transaction-type="JTA">
                      <provider>org.hibernate.ejb.HibernatePersistence</provider>
                      <jta-data-source>mobeeadminDatasource</jta-data-source>             
                      <mapping-file>META-INF/orm.xml</mapping-file>
                      
                      <exclude-unlisted-classes>true</exclude-unlisted-classes>
                      <properties>
                              <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
                              <property name="hibernate.hbm2ddl.auto" value="update" />
                              <property name="hibernate.jdbc.batch_size" value="20" />
                              <property name="hibernate.cache.use_second_level_cache"      value="true" />
                              <property name="hibernate.show_sql" value="false" />
                              <property name="hibernate.default_schema" value="database1" />
                              <property name="hibernate.transaction.manager_lookup_class"
                                      value="@transactionManagerLookupClass@" />
                      </properties>
              </persistence-unit>
              
              <persistence-unit name="admin2" transaction-type="JTA">
                      <provider>org.hibernate.ejb.HibernatePersistence</provider>
                      <jta-data-source>mobeeadminDatasource2</jta-data-source>
                      <mapping-file>META-INF/orm2.xml</mapping-file>              
                      <exclude-unlisted-classes>true</exclude-unlisted-classes>
                      <properties>
                              <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
                              <property name="hibernate.hbm2ddl.auto" value="update" />
                              <property name="hibernate.jdbc.batch_size" value="20" />
                              <property name="hibernate.cache.use_second_level_cache"      value="true" />
                              <property name="hibernate.show_sql" value="false" />
                              <property name="hibernate.default_schema" value="database2" /> 
                              <property name="hibernate.transaction.manager_lookup_class"     
                                          value="@transactionManagerLookupClass@"/>                
                      </properties>
              </persistence-unit>
      </persistence>




      projectName-prod-ds.xml


      <datasources>
              <local-tx-datasource>
                      <jndi-name>adminDatasource</jndi-name>
                      <use-java-context>false</use-java-context>
                      <connection-url>jdbc:oracle:thin:@localhost:1521:xe</connection-url>
                      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                      <user-name>database1</user-name>
                      <password>**********</password>             
              </local-tx-datasource>
              
              <local-tx-datasource>
                      <jndi-name>adminDatasource2</jndi-name>
                      <use-java-context>false</use-java-context>
                      <connection-url>jdbc:oracle:thin:@localhost:1521:xe</connection-url>
                      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
                      <user-name>database2</user-name>
                      <password>**********</password>
              </local-tx-datasource>
      </datasources>





      Components.xml


      <persistence:entity-manager-factory
                      installed="@seamBootstrapsPu@" name="entityManagerFactory"
                      persistence-unit-name="admin1" />
              <persistence:managed-persistence-context
                      auto-create="true" entity-manager-factory="#{entityManagerFactor}" name="entityManager"
                      persistence-unit-jndi-name="java:/entityManager" />
      
              <persistence:entity-manager-factory name="entityManagerFactory2" 
                            persistence-unit-name="admin2"/>
              <persistence:managed-persistence-context name="entityManager2"
              auto-create="true" entity-manager-factory="#{entityManagerFactory2}"
              persistence-unit-jndi-name="java:/entityManager2"/>