[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Multiple datasources for same persistence unit

icordoba do-not-reply at jboss.com
Wed Dec 5 08:39:11 EST 2007

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,

 <?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>

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110519#4110519

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110519

More information about the jboss-user mailing list