6.3 O/R mapping files

The following table describes the configuration of the O/R mapping files:

Tag nameOccurrence patternDescription
<entity-mappings>OnceIndicates the root tag.

<description>0 or onceAdds the description.

<persistence-unit-metadata>0 or onceSpecifies the definition related to the entire PersistenceUnit.

<xml-mapping-metadata-complete>0 or onceSpecifies whether to control the mapping metadata of the persistence unit.

<persistence-unit-defaults>0 or onceSpecifies the default value of the persistence unit.

<schema>0 or onceDefines the schema.

<catalog>0 or onceDefines the catalog.

<access>0 or onceSpecifies the access type.

<cascade-persist>0 or onceAdds the cascade persistence option.

<entity-listeners>0 or onceDefines the default entity listener of the persistence unit.

<entity-listener>0 or more timesSpecifies the entity listener.

<pre-persist>0 or onceSpecifies the lifecycle callback method.

<post-persist>0 or onceSpecifies the lifecycle callback method.

<pre-remove>0 or onceSpecifies the lifecycle callback method.

<post-remove>0 or onceSpecifies the lifecycle callback method.

<pre-update>0 or onceSpecifies the lifecycle callback method.

<post-update>0 or onceSpecifies the lifecycle callback method.

<post-load>0 or onceSpecifies the lifecycle callback method.

<package>0 or onceSpecifies the class package described in the elements and attributes within the same mapping file.

<schema>0 or onceDefines the schema.

<catalog>0 or onceDefines the catalog.

<access>0 or onceDefines the access method.

<sequence-generator>0 or more timesAdds the sequence generator.

<table-generator>0 or more timesDefines the table generator.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<named-query>0 or more timesDefines a named query.

<query>OnceSpecifies the query string.

<hint>0 or more timesAdds a hint to the query.

<named-native-query>0 or more timesDefines the named native query.

<query>OnceSpecifies the query string.

<hint>0 or more timesAdds a hint to the query.

<sql-result-set-mapping>0 or more timesDefines the SQL result set mapping.

<entity-result>0 or more timesSpecifies the entity class used for mapping the native SQL query result.

<field-result>0 or more timesSpecifies the field used for mapping the native SQL query result.

<column-result>0 or more timesSpecifies the column used for mapping the native SQL query result.

<mapped-superclass>0 or more timesDefines the mapped superclass of the persistence unit.

<description>0 or onceAdds the description for the mapped superclass of the persistence unit.

<id-class>0 or onceOverwrites @IdClass specified in the mapped superclass.

<exclude-default-listeners>0 or onceDefines whether to control the default entity listener of the mapped superclass and the sub class.

<exclude-superclass-listeners>0 or onceDefines whether to control the superclass listener of the mapped superclass and the sub class.

<entity-listeners>0 or onceSpecifies the callback listener class.

<entity-listener>0 or more timesSpecifies the entity listener.

<pre-persist>0 or onceSpecifies the lifecycle callback method.

<post-persist>0 or once

<pre-remove>0 or once

<post-remove>0 or once

<pre-update>0 or once

<post-update>0 or once

<post-load>0 or once

<pre-persist>0 or onceDefines the lifecycle callback method using the corresponding annotations in the mapped superclass.

<post-persist>0 or once

<pre-remove>0 or once

<post-remove>0 or once

<pre-update>0 or once

<post-update>0 or once

<post-load>0 or once

<attributes>0 or onceThe element is not defined.

<id>0 or more times#1Overwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<generated-value>0 or onceSpecifies the strategy for generating the primary key value.

<temporal>0 or onceSpecified when mapping to the DATE, TIME, and TIMESTAMP type.

<table-generator>0 or onceAdds the table generator.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<sequence-generator>0 or onceAdds the sequence generator.

<embedded-id>0 or once#1Overwrites the mapping specified in fields and properties.

<attribute-override>0 or more timesOverwrites the mapping of properties and fields.

<column>OnceSpecifies the column mapping for the properties of the Persistent field.

<basic>0 or more timesOverwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<lob>0 or once#2Specified when mapping to the Lob type.

<temporal>0 or once#2Specified when mapping to the DATE, TIME, and TIMESTAMP type.

<enumerated>0 or once#2Specified when mapping to the enumeration type.

<version>0 or more timesOverwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<temporal>0 or onceSpecified when mapping to the DATE, TIME, and TIMESTAMP type.

<many-to-one>0 or more timesOverwrites the mapping specified in fields and properties.

<join-column>0 or more times#3Specifies the external key column of the join table corresponding to the owner-side entity.

<join-table>0 or once#3Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<one-to-many>0 or more timesOverwrites the mapping specified in fields and properties.

<order-by>0 or onceSpecifies the order to be applied when maintaining a relation in the collection.

<map-key>0 or onceSpecifies the map key as the Map type relation.

<join-table>0 or once#4Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<join-column>0 or more times#4Specifies the external key column of the join table corresponding to the owner-side entity.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<one-to-one>0 or more timesOverwrites the mapping specified in fields and properties.

<primary-key-join-column>0 or more times#5Specifies the primary key column used as external key to JOIN with other tables.

<join-column>0 or more times#5Specifies the external key column of the join table corresponding to the owner-side entity.

<join-table>0 or once#5Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<many-to-many>0 or more timesOverwrites the mapping specified in fields and properties.

<order-by>0 or onceSpecifies the order to be applied when maintaining a relation in the collection.

<map-key>0 or onceSpecifies the map key as the Map type relation.

<join-table>0 or onceSpecifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<embedded>0 or more timesOverwrites the mapping specified in fields and properties.

<attribute-override>0 or more timesOverwrites the mapping of properties and fields.

<column>OnceSpecifies the column mapping for the properties of the Persistent field.

<transient>0 or more timesOverwrites the mapping specified in fields and properties.

<entity>0 or more timesDefines the entities of the persistence unit.

<description>0 or onceAdds the description for the entities of the persistence unit.

<table>0 or onceOverwrites @Table (including default values) of the entity class.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<secondary-table>0 or more timesOverwrites all @SecondaryTable and @SecondaryTables (including default values) of the entity class.

<primary-key-join-column>0 or more timesOverwrites all @PrimaryKeyJoinColumn and @PrimaryKeyJoinColumns (including default values) of the entity class.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<primary-key-join-column>0 or more timesOverwrites all @PrimaryKeyJoinColumn and @PrimaryKeyJoinColumns (including default values) of the entity class.

<id-class>0 or onceOverwrites @IdClass specified in the entity class.

<inheritance>0 or onceOverwrites @Inheritance (including default values) of the entity class.

<discriminator-value>0 or onceOverwrites @DiscriminatorValue (including default values) of the entity class.

<discriminator-column>0 or onceOverwrites @DiscriminatorColumn (including default values) of the entity class.

<sequence-generator>0 or onceSpecifies the settings for the sequence generator that creates the primary key.

<table-generator>0 or onceSpecifies the settings for the generator that creates the primary key.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<named-query>0 or more timesDefines a named query.

<query>OnceSpecifies the query string.

<hint>0 or more timesAdds a hint to the query.

<named-native-query>0 or more timesDefines the named native query.

<query>OnceSpecifies the query string.

<hint>0 or more timesAdds a hint to the query.

<sql-result-set-mapping>0 or more timesDefines the mapping of the SQL results.

<entity-result>0 or more timesSpecifies the entity class used for mapping the native SQL query result.

<field-result>0 or more timesSpecifies the field used for mapping the native SQL query result.

<column-result>0 or more timesSpecifies the column used for mapping the native SQL query result.

<exclude-default-listeners>0 or onceControls the default entity listeners of the entity class and the sub class.

<exclude-superclass-listeners>0 or onceControls the superclass listeners of the entity class and the sub class.

<entity-listeners>0 or onceOverwrites @EntityListeners of the entity class.

<entity-listener>0 or more timesSpecifies the entity listener.

<pre-persist>0 or onceOverwrites the definition of the lifecycle callback method according to the corresponding annotations, in the mapped superclass.

<post-persist>0 or once

<pre-remove>0 or once

<post-remove>0 or once

<pre-update>0 or once

<post-update>0 or once

<post-load>0 or once

<pre-persist>0 or onceOverwrites the definition of the lifecycle callback method according to the corresponding annotations, in the entity class.

<post-persist>0 or once

<pre-remove>0 or once

<post-remove>0 or once

<pre-update>0 or once

<post-update>0 or once

<post-load>0 or once

<attribute-override>0 or more timesAdded to the value defined in @AttributeOverride or @AttributeOverrides of the entity class.

<column>OnceSpecifies the column mapping for the properties of the Persistent field.

<association-override>0 or more timesAdded to the value defined in @AssociationOverride or @AssociationOverrides of the entity class.

<join-column>One or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<attributes>0 or onceThe element is not defined.

<id>0 or more times#1Overwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<generated-value>0 or onceSpecifies the strategy for generating the primary key value.

<temporal>0 or onceSpecified when mapping to the DATE, TIME, and TIMESTAMP type.

<table-generator>0 or onceAdds the table generator.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<sequence-generator>0 or onceSpecifies the settings for the sequence generator that creates the primary key.

<embedded-id>0 or once#1Overwrites the mapping specified in fields and properties.

<attribute-override>0 or more timesAdded to the value defined in @AttributeOverride or @AttributeOverrides of the entity class.

<column>OnceSpecifies the column mapping for the properties of the Persistent field.

<basic>0 or more timesOverwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<lob>0 or once#2Specified when mapping to the Lob type.

<temporal>0 or onceSpecified when mapping to the DATE, TIME, and TIMESTAMP type.

<enumerated>0 or once#2Specified when mapping to the enumeration type.

<version>0 or more timesOverwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<temporal>0 or onceSpecified when mapping to the DATE, TIME, and TIMESTAMP type.

<many-to-one>0 or more timesOverwrites the mapping specified in fields and properties.

<join-column>0 or more times#4Specifies the external key column of the join table corresponding to the owner-side entity.

<join-table>0 or once#4Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<one-to-many>0 or more timesOverwrites the mapping specified in fields and properties.

<order-by>0 or onceSpecifies the order to be applied when maintaining a relation in the collection.

<map-key>0 or onceSpecifies the map key as the Map type relation.

<join-table>0 or once#3Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<join-column>0 or more times#3Specifies the external key column of the join table corresponding to the owner-side entity.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<one-to-one>0 or more timesOverwrites the mapping specified in fields and properties.

<primary-key-join-column>0 or more times#5Overwrites all @PrimaryKeyJoinColumn and @PrimaryKeyJoinColumns (including default values) of the entity class.

<join-column>0 or more times#5Specifies the external key column of the join table corresponding to the owner-side entity.

<join-table>0 or once#5Specifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<many-to-many>0 or more timesOverwrites the mapping specified in fields and properties.

<order-by>0 or onceSpecifies the order to be applied when maintaining a relation in the collection.

<map-key>0 or onceSpecifies the map key as the Map type relation.

<join-table>0 or onceSpecifies the join table to be used in many-to-many and the unilateral one-to-many relationships.

<join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owner-side entity.

<inverse-join-column>0 or more timesSpecifies the external key column of the join table corresponding to the owned-side entity.

<unique-constraint>0 or more timesAdds a unique constraint to DDL.

<column-name>One or more timesSpecifies the name of the column in which the unique constraint will be added.

<cascade>0 or onceSpecifies the operations that you can cascade.

<cascade-all>0 or onceCascades all the operations.

<cascade-persist>0 or onceCascades the persist operation.

<cascade-merge>0 or onceCascades the merge operation.

<cascade-remove>0 or onceCascades the remove operation.

<cascade-refresh>0 or onceCascades the refresh operation.

<embedded>0 or more timesOverwrites the mapping specified in fields and properties.

<attribute-override>0 or more timesAdded to the value defined in @AttributeOverride or @AttributeOverrides of the entity class.

<column>OnceSpecifies the column mapping for the properties of the Persistent field.

<transient>0 or more timesOverwrites the mapping specified in fields and properties.

<embeddable>0 or more timesDefines the embeddable class of the persistence unit.

<description>0 or onceAdds the description for the embeddable class of the persistence unit.

<attributes>0 or onceThe element is not defined.

<basic>0 or more timesOverwrites the mapping specified in fields and properties.

<column>0 or onceSpecifies the column mapping for the properties of the Persistent field.

<lob>0 or once#2Specified when mapping to the Lob type.

<temporal>0 or once#2Specified when mapping to the DATE, TIME, and TIMESTAMP type.

<enumerated>0 or once#2Specified when mapping to the enumeration type.

<transient>0 or more timesOverwrites the mapping specified in fields and properties.
#1
Specify any one among the <id> tag and the <embedded-id> tag.
#2
Specify any one among the <lob> tag, the <temporal> tag, and the <enumerated> tag.
#3
Specify any one among the <join-column> tag and the <join-table> tag.
#4
Specify any one among the <join-table> tag and the <join-column> tag.
#5
Specify any one among the <primary-key-join-column> tag, the <join-column> tag, and the <join-table> tag.

Organization of this section
6.3.1 Elements below entity-mappings
6.3.2 Elements below persistence-unit-metadata
6.3.3 Elements below table-generator
6.3.4 Elements below named-query
6.3.5 Elements below named-native-query
6.3.6 Elements below sql-result-set-mapping
6.3.7 Elements below mapped-superclass
6.3.8 Elements below entity
6.3.9 Elements under embeddable
6.3.10 Other elements