[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-dev] Loading multiple persistence.xml files
|
Hi Carl,
What issues are you seeing when you specify several orm files within the same
persistence unit definition in one persistence.xml file?
e.g.
<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 persistence_1_0.xsd"
version="1.0">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<mapping-file>META-INF/advanced-entity-mappings.xml</mapping-file>
<mapping-file>META-INF/inheritance-entity-mappings.xml</mapping-file-->
<mapping-file>META-INF/inherited-entity-mappings.xml</mapping-file>
<mapping-file>META-INF/relationships-entity-mappings.xml</mapping-file>
etc....
-Tom
Carl Hall wrote:
Hi, Tom.
You've nailed it. Each persistence.xml is trying to create the same
persistence unit ("default"). Is there a nice way to load 1 persistence
unit from multiple orm.xml files? I've seen some classloader tricks to
accomplish this but don't want to head down that rabbit hole unless
necessary.
Thanks,
Carl
On Wed, Dec 17, 2008 at 10:55, Tom Ware <tom.ware@xxxxxxxxxx
<mailto:tom.ware@xxxxxxxxxx>> wrote:
Hi Carl,
Are you using separate EntityManagers for each persistence unit?
An EntityManager represents one persistence unit - when the
EntityManagerFactory is created, you get it by persistence unit
name. Any EntityManager created by that factory will represent that
persistence unit.
The name of a persistence unit is specified in the persistence.xml
and only one persistence.xml may be used to define a given
persistence units. It is an error to have multiple persistence.xml
that define the same persistence unit and the behavior is undefined
- I am not surprised that if you are doing this, you get the last
one loaded.
To access different persistence units, create an EntityManager for
each.
-Tom
Carl Hall wrote:
I have a setup where multiple project come into a shared
classloader. Each project can have its own model files and
thusly its own persistence.xml and orm.xml files. When I create
an EntityManager, I see in the logs that each persistence.xml
file is found (3) and each orm.xml file loads with the expected
entities. When I try to query or persist using this
EntityManager, only the entities from the lastly loaded
persistence.xml is found. Am I loading this correctly? Am I
trying to access things incorrectly?
------------------------------------------------------------------------
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx <mailto:eclipselink-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx <mailto:eclipselink-dev@xxxxxxxxxxx>
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
------------------------------------------------------------------------
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev