0 Replies Latest reply on Dec 5, 2007 8:39 AM by icordoba

    Multiple datasources for same persistence unit

    icordoba

      Hi there,
      I have an application packaged in an .ear file.
      It has 3 jars.
      I've included a persistence.xml file in each jar, because all EJBs point to the same persistence unit name (they are already compiled this way).
      I cannot specify a different datasource for that same persistence unit name.
      Is this possible? (isolating config options for a same name persistence unit between different jars in an ear) It seems to me that the first persistence.xml file loaded is taken and the parameters from the rest are ignored. Here is one of my persistence.xml files. (what I changes over them is "<jta-data-source>" parameter trying to point to another data source, with no success)

      Thanks for any help,
      Ignacio


      <?xml version="1.0" encoding="UTF-8" ?>
      <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" xmlns="http://java.sun.com/xml/ns/persistence">
       <persistence-unit name="mainPersistenceUnit">
       <jta-data-source>java:/tuportalDS</jta-data-source>
       <properties>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
       <property name="hibernate.connection.useUnicode" value="true" />
       <property name="hibernate.connection.characterEncoding" value="UTF-8" />
       </properties>
       </persistence-unit>
      </persistence>