Hitachi

uCosminexus Application Server Compatibility Guide


8.12.20 @GeneratedValue

Organization of this subsection

(1) Description

This annotation specifies the method for automatically generating and allotting a unique value to the primary key column. This annotation is applicable to the field or property of the primary key of entity class or mapped superclass containing @Id.

The primary key value is generated by the following four methods. Depending on the generation method selected, the base table and database sequence object must be prepared beforehand. For details on each of the generation methods, see the description about the strategy element.

The applicable targets are method and field.

(2) Element

The following table lists the elements of @GeneratedValue:

Element name

Optional/Required

Element description

strategy

Optional

This element specifies the method for generating the primary key value of the entity class.

generator

Optional

This element specifies the name element set up in @SequenceGenerator or @TableGenerator to be used.

The details of attributes that are supported with Cosminexus JPA provider are as follows:

(a) strategy element

Type

GenerationType

Description

This element specifies the method for generating the primary key value of the entity class.

The following four types of values can be specified:

  • GenerationType.AUTO

    For generating the primary key value, select the most appropriate procedure in each database.

    When Oracle or HiRDB is used as the database, the processing is same as GenerationType.TABLE.

  • GenerationType.IDENTITY

    The primary key value is generated using the identity column of the database.

    If Oracle is used as the database, the processing is same as GenerationType.SEQUENCE.

    If HiRDB is used as the database, the processing is same as GenerationType.TABLE.

  • GenerationType.SEQUENCE

    The primary key value is generated using the database sequence object.

    If HiRDB is used as the database, the processing is same as GenerationType.TABLE.

  • GenerationType.TABLE

    The primary key value is generated using a table for maintaining the primary key value.

Default value

GenerationType.AUTO

(b) generator element

Type

String

Description

This element specifies the name element set up in @SequenceGenerator or @TableGenerator to be used.

Default value

The following names are assumed depending on the value of the strategy element:

  • In the case of GenerationType.AUTO

    "SEQ_GEN"

  • In the case of GenerationType.SEQUENCE

    "SEQ_GEN_SEQUENCE"

  • In the case of GenerationType.TABLE

    "SEQ_GEN_TABLE"