Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Verifying whether eclipselink-orm.xml is being picked up

On Tue, Jun 18, 2013 at 12:00 PM, Guy Pelletier <guy.pelletier@xxxxxxxxxx> wrote:
Alternatively, did you try adding:

<mapping-file>META-INF/eclipselink-orm.xml</mapping-file>

to your persistence.xml directly?

I know that will work, yes.
 
The same discovery issue would also hold true if it were an orm.xml file and I don't believe EclipseLink is violating the JPA spec in this case (but I'll dig further)

Yes; no horse in that race other than being (perennially, terminally) curious.  The section in question is 8.2.1.6.2, which reads in part:

"A object/relational mapping XML file named orm.xml may be specified in the META-INF directory in the root of the persistence unit or in the META-INF directory of any jar file referenced by the persistence.xml.  Alternatively, or in addition, one or more mapping files may be referenced by the mapping-file elements of the persistence-unit element. These mapping files may be present anywhere on the class path."

Reading this as favorably to EclipseLink's implementation as possible, my scenario should fail (and does) because my persistence.xml references no jar files, and target/classes is not in a .jar file anyhow.  Furthermore, again reading this favorably to EclipseLink, although the last bit says "mapping files may be present anywhere on the class path" such mapping files would be picked up only if they were referenced by the mapping-file element in my persistence.xml.

That would be the end of the story (and is, I suppose) except for the next bit:

"An orm.xml mapping file or other mapping file is loaded as a resource by the persistence provider."

This sentence—if it is worthwhile at all—indicates how a mapping file is loaded (must be loaded?).  I assume that "as a resource" means that some variety of ClassLoader#getResource(String) must be used (otherwise I don't know what "as a resource" means, other than something hazy like "not as a filesystem path").  And maybe this sentence applies only to explicitly-mentioned mapping files.  I don't know.

Anyhow, note that indeed if the persistence provider is required to use that mechanism to load an unmentioned mapping file, then my target/classes/META-INF/eclipselink-orm.xml file should be found (if you guys are attempting to load it in exactly the same way as an unmentioned META-INF/orm.xml file).

Anyway, I know how to work around the problem but I'd be curious as to whether this is a specification violation.  I asked about it on the relevant JSR users mailing list and heard nothing either way.

Best,

Back to the top