Jump to: navigation, search

Difference between revisions of "EclipseLink/Examples/JPA/EclipseLink-ORM.XML"

(XML Configuration)
(XML Configuration)
Line 9: Line 9:
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="windows-1252" ?>
 
<?xml version="1.0" encoding="windows-1252" ?>
<entity-mappings xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm xsd/eclipselink_orm_1_0.xsd"
+
<entity-mappings
version="1.0"
+
 
xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
 
xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_0.xsd"
 +
version="1.0">
 +
</entity-mappings>
 
</source>
 
</source>
  

Revision as of 13:48, 23 July 2008

In EclipseLink 1.0 the new eclipselink-orm.xml mapping file is introduced (See bug 200040). This mapping file can be used in place of JPA's standard mapping file or can be used to override a JPA mapping file. In additional to allowing all of the standard JPA mapping capabilities it also includes advanced mapping types and options.

Note: Usage of this mapping file will enable many advanced features but may prevent the persistence unit from being portable to other JPA implementations

XML Configuration

The EclipseLink ORM schema (eclipselink_orm_1_0.xsd) can be used with the following header to define JPA and EclipseLink's advanced mappings.

<?xml version="1.0" encoding="windows-1252" ?>
<entity-mappings
	xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_0.xsd"
	version="1.0">
</entity-mappings>

Configuring usage in persistence.xml

A persistence unit can use one or more of these mapping files in the same way a standard JPA ORM mapping XML file can be used. The default location of /META-INF/orm.xml will automatically be picked up and used by any persistence unit.

If you want to use a different name for this mapping file or provide multiple mapping files they must be listed in the peristence.xml as:

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

Complete Example

The Employee JPA Example using XML illustrates how XML can be used exclusively (no annotations) to configure JPA usage. This example includes the usage of this EclipseLink specific JPA mapping XML file (see Employee example orm.xml).