Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] Loading multiple persistence.xml files

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
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev


Back to the top