Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] eclipselink-orm.xml overriding question

Hi Laird,

You must name the file exactly "eclipselink-orm.xml" to grant it the special override privileges otherwise when it is named "my-eclipselink-orm.xml" it will be treated just like any other mapping file and will try to merge the metadata, hence throwing the conflict error below.

Thanks,
Guy

On 15/01/2016 1:30 PM, Laird Nelson wrote:
Hello; https://wiki.eclipse.org/EclipseLink/Examples/JPA/EclipseLink-ORM.XML says, in part:

"This mapping file can be used in place of JPA's standard mapping file or can be used to override a JPA mapping file."

I'm interested in doing the latter, not the former.

In my persistence.xml, I have this:

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

In my-real-orm.xml, I have an <entity> mapping that includes a one-to-many mapping on an attribute named "names".  It's very straightforward.

In my-eclipselink-orm.xml, all that I am interested in doing is adding a <batch-fetch> element to the particular one-to-many mapping mentioned above.

When I add the bare minimum of XML to my-eclipselink-orm.xml to accomplish this, I receive the following error:

"Conflicting XML elements [<one-to-many>] with the same name [names] were found. The first was found in the mapping file [file:/Users/ljnelson/Projects/foo/target/classes/META-INF/my-eclipselink-orm.xml] and the second in the mapping file [file:/Users/ljnelson/Projects/foo/target/classes/META-INF/my-real-orm.xml]. Named XML elements must be unique across the persistence unit."

The bare minimum looks like this:

<entity class="the.entity.class.in.Question">
  <attributes>
    <one-to-many name="names">
      <batch-fetch size="10" type="JOIN"/>
    </one-to-many>
  </attributes>
</entity>

I'm unclear how an eclipselink-orm.xml file can override a JPA mapping file if this is the case.  How do I designate the entity whose XML mapping information should be augmented?

Best,
Laird


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top