13.3.8 Elements below entity
The following elements and attributes apply only to the entity class that is the target of the lower elements and attributes:
- Organization of this subsection
-
(1) <entity>
The entity element defines the entities of the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Optional |
The name attribute defines the name of the entity. The name attribute is overwritten regardless of whether the entity name defined by the name element of @Entity is explicitly specified or is the default value. The operation when the entity class name is overwritten might not execute normally. |
class |
xsd:string |
Required |
Entity class name. |
access |
orm:access-type |
Optional |
The access attribute defines the access type of the entity class. The access attribute overwrites the access type specified in the persistence-unit-defaults element (default element) and entity-mappings element (element valid for the entire persistence unit) provided to the entity class.#1 |
metadata-complete#2 |
xsd:boolean |
Optional |
If the metadata-complete attribute is specified in the entity element, the annotations specified in the entity class and in the fields and properties of the entity class are ignored. If metadata-complete is specified in the entity element and if the XML element is omitted, the default value is enabled. |
(2) <table>
The table element overwrites @Table (including default values) of the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Optional |
See the name attribute in 8.12.59 @Table. |
catalog |
xsd:string |
Optional |
See the catalog attribute in 8.12.59 @Table. |
schema |
xsd:string |
Optional |
See the schema attribute in 8.12.59 @Table. |
(3) <secondary-table>
The secondary-table element overwrites all @SecondaryTable and @SecondaryTables (including default values) of the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.54 @SecondaryTable. |
catalog |
xsd:string |
Optional |
See the catalog attribute in 8.12.54 @SecondaryTable. |
schema |
xsd:string |
Optional |
See the schema attribute in 8.12.54 @SecondaryTable. |
(4) <primary-key-join-column>
The primary-key-join-column element overwrites all @PrimaryKeyJoinColumn and @PrimaryKeyJoinColumns (including default values) of the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Optional |
See the name attribute in 8.12.51 @PrimaryKeyJoinColumn. |
referenced-column-name |
xsd:string |
Optional |
See the referencedColumnName attribute in 8.12.51 @PrimaryKeyJoinColumn. |
column-definition |
xsd:string |
Optional |
See the columnDefinition attribute in 8.12.51 @PrimaryKeyJoinColumn. |
(5) <id-class>
The id-class element overwrites @IdClass specified in the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
value |
xsd:string |
Required |
See the value attribute in 8.12.22 @IdClass. |
(6) <inheritance>
The inheritance element overwrites @Inheritance (including default values) of the entity class.
The inheritance element will be applied to the entity class and the sub class (if the sub class specified in the annotation and XML element is not overwritten using another method).
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
strategy |
orm:inheritance-type |
Optional |
See the strategy attribute in 8.12.23 @Inheritance. |
(7) <discriminator-value>
The discriminator-value element overwrites @DiscriminatorValue (including default values) of the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
(8) <discriminator-column>
The discriminator-column element overwrites @DiscriminatorColumn (including default values) of the entity class.
The discriminator-column element will be applied to the entity class and the sub class (if the sub class specified in the annotation and XML element is not overwritten using another method).
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Optional |
See the name attribute in 8.12.8 @DiscriminatorColumn. |
discriminator-type |
orm:discriminator-type |
Optional |
See the discriminatorType attribute in 8.12.8 @DiscriminatorColumn. |
column-definition |
xsd:string |
Optional |
See the columnDefinition attribute in 8.12.8 @DiscriminatorColumn. |
length |
xsd:int |
Optional |
See the length attribute in 8.12.8 @DiscriminatorColumn. |
(9) <sequence-generator>
The generator defined by the sequence-generator element is added to the generators defined using annotations and the other generators defined in the O/R mapping file. If a generator with the same name is defined in the annotation, the generator defined by the sequence-generator element overwrites this generator.
The generator defined by the sequence-generator element applies to the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.56 @SequenceGenerator. |
sequence-name |
xsd:string |
Optional |
See the sequenceName attribute in 8.12.56 @SequenceGenerator. |
initial-value |
xsd:int |
Optional |
See the initialValue attribute in 8.12.56 @SequenceGenerator. |
allocation-size |
xsd:int |
Optional |
See the allocationSize attribute in 8.12.56 @SequenceGenerator. |
(10) <table-generator>
The generator defined by the table-generator element is added to the generators defined using annotations and the other generators defined in the O/R mapping file. If a generator with the same name is defined in the annotation, the generator defined by the table-generator element overwrites this generator.
The generators defined by the table-generator element will be applied to the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.60 @TableGenerator. |
table |
xsd:string |
Optional |
See the table attribute in 8.12.60 @TableGenerator. |
catalog |
xsd:string |
Optional |
See the catalog attribute in 8.12.60 @TableGenerator. |
schema |
xsd:string |
Optional |
See the schema attribute in 8.12.60 @TableGenerator. |
pk-column-name |
xsd:string |
Optional |
See the pkColumnName attribute in 8.12.60 @TableGenerator. |
value-column-name |
xsd:string |
Optional |
See the valueColumnName attribute in 8.12.60 @TableGenerator. |
pk-column-value |
xsd:string |
Optional |
See the pkColumnValue attribute in 8.12.60 @TableGenerator. |
initial-value |
xsd:int |
Optional |
See the initialValue attribute in 8.12.60 @TableGenerator. |
allocation-size |
xsd:int |
Optional |
See the allocationSize attribute in 8.12.60 @TableGenerator. |
(11) <named-query>
The named query defined by the named-query element is added to the named query defined using annotations and the other named queries defined in the O/R mapping file. If a named query with the same name is defined in the annotation, the named query defined by the named-query element overwrites this named query.
The named query defined by the named-query element applies to the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.35 @NamedQuery. |
(12) <named-native-query>
The named native query defined by the named-native-query element is added to the named native query defined using annotations and the other named native queries defined in the O/R mapping file. If a named native query with the same name is defined in the annotation, the named native query defined by the named-native-query element overwrites this named native query.
The named native query defined by the named-native-query element applies to the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.33 @NamedNativeQuery. |
result-class |
xsd:string |
Optional |
See the resultClass attribute in 8.12.33 @NamedNativeQuery. |
result-set-mapping |
xsd:string |
Optional |
See the resultSetMapping attribute in 8.12.33 @NamedNativeQuery. |
(13) <sql-result-set-mapping>
The SQL result mapping defined by the sql-result-set-mapping element is added to the SQL result mapping defined using annotations and the other SQL result mapping defined in the O/R mapping file. If SQL result mapping with the same name is defined in the annotation, the SQL result mapping defined in the sql-result-set-mapping element overwrites this SQL result mapping.
The SQL result mapping defined by the sql-result-set-mapping element applies to the persistence unit.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.57 @SqlResultSetMapping. |
(14) <exclude-default-listeners>
The exclude-default-listeners element is applied regardless of whether @ExcludeDefaultListeners is specified in the entity class.
The exclude-default-listeners element controls the default entity listeners of the entity class and the sub class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
(15) <exclude-superclass-listeners>
The exclude-superclass-listeners element is applied regardless of whether @ExcludeSuperclassListeners is specified in the entity class.
The exclude-superclass-listeners element controls the superclass listeners of the entity class and the sub class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
(16) <entity-listeners>
The entity-listeners element overwrites @EntityListeners of the entity class.
If these listeners are not controlled using other methods, these listeners will be applied in the entity class and the sub class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
(17) <pre-persist>, <post-persist>, <pre-remove>, <post-remove>, <pre-update>, <post-update>, <post-load>
These elements overwrite the definition of the lifecycle callback method according to the corresponding annotations, in the entity class.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
method-name |
xsd:string |
Required |
Target method name. |
(18) <attribute-override>
The attribute-override element is added to the value defined in @AttributeOverride or @AttributeOverrides of the entity class. The attribute-override element overwrites the AttributeOverride element with the same attribute name.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.3 @AttributeOverride. |
(19) <association-override>
The association-override element is added to the value defined in @AssociationOverride or @AssociationOverrides of the entity class. The association-override element overwrites the AssociationOverride element with the same attribute name.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
See the name attribute in 8.12.1 @AssociationOverride. |
(20) <id>
The id element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Primary key property or field. |
(21) <embedded-id>
The embedded-id element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Compound primary key. |
(22) <basic>
The basic element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Methods or fields that map the type. |
fetch |
orm:fetch-type |
Optional |
See the fetch attribute in 8.12.5 @Basic. |
optional |
xsd:boolean |
Optional |
See the optional attribute in 8.12.5 @Basic. |
(23) <version>
The version element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Version property or field. |
(24) <many-to-one>
The many-to-one element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Methods or fields with a many-to-one relationship. |
target-entity |
xsd:string |
Optional |
See the targetEntity attribute in 8.12.29 @ManyToOne. |
fetch |
orm:fetch-type |
Optional |
See the fetch attribute in 8.12.29 @ManyToOne. |
optional |
xsd:boolean |
Optional |
See the optional attribute in 8.12.29 @ManyToOne. |
(25) <one-to-many>
The one-to-many element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Methods or fields with a one-to-many relationship. |
target-entity |
xsd:string |
Optional |
See the targetEntity attribute in 8.12.36 @OneToMany. |
fetch |
orm:fetch-type |
Optional |
See the fetch attribute in 8.12.36 @OneToMany. |
mapped-by |
xsd:string |
Optional |
See the mappedBy attribute in 8.12.36 @OneToMany. |
(26) <one-to-one>
The one-to-one element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Methods or fields with a one-to-one relationship. |
target-entity |
xsd:string |
Optional |
See the targetEntity attribute in 8.12.37 @OneToOne. |
fetch |
orm:fetch-type |
Optional |
See the fetch attribute in 8.12.37 @OneToOne. |
optional |
xsd:boolean |
Optional |
See the optional attribute in 8.12.37 @OneToOne. |
mapped-by |
xsd:string |
Optional |
See the mappedBy attribute in 8.12.37 @OneToOne. |
(27) <many-to-many>
The many-to-many element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Methods or fields with a many-to-many relationship. |
target-entity |
xsd:string |
Optional |
See the targetEntity attribute in 8.12.28 @ManyToMany. |
fetch |
orm:fetch-type |
Optional |
See the fetch attribute in 8.12.28 @ManyToMany. |
mapped-by |
xsd:string |
Optional |
See the mappedBy attribute in 8.12.28 @ManyToMany. |
(28) <embedded>
The embedded element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Property or field that is an embedded object. |
(29) <transient>
The transient element overwrites the mapping specified in fields and properties.
For details on the functionality and attributes, see 8.12 javax.persistence package.
The following table lists the specifiable attributes:
Attribute name |
Type |
Optional/Required |
Description |
---|---|---|---|
name |
xsd:string |
Required |
Property or field that is non-persistent. |