persistence@glassfish.java.net

Re: Extending the persistence unit

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Wed, 03 Oct 2007 08:01:10 -0400

The spec says:

"A persistence unit may be packaged within *one or more* jar files
contained within a WAR or EAR, as a
set of classes within an EJB-JAR file or in the WAR classes directory,
or as a combination of these as
defined below."

Notice the "one or more" above. It leads me to believe that a
persistence unit may be defined in more than one persistence.xml files.

My question is whether the spec supports having one of these
persistence.xml files in a directory in the classpath (and not in a jar,
war, ear etc.).

Thanks for your help.

Sahoo wrote:
> There is one persistence.xml per persistence-unit.
> META-INF/persistence.xml can be anywhere in the classpath as long as
> it contains the list of persistence class names. Look at chapter #6.2
> of the JPA 1.0 spec.
>
> Thanks,
> Sahoo
>
> Farrukh Najmi wrote:
>>
>> I have a base project (base-project) that produces a jar with
>> persistence classes and a META-INF/persistence.xml file.
>>
>> Next, I want to use a standalone test program that depends upon the
>> base-project.jar for persistence classes and wish to add additional
>> persistence.xml files (to add entity listeners and perhaps additional
>> persistence classes etc.).
>>
>> Does the spec require that any additional persistence.xml files be in
>> a jar/war etc. or can it be anywhere in the classpath including under
>> a directory in classpath?
>>
>> Specifically, is it legal to place it in META-INF/persistence.xml in
>> any directory on the classpath and expect it to be processed by the
>> Persistence provider?
>>
>> TIA for your help.
>>


-- 
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com