1 Reply Latest reply on Jul 23, 2009 10:44 AM by jaikiran pai

    Problem creating self contained datasource and entity manger

    Mohit Anchlia Novice

      Jboss 4.2:

      We are currently having problems with getting EntityManager that is self contained only for .ear environment. Instead what is happening is that even though we have separate persistence.xml in each .ear file still entity manager is not becoming container specific. It's still getting loaded globally.

      Below is the persistence.xml in each .ear file. Datasource also is self contained inside the .ear file.

       <persistence-unit name="EeEM" transaction-type="JTA">
       <property name="hibernate.dialect"
       <!-- For debugging -->
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.connection.driver_class"
       <!-- Workaround for Oracle 10G driver bug -->
       <property name="hibernate.jdbc.batch_size" value="0"/>
       <!-- Enable this is hibernate should be responsible for creating
       tables. -->
       <!--property name="hibernate.hbm2ddl.auto" value="create"/-->
       <property name="hibernate.connection.datasource" value="java:/EeDS"/>
       <property name="jboss.entity.manager.jndi.name" value="java:/EntityManagers/EeEM"/>
       <property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactories/EeEM"/>

       <connection-property name="SetBigStringTryClob">true</connection-property>
       <!-- recommended by Oracle support to avoid ORA-01461 errors -->
       <connection-property name="oracle.jdbc.RetainV9LongBindBehavior">true</connection-property>
       <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the
       pool -->
       <!-- Checks the Oracle error codes and messages for fatal errors -->
       <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global
      transaction and vice-versa -->
       <!-- sql to call when connection is created
       <new-connection-sql>some arbitrary sql</new-connection-sql>
       <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConn
      ectionChecker is prEered
       <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
       <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

      Above .xml files lives inside each .ear file. Now I expect 2 Entitiy Manger very specific to each .ear file deployment. Instead we are getting only one entity manager - the last one that gets loaded - for entire JVM environment. What can we do to seprate it out. We tries "isolate" of .ear but that doesn't work either. Any example or suggestions will be helpful.