Yes, I hardly understand why it doesn't work.
To be more precise, my t4-core-commons project contains this persistence.xml file :
<?xml version="1.0" encoding="UTF-8"?>
| <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="t4Seam">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/jdbc/t4Seam</jta-data-source>
| <jar-file>../test-classes/lib/t4-core-utils-core.jar</jar-file>
| <properties>
| <property name="hibernate.hbm2ddl.auto"
value="update"/>
| <property name="hibernate.show_sql"
value="false"/>
| </properties>
| </persistence-unit>
| </persistence>
And t4-core-utils.jar contains the following persistence.xml file :
<?xml version="1.0" encoding="UTF-8"?>
| <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="t4Seam">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/jdbc/t4Seam</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto"
value="update"/>
| <property name="hibernate.show_sql"
value="false"/>
| </properties>
| </persistence-unit>
| </persistence>
I have some doubts on Hibernate behaviour when it finds two persistence.xml files with the
same persistence unit in the classpath. It looks like it takes into account only the first
one it finds in classpath. If t4-core-commons is first in the classpath, it crashes
because it can't find entities defined in t4-core-utils. If t4-core-utils is first in
the classpath, it loads only entities defined in t4-core-utils (entities there don't
depend on t4-core-commons ones) and not the ones defined in t4-core-commons. The only
solution I found to make it work is to build a jar that bundles entities of both
t4-core-commons and t4-core-utils, but as I said it's not very convenient. Do you have
more details about the way Hibernate behaves if it finds a persistenc unit twice ?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4183160#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...