-
1. Re: Persistence unit scoping across multiple jars in a singl
raja05 Aug 13, 2006 6:13 AM (in response to k34216)From the EJB Spec,
A persistence unit must have a name. Only one persistence unit of any given name may be defined within a single EJB-JAR file, within a single WAR file, within a single application client jar, or within an EAR (in the EAR root or lib directory).
And as for scope of the persistence.xml (between EJB, WEB, or EAR)
A persistence unit that is defined at the level of the EAR is generally visible to all components in the application.
So if you put your generic persistence.xml in the root folder(where your EAR is defined or in a lib subfolder), all your sub deployments should be able to use that. -
2. Re: Persistence unit scoping across multiple jars in a singl
raja05 Aug 13, 2006 6:36 AM (in response to k34216)That said, the above dint work for a trivial example for me. Can you verify this as well? (Or am i reading the spec wrong ?)
-
3. Re: Persistence unit scoping across multiple jars in a singl
raja05 Aug 13, 2006 11:23 AM (in response to k34216)Sorry scratch my previous comment, it does work well if you put the persistence.xml in a jar file and make it a part of your archive. Note that you would have to enter the jar file containing the managed classes in the persistence.xml file.
-
4. Re: Persistence unit scoping across multiple jars in a singl
grdzeli_kaci Aug 13, 2006 12:16 PM (in response to k34216)hi all, i had already problem like this and my mistake was that i hadn't unitname in the persistance.xml file
i think if u must add this in u your persistance.xml<persistence-unit name="Blah1" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
in second persistanc.xml<persistence-unit name="Blah2" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
u also could put more then one persistance unit in one persistance.xml file<persistence-unit name="Blah1" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit> <persistence-unit name="Blah2" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
-
5. Re: Persistence unit scoping across multiple jars in a singl
k34216 Aug 14, 2006 12:23 PM (in response to k34216)Right, but in my tests, if you had different unit names then the entity beans couldn't have any relationships between them.
The only solution I have found is like raja05 said, is to put the persistence.xml in a jar file in the ear file. And then reference from that persistence.xml file all the other jars."grdzeli_kaci" wrote:
hi all, i had already problem like this and my mistake was that i hadn't unitname in the persistance.xml file
i think if u must add this in u your persistance.xml<persistence-unit name="Blah1" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
in second persistanc.xml<persistence-unit name="Blah2" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
u also could put more then one persistance unit in one persistance.xml file<persistence-unit name="Blah1" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit> <persistence-unit name="Blah2" transaction-type="JTA"> <jta-data-source>java:/XAOracleDS</jta-data-source> <class>com.magti.businesslayer.ejb3entity.oracle.Test</class> <properties> [props] </properties> </persistence-unit>
-
6. Re: Persistence unit scoping across multiple jars in a singl
jeffbrooks Aug 18, 2006 6:14 PM (in response to k34216)The only solution I have found is like raja05 said, is to put the persistence.xml in a jar file in the ear file. And then reference from that persistence.xml file all the other jars.
How exactly did you do that?
Can you list what settings you put into what files and show how the .ear is structured?
Jeff Brooks -
7. Re: Persistence unit scoping across multiple jars in a singl
buttmanizer Sep 13, 2006 2:24 AM (in response to k34216)"JeffBrooks" wrote:
The only solution I have found is like raja05 said, is to put the persistence.xml in a jar file in the ear file. And then reference from that persistence.xml file all the other jars.
How exactly did you do that?
Can you list what settings you put into what files and show how the .ear is structured?
Jeff Brooks
yeah i have the same problem. please be tell us how exactly you did that -
8. Re: Persistence unit scoping across multiple jars in a singl
webmarck Sep 13, 2006 4:21 AM (in response to k34216)I have the same problem so a solution would be very nice.
"raja05" wrote:
from the EJB Spec,
Quote:
A persistence unit must have a name. Only one persistence unit of any given name may be defined within a single EJB-JAR file, within a single WAR file, within a single application client jar, or within an EAR (in the EAR root or lib directory).
But as understand it then JBoss 4.0.x will not support the new ear file layout - so does this work with the current version of JBoss?