persistence@glassfish.java.net

Re: Single persistence unit spread over multiple files

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 02 Jan 2007 13:50:31 -0800

Martin,

No, you can't have more than one persistence.xml file for the same PU.

thanks,
-marina

Martin Bayly wrote:
> Is it supported to have a single persistence unit spread over multiple
> persistence xml files?
>
> The background behind this question is that we have a modular app where
> each module contributes some persistent entities.
> I would like to define a persistence.xml file for each module and have
> them all 'contribute' to a single common persistence unit at runtime.
>
> i.e. one module's xml file would contain:
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> <persistence-unit name="pu1">
>
> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
>
>
> <class>com.mydomain.domain.Course</class>
>
> </persistence-unit>
> </persistence>
>
> And another module's persistence.xml file might contain
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
> <persistence-unit name="pu1">
>
> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
>
>
> <class>com.mydomain.domain.User</class>
>
> </persistence-unit>
> </persistence>
>
>
> Thanks
> Martin