Adding or overriding entity mappings in the orm.xml file

You can use the Object Relational Mapping XML Editor to define object-relational mappings for JPA entity beans in the orm.xml file.

About this task

When you specify object-relational mappings using the JPA tools, the mapping information is contained in the Java™ class files in the form of Java annotations. However, you can also choose to define the object-relational mappings in XML in a file called orm.xml.

Mapping information that is defined in the orm.xml file automatically overrides both default JPA behavior and any mappings defined using annotations. Therefore, you can, for example, to adapt existing JPA entity beans to a different set of database tables without needing to modify the entity class files.

Important: The Object Relational Mapping XML Editor does not apply to projects with JPA version 2.1. Use the JPA Details view instead.

Complete the following steps to edit the orm.xml file that is in the META-INF directory of the JPA project.

Procedure

  1. In the Package Explorer view, right-click the orm.xml file of the JPA project that you want to edit, and select Open with > Object Relational Mapping XML Editor.
  2. In the Design tab of the Object Relational Mapping XML Editor, add object-relational mapping information.
  3. Click File > Save to save your changes.