Use the <tt>orm.xml</tt> file to apply the metadata to the persistence unit. This metadata is a union of all the mapping files and the annotations (if there is no <tt>xml-mapping-metadata-complete</tt> element). If you use one mapping <tt>orm.xml</tt> file for your metadata and place this file in a <tt>META-INF</tt> directory on the classpath, then you do not need to explicitly list it. The EclipseLink persistence provider will automatically search for this file (<tt>orm.xml</tt>) and use it.

Use the <tt>orm.xml</tt> file to apply the metadata to the persistence unit. This metadata is a union of all the mapping files and the annotations (if there is no <tt>xml-mapping-metadata-complete</tt> element). If you use one mapping <tt>orm.xml</tt> file for your metadata and place this file in a <tt>META-INF</tt> directory on the classpath, then you do not need to explicitly list it. The EclipseLink persistence provider will automatically search for this file (<tt>orm.xml</tt>) and use it.

−

If you use a different name for your mapping files or place them in a different location, you must list them in the <code>mapping-file</code> element of the [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Configuration/JPA/persistence.xml|persistence.xml file]], as shown here:

+

The schema for the JPA 2.0 orm.xml is [http://java.sun.com/xml/ns/persistence/orm_2_0.xsd <tt>orm_2_0.xsd</tt>].

+

+

If you use a different name for your mapping files or place them in a different location, you must list them in the <tt>mapping-file</tt> element of the [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Configuration/JPA/persistence.xml|<tt>persistence.xml</tt>]] file, as shown here:

Specifying Object-Relational Mappings Using orm.xml

Use the orm.xml file to apply the metadata to the persistence unit. This metadata is a union of all the mapping files and the annotations (if there is no xml-mapping-metadata-complete element). If you use one mapping orm.xml file for your metadata and place this file in a META-INF directory on the classpath, then you do not need to explicitly list it. The EclipseLink persistence provider will automatically search for this file (orm.xml) and use it.

Note: In this example, the orm.xml file is not listed -- the persistence provider finds it by default.

The following is an example of an orm.xml file.

<?xmlversion="1.0"encoding="UTF-8"?><entity-mappingsversion="2.0"xmlns="http://java.sun.com/xml/ns/persistence/orm"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"><description>The minimal mappings for a persistent entity in XML.</description><entityname="Employee"class="org.acme.Employee"access="FIELD"><attributes><idname="id"/></attributes></entity></entity-mappings>

XML Schema Validation

By default the content of your orm XML file is not validated against the JPA orm XML schema.

During development it is a good idea to validate your orm XML file against the schema to ensure it is valid.
In EclipseLink orm XML schema validation can be enabled using the persistence unit property "eclipselink.orm.validate.schema" in your persistence.xml file.