When both <tt>orm.xml</tt> and <tt>eclipselink-orm.xml</tt> are specified in a project, the contents of <tt>eclipselink-orm.xml</tt> override <tt>orm.xml</tt> and any other JPA mapping file specified in the persistence unit. If there are overlapping specifications in multiple ORM files, the files are merged if there are no conflicting entities. {{EclipseLink_Note

+

'''[[Image:Elug_draft_icon.png|Warning]] See "Overriding and Merging Mapping Information" in the [http://www.eclipse.org/eclipselink/documentation/ EclipseLink Concepts Guide]'''

−

|note=The order of files defined in <tt>persistence.xml</tt> does not define the order of their processing. The files are processed, merged, and overidden as required. For more information, see [[#Overriding and Merging Examples|Overriding and Merging Examples]].}}

+

−

+

−

The <tt>eclipselink-orm.xml</tt> file can be referenced for inclusion in a persistence unit’s metadata through any of the following files or methods:

*<tt>META-INF/orm.xml</tt> - defines Entity A with the mappings b and c.

+

−

*<tt>META-INF/extensions/<tt>eclipselink-orm.xml</tt></tt> - defines defines Entity A with the mappings c and d. <br> '''Note:''' This file is added through a &lt;mapping-file&gt; tag in the <tt>persistence.xml</tt>

| If an entity-listeners exists, then the <tt>eclipselink-orm.xml</tt>'s entity-listeners will be merged with the list of all entity-listeners from the persistence unit.

+

−

|}

+

−

+

−

=== Entity Mappings ===

+

−

+

−

Entities, embeddables and mapped superclasses are defined within entity-mappings. <tt>eclipselink-orm.xml</tt>'s entities, embeddables and mapped superclasses are added to the persistence unit. The following table describes the top-level elements of the entity-mappings sections:

+

−

+

−

{|

+

−

|-

+

−

! entity-mappings/

+

−

! Rule

+

−

! Description

+

−

|-

+

−

| package

+

−

| None

+

−

| The package element specifies the package of the classes listed within the subelements and attributes of the same mapping file only. It is only applicable to those entities that are fully defined within the <tt>eclipselink-orm.xml</tt> file, else its usage remains local and is same as described in the JPA specification.

+

−

|-

+

−

| catalog

+

−

| None

+

−

| The catalog element applies only to the subelements and attributes listed within the <tt>eclipselink-orm.xml</tt> file that are not an extension to another mapping file. Otherwise, the use of the catalog element within the <tt>eclipselink-orm.xml</tt> file remains local and is same as described in the JPA specification.

+

−

|-

+

−

| schema

+

−

| None

+

−

| The schema element applies only to the subelements and attributes listed within the <tt>eclipselink-orm.xml</tt> file that are not an extension to another mapping file. Otherwise, the use of the schema element within the <tt>eclipselink-orm.xml</tt> file remains local and is same as described in the JPA specification.

+

−

|-

+

−

| access

+

−

| None

+

−

| The access element applies only to the subelements and attributes listed within the <tt>eclipselink-orm.xml</tt> file that are not an extension to another mapping file. Otherwise, the use of the access element within the <tt>eclipselink-orm.xml</tt> file remains local and is same as described in the JPA specification.

+

−

|-

+

−

| sequence-generator

+

−

| Full override

+

−

| A sequence-generator is unique by name. The sequence-generator defined in the <tt>eclipselink-orm.xml</tt> will override a sequence-generator of the same name defined in another mapping file. Outside of the overriding case, an exception is thrown if two or more sequence-generators with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| table-generator

+

−

| Full override

+

−

| A table-generator is unique by name. The table-generator defined in the <tt>eclipselink-orm.xml</tt> will override a table-generator of the same name defined in another mapping file. Outside of the overriding case, an exception is thrown if two or more table-generators with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| named-query

+

−

| Full override

+

−

| A named-query is unique by name. The named-query defined in the <tt>eclipselink-orm.xml</tt> will override a named-query of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more named-querys with the same name are defined in one or across multiple mapping file.

+

−

|-

+

−

| named-native-query

+

−

| Full override

+

−

| A named-native-query is unique by name. The named-native-query defined in the <tt>eclipselink-orm.xml</tt> will override a named-native-query of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more named-native-querys with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| sql-result-set-mapping

+

−

| Full override

+

−

| A sql-result-set-mapping is unique by name. The sql-result-set-mapping defined in the <tt>eclipselink-orm.xml</tt> will override a sql-result-set-mapping of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more sql-result-set-mapping entities with the same name are defined in one or across multiple mapping files.

+

−

|}

+

−

+

−

=== Mapped Superclass ===

+

−

+

−

A mapped-superclass can be defined completely, or with specific elements to provide extensions to a mapped-superclass from another mapping file. The following table lists individual override and merging rules:

+

−

+

−

{|

+

−

|-

+

−

! entity-mappings/mapped-superclass

+

−

! Rule

+

−

! Description

+

−

|-

+

−

| id-class

+

−

| Full override

+

−

| If an id-class setting exists, then the <tt>eclipselink-orm.xml</tt>'s id-class setting overrides the existing setting, or creates a new id-class setting.

+

−

|-

+

−

| exclude-default-listeners

+

−

| Full override

+

−

| If an exclude-default-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s exclude-default-listeners setting will be applied. If the exclude-default-listeners setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|-

+

−

| exclude-superclass-listeners

+

−

| Full override

+

−

| If an exclude-superclass-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s exclude-superclass-listeners setting will be applied. If exclude-superclass-listeners setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|-

+

−

| entity-listeners

+

−

| Merge and full override

+

−

| If an entity-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s entity-listeners setting will override and merge with an existing setting, or creates a new entity-listeners setting all together. <br>{{EclipseLink_Note|note=An entity listener override must be complete. All lifecycle methods of that listener must be specified and no merging of individual lifecycle methods of an entity listener is allowed. The class name of the listener is the key to identify the override.}}

+

−

|-

+

−

| pre-persist

+

−

| Full override

+

−

| If a <tt>pre-persist</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>pre-persist</tt> setting overrides the existing setting, or creates a new <tt>pre-persist</tt> setting.

+

−

|-

+

−

| post-persist

+

−

| Full override

+

−

| If a <tt>post-persist</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>post-persist</tt> setting overrides the existing setting, or creates a new <tt>post-persist</tt> setting.

+

−

|-

+

−

| pre-remove

+

−

| Full override

+

−

| If a pre-remove setting exists, then the <tt>eclipselink-orm.xml</tt>'s pre-remove setting overrides the existing setting, or creates a new pre-remove setting.

+

−

|-

+

−

| post-remove

+

−

| Full override

+

−

| If a <tt>post-remove</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>post-remove</tt> setting overrides the existing setting, or creates a new <tt>post-remove</tt> setting.

+

−

|-

+

−

| pre-update

+

−

| Full override

+

−

| If a pre-update setting exists, then the <tt>eclipselink-orm.xml</tt>'s pre-update setting overrides the existing setting, or creates a new pre-update setting.

+

−

|-

+

−

| post-update

+

−

| Full override

+

−

| If a post-update setting exists, then the <tt>eclipselink-orm.xml</tt>'s post-update setting overrides the existing setting, or creates a new post-update setting.

+

−

|-

+

−

| post-load

+

−

| Full override

+

−

| If a post-load setting exists, then the <tt>eclipselink-orm.xml</tt>'s post-load setting overrides the existing setting, or creates a new post-load setting.

| If an access setting exists, then the <tt>eclipselink-orm.xml</tt>'s access setting overrides the existing setting, or creates a new access setting. It also overrides the default class setting.

+

−

|-

+

−

| metadata-complete

+

−

| Full override

+

−

| If a metadata-complete setting exists, then the <tt>eclipselink-orm.xml</tt>'s metadata-complete setting will be applied. If metadata-complete setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|}

+

−

+

−

=== Entity override and merging rules ===

+

−

+

−

An entity can be defined completely, or with specific elements to provide extensions to an entity from another mapping file. The following table lists individual override and merging rules:

+

−

+

−

{|

+

−

|-

+

−

! entity-mappings/entity

+

−

! Rule

+

−

! Comments

+

−

|-

+

−

| table

+

−

| Full override

+

−

| The table definition overrides any other table setting (with the same name) for this entity. There is no merging of individual table values.

+

−

|-

+

−

| secondary-table

+

−

| Full override

+

−

| The secondary-table definition overrides another secondary-table setting (with the same name) for this entity. There is no merging of individual secondary-table(s) values.

+

−

|-

+

−

| primary-key-join-column

+

−

| Full override

+

−

| The primary-key-join-column(s) definition overrides any other primary-key-join-column(s) setting for this entity. There is no merging of the primary-key-join-column(s). The specification is assumed to be complete and these primary-key-join-columns are the source of truth.

+

−

|-

+

−

| id-class

+

−

| Full override

+

−

| If an id-class setting exists, then the <tt>eclipselink-orm.xml</tt>'s id-class setting overrides the existing setting, or creates a new id-class setting.

+

−

|-

+

−

| inheritance

+

−

| Full override

+

−

| If an inheritance setting exists, then the <tt>eclipselink-orm.xml</tt>'s inheritance setting overrides the existing setting, or creates a new inheritance setting.

+

−

|-

+

−

| discriminator-value

+

−

| Full override

+

−

| If a discriminator-value setting exists, then the <tt>eclipselink-orm.xml</tt>'s discriminator-value setting overrides the existing setting, or creates a new discriminator-value setting.

+

−

|-

+

−

| discriminator-column

+

−

| Full override

+

−

| If a discriminator-column setting exists, then the <tt>eclipselink-orm.xml</tt>'s discriminator-column setting overrides the existing setting, or creates a new discriminator-column setting.

+

−

|-

+

−

| sequence-generator

+

−

| Full override

+

−

| A sequence-generator is unique by name. The sequence-generator defined in <tt>eclipselink-orm.xml</tt> overrides sequence-generator of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more sequence-generators with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| table-generator

+

−

| Full override

+

−

| A table-generator is unique by name. The table-generator defined in <tt>eclipselink-orm.xml</tt> overrides table-generator of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more table-generators with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| named-query

+

−

| Merge and full override

+

−

| A named-query is unique by name. The named-query defined in <tt>eclipselink-orm.xml</tt> overrides named-query of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more named-query elements with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| named-native-query

+

−

| Merge and full override

+

−

| A named-native-query is unique by name. The named-native-query defined in <tt>eclipselink-orm.xml</tt> overrides named-native-query of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more named-native-query elements with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| sql-result-set-mapping

+

−

| Merge and full override

+

−

| A sql-result-set-mapping is unique by name. The sql-result-set-mapping defined in <tt>eclipselink-orm.xml</tt> overrides sql-result-set-mapping of the same name defined in other mapping files. Outside of the overriding case, an exception is thrown if two or more sql-result-set-mapping elements with the same name are defined in one or across multiple mapping files.

+

−

|-

+

−

| exclude-default-listeners

+

−

| Full override

+

−

| If an exclude-default-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s exclude-default-listeners setting will be applied. If an exclude-default-listeners setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|-

+

−

| exclude-superclass-listeners

+

−

| Full override

+

−

| If an exclude-superclass-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s exclude-superclass-listeners setting will be applied. If an exclude-superclass-listeners setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|-

+

−

| entity-listeners

+

−

| Full override

+

−

| If an entity-listeners setting exists, then the <tt>eclipselink-orm.xml</tt>'s entity-listeners setting will override and merge with an existing setting, or creates a new entity-listeners setting all together. <br> {{EclipseLink_Note|note=An entity listener override must be complete. All lifecycle methods of that listener must be specified and no merging of individual lifecycle methods of an entity listener is allowed. The class name of the listener is the key to identify the override.}}

+

−

|-

+

−

| pre-persist

+

−

| Full override

+

−

| If a <tt>pre-persist</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>pre-persist</tt> setting overrides the existing setting, or creates a new <tt>pre-persist</tt> setting.

+

−

|-

+

−

| post-persist

+

−

| Full override

+

−

| If a <tt>post-persist</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>post-persist</tt> setting overrides the existing setting, or creates a new <tt>post-persist</tt> setting.

+

−

|-

+

−

| pre-remove

+

−

| Full override

+

−

| If a pre-remove setting exists, then the <tt>eclipselink-orm.xml</tt>'s pre-remove setting overrides the existing setting, or creates a new pre-remove setting.

+

−

|-

+

−

| post-remove

+

−

| Full override

+

−

| If a <tt>post-remove</tt> setting exists, then the <tt>eclipselink-orm.xml</tt>'s <tt>post-remove</tt> setting overrides the existing setting, or creates a new <tt>post-remove</tt> setting.

+

−

|-

+

−

| pre-update

+

−

| Full override

+

−

| If a pre-update setting exists, then the <tt>eclipselink-orm.xml</tt>'s pre-update setting overrides the existing setting, or creates a new pre-update setting.

+

−

|-

+

−

| post-update

+

−

| Full override

+

−

| If a post-update setting exists, then the <tt>eclipselink-orm.xml</tt>'s post-update setting overrides the existing setting, or creates a new post-update setting.

+

−

|-

+

−

| post-load

+

−

| Full override

+

−

| If a post-load setting exists, then the <tt>eclipselink-orm.xml</tt>'s post-load setting overrides the existing setting, or creates a new post-load setting.

| If an association-override setting exists, then the <tt>eclipselink-orm.xml</tt>'s association-override setting overrides the existing setting, or creates a new association-override setting.

+

−

|-

+

−

| name

+

−

| Full override

+

−

| If a name setting exists, then the <tt>eclipselink-orm.xml</tt>'s name setting overrides the existing setting, or creates a new name setting.

+

−

|-

+

−

| class

+

−

| None

+

−

|

+

−

|-

+

−

| access

+

−

| Full override

+

−

| If an access setting exists, then the <tt>eclipselink-orm.xml</tt>'s access setting overrides the existing setting, or creates a new access setting. It also overrides the default class setting.

+

−

|-

+

−

| metadata-complete

+

−

| Full override

+

−

| If a metadata-complete setting exists, then the <tt>eclipselink-orm.xml</tt>'s metadata-complete setting will be applied. If a metadata-complete setting is not specified, it will not override an existing setting, that is essentially turning it off.

+

−

|}

+

−

+

−

=== Embeddable ===

+

−

+

−

An embeddable can be defined wholely or may be defined so as to provide extensions to an embeddeable from another mapping file. Therefore, we will allow the merging of that classes metadata. The individual override rules for that metadata is tabled below.

| If an access setting exists, then the <tt>eclipselink-orm.xml</tt>'s access setting overrides the existing setting, or creates a new access setting. It also overrides the default class setting.

+

−

|-

+

−

| metadata-complete

+

−

| Full override

+

−

| If a metadata-complete setting exists, then the <tt>eclipselink-orm.xml</tt>'s metadata-complete setting will be applied. If a metadata-complete setting is not specified, it will not override an existing setting, that is essentially turning it off.