uCosminexus Application Server, API Reference Guide

[Contents][Index][Back][Next]

2.7 javax.persistence package

This section describes the list of annotations included in the javax.persistence package and the precautions to be taken when specifying annotations.

You can also specify the mapping information in an O/R mapping file instead of the annotations. For details on the correspondence between the annotations and the O/R mapping files, see 2.7.64 Correspondence between the annotations and O/R mapping.

Precautions when specifying an annotation
  • With the Cosminexus JPA, the annotations included in the javax.persistence package are not supported in the attributes related to the DDL output functionality.
  • When specifying the same column name more than once in an annotation, arrange the upper case and lower case characters.
  • If field names or method names are allocated in the column name, character strings are considered as upper case characters strings and used with Cosminexus JPA. If you want to specify a column name in the supported annotation, use upper case characters.
  • The access type is decided according to the location at which the annotation is provided. However, if the access type exists in both, the field and property, the settings of the field will be enabled.
  • The property name is decided as follows depending on the character string acquired by removing get or set (is) from the access method:
    - If the first two characters are in upper case, the string is used as it is.
    - If the first two characters are not in upper case, the first character is converted into lower case, and the string is used.
    - For a single character, the first character is converted into lower case, and the string is used.

List of annotations
Annotation classification Annotation name Overview
Entity annotation @Entity Indicates that the class is an entity.
Annotations related to the tables or columns @Column Specifies the mapping between the persistence field or the persistence property, and the columns of the database.
@JoinColumn Specifies the external key column for the binding table or a column of the binding--destination table that is referenced from the external key column by correlating the entity classes.
@JoinColumns Used when multiple @JoinColumns are coded concurrently.
@JoinTable This annotation specifies the binding table set up in the following classes:
  • Owner side class when ManyToMany relationship is specified.
  • Class with single-sided OneToMany relationship.
@PrimaryKeyJoinColumn Specifies the column used as the external key, when binding with other tables.
@PrimaryKeyJoinColumns Used when multiple @PrimaryKeyJoinColumns are coded concurrently.
@SecondaryTable Specifies a secondary table in the entity class.
@SecondaryTables Used when multiple @SecondaryTables are coded concurrently.
@Table Specifies a primary table in the entity class.
@UniqueConstraint If you want to generate CREATE sentences for the primary table or secondary table, include the unique constraints, and then specify.
Note that this annotation is not supported with Cosminexus JPA provider CJPA provider.
Annotations related to the ID @EmbeddedId Specifies the compound primary key of a class that can be embedded.
@GeneratedValue Specifies the method for automatically generating and allotting a unique value to the primary key column.
@Id Specifies the properties or fields of the primary key of the entity class.
@IdClass Specifies the compound primary key class mapped to multiple fields or properties of the entity class.
@SequenceGenerator Specifies the settings of the sequence generator that creates the primary key.
@TableGenerator Specifies the settings of the generator that creates the primary key.
Lock annotation @Version Specifies the version field or the version property for using the optimistic lock functionality.
Annotations related to mapping @Basic Indicates the type of mapping to the simplest database column.
@Embeddable Specifies an embedded class.
@Embedded Specifies the persistence property or the persistence field indicating the instance value of the embedded class within the entity class at the embedding destination.
@Enumerated Specifies the persistence field or the persistence property as the enumeration type.
@Lob Specifies the persistence field or the persistence property of the large object type supported by the database.
@MapKey Specifies the map key used for object identification within the map, when a non--owner entity class is indicated by the java.util.Map type in the OneToMany relationship or the ManyToMany relationship.
@OrderBy Specifies the order in which the collection is evaluated when the entity information is acquired.
@Temporal Specifies in the persistence property or persistence field having the type that expresses the time (java.util.Date and java.util.Calendar).
@Transient Specifies the field or property of a non--persisting entity class, mapped superclass, or embedded class.
Annotations related to the relationship @ManyToMany Indicates that the specified class has a ManyToMany relationship, and also specifies the multiple relationships from the owner entity class to the non--owner entity class.
@ManyToOne Indicates that the specified class has the ManyToOne relationship, and also specifies the relationship to the non--owner entity class.
@OneToMany Indicates that the specified class has the OneToMany relationship, and also specifies the multiple relationships from the owner entity class to the non--owner entity class.
@OneToOne Indicates that the specified class has the OneToOne relationship, and also specifies the single relationship between entity classes.
Annotations related to inheritance and overriding @AssociationOverride Overrides the settings used in the ManyToOne relationship or the OneToOne relationship specified in a mapped superclass and embedded class.
@AssociationOverrides Used when multiple @AssociationOverrides are coded concurrently.
@AttributeOverride Overrides the following mapping information:
  • Properties or fields specified by @Basic (or applied by default)
  • Properties or fields specified by @Id
@AttributeOverrides Used when multiple @ElementOverrides are coded concurrently.
@DiscriminatorColumn Specifies the column used for identification in the SINGLE_TABLE strategy or JOINED strategy.
This annotation is added to an entity class that becomes a superclass by inheriting an entity class.
@DiscriminatorValue Specifies the value of the column used for identification in the SINGLE_TABLE strategy or JOINED strategy.
@Inheritance Specifies the inheritance mapping strategy used in the entity class hierarchy.
@MappedSuperclass Specifies a mapped superclass.
Annotations related to queries @ColumnResult Specifies the column for mapping the query results of an SQL to the entity class.
@EntityResult Specifies the entity class in which the query results of the SQL are to be mapped.
@FieldResult Specifies the field in which the query results of the SQL are to be mapped.
@NamedNativeQueries Used when multiple @NamedNativeQueries are coded concurrently.
@NamedNativeQuery Specifies a named query in the SQL.
@NamedQueries Used when multiple @NamedQueries are coded concurrently.
@NamedQuery Specifies a named query of JPQL.
@QueryHint Specifies a database--specific query hint.
@SqlResultSetMapping Specifies the result set mapping of an SQL query.
@SqlResultSetMappings Used when multiple @SqlResultSetMappings are coded concurrently.
Annotations related to event callback# @EntityListeners Specifies the callback listener class used in the entity class or mapped superclass.
@ExcludeDefaultListeners This annotation excludes the default listener for the following classes:
  • Entity class
  • Mapped superclass
  • Subclass of the entity class or mapped superclass
@ExcludeSuperclassListeners This annotation excludes the superclass listener for the following classes:
  • Entity class
  • Mapped superclass
  • Subclass of the entity class or mapped superclass
@PostLoad This annotation indicates the callback method invoked after the SELECT statement is issued in the database.
@PostPersist This annotation indicates the callback method invoked after the INSERT statement is issued in the database.
@PostRemove This annotation indicates the callback method invoked after the DELETE statement is issued in the database.
@PostUpdate This annotation indicates the callback method invoked after the UPDATE statement is issued in the database.
@PrePersist This annotation indicates the callback method invoked before the INSERT statement is issued in the database.
@PreRemove This annotation indicates the callback method invoked before the DELETE statement is issued in the database.
@PreUpdate This annotation indicates the callback method invoked before the UPDATE statement is issued in the database.
Annotations related to the reference of EntityManager and EntityManagerFactory @PersistenceContext Defines the container--managed EntityManager.
@PersistenceContexts Used when multiple @PersistenceContexts are coded concurrently.
@PersistenceProperty Sets up properties in the container--managed EntityManager.
@PersistenceUnit Defines the persistence unit for the EntityManagerFactory.
@PersistenceUnits Used when multiple @PersistenceUnits are coded concurrently.

# For details on the callback method, see 6.15 How to specify the callback method in the uCosminexus Application Server Common Container Functionality Guide.


Organization of this section
2.7.1 @AssociationOverride
2.7.2 @AssociationOverrides
2.7.3 @AttributeOverride
2.7.4 @AttributeOverrides
2.7.5 @Basic
2.7.6 @Column
2.7.7 @ColumnResult
2.7.8 @DiscriminatorColumn
2.7.9 @DiscriminatorValue
2.7.10 @Embeddable
2.7.11 @Embedded
2.7.12 @EmbeddedId
2.7.13 @Entity
2.7.14 @EntityListeners
2.7.15 @EntityResult
2.7.16 @Enumerated
2.7.17 @ExcludeDefaultListeners
2.7.18 @ExcludeSuperclassListeners
2.7.19 @FieldResult
2.7.20 @GeneratedValue
2.7.21 @Id
2.7.22 @IdClass
2.7.23 @Inheritance
2.7.24 @JoinColumn
2.7.25 @JoinColumns
2.7.26 @JoinTable
2.7.27 @Lob
2.7.28 @ManyToMany
2.7.29 @ManyToOne
2.7.30 @MapKey
2.7.31 @MappedSuperclass
2.7.32 @NamedNativeQueries
2.7.33 @NamedNativeQuery
2.7.34 @NamedQueries
2.7.35 @NamedQuery
2.7.36 @OneToMany
2.7.37 @OneToOne
2.7.38 @OrderBy
2.7.39 @PersistenceContext
2.7.40 @PersistenceContexts
2.7.41 @PersistenceProperty
2.7.42 @PersistenceUnit
2.7.43 @PersistenceUnits
2.7.44 @PostLoad
2.7.45 @PostPersist
2.7.46 @PostRemove
2.7.47 @PostUpdate
2.7.48 @PrePersist
2.7.49 @PreRemove
2.7.50 @PreUpdate
2.7.51 @PrimaryKeyJoinColumn
2.7.52 @PrimaryKeyJoinColumns
2.7.53 @QueryHint
2.7.54 @SecondaryTable
2.7.55 @SecondaryTables
2.7.56 @SequenceGenerator
2.7.57 @SqlResultSetMapping
2.7.58 @SqlResultSetMappings
2.7.59 @Table
2.7.60 @TableGenerator
2.7.61 @Temporal
2.7.62 @Transient
2.7.63 @Version
2.7.64 Correspondence between the annotations and O/R mapping