0 Replies Latest reply on Aug 22, 2007 12:48 PM by Luca Maistrello

    two units in persistence.xml

    Luca Maistrello Newbie

      Hi guys!

      I have a persistence.xml file with two persistence unit:

      <persistence-unit name="CPTAdminPU" transaction-type="RESOURCE_LOCAL">
      org.hibernate.ejb.HibernatePersistence

      <!-- the datasource (that must be deployed on JBoss) -->
      <non-jta-data-source>java:CPTAdminDB</non-jta-data-source>

      <!-- entity list -->
      com.gsk.mdr.cpt.admin.entity.ProgramEntity
      com.gsk.mdr.cpt.admin.entity.UserEntity


      <!-- Hibernate settings -->






      </persistence-unit>


      <!--
      - ProjectP3IPU persistence unit used by the JBoss application.
      -->
      <persistence-unit name="CPTProjectP3IPU" transaction-type="RESOURCE_LOCAL">
      org.hibernate.ejb.HibernatePersistence

      <!-- the datasource (that must be deployed on JBoss) -->
      <non-jta-data-source>java:CPTProjectP3IDS</non-jta-data-source>

      <!-- entity list -->
      com.gsk.mdr.cpt.admin.entity.ProjectP3I


      <!-- Hibernate settings -->






      </persistence-unit>

      the two units maps to this datasources:

      <local-tx-datasource>
      <jndi-name>CPTAdminDB</jndi-name>
      <connection-url>**********************</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>*********</user-name>
      ********
      <min-pool-size>5</min-pool-size>
      <max-pool-size>20</max-pool-size>
      </local-tx-datasource>

      <local-tx-datasource>
      <jndi-name>CPTProjectP3IDS</jndi-name>
      <connection-url>********************</connection-url>
      <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
      <user-name>***************</user-name>
      **********
      <min-pool-size>10</min-pool-size>
      <max-pool-size>500</max-pool-size>

      <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
      <valid-connection-checker-class-name>
      org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
      </valid-connection-checker-class-name>

      <!-- Checks the Oracle error codes and messages for fatal errors -->
      <exception-sorter-class-name>
      org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
      </exception-sorter-class-name>
      </local-tx-datasource>

      My code uses the first persistence unit until i have to validate p3i id, and at this time i try to create an EntityManagerFactory for the second unit:

      AtlasProgramIDValidator.java line 35:
      emf = PersistenceManager.getInstance().getEntityManagerFactory("CPTProjectP3IPU");

      but i obtain this error:

      org.hibernate.HibernateException: Missing table: CPT_ACCESS
      at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1080)
      at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
      at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:317)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
      at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
      at com.gsk.mdr.cpt.admin.util.PersistenceManager.getEntityManagerFactory(PersistenceManager.java:62)
      at com.gsk.mdr.cpt.admin.validator.AtlasProgramIDValidator.validate(AtlasProgramIDValidator.java:35)

      But the CPT_ACCESS table is on the first unit, is the table to which is mapped this class
      com.gsk.mdr.cpt.admin.entity.UserEntity

      Can anyone help me ??????

      ---------------------------------------------------------------
      Office ext.:+39 045 821 8523
      Office int.: 718 8523
      e-mail: luca.2.maistrello@gsk.com