Hitachi

uCosminexus Application Server Compatibility Guide


8.12.56 @SequenceGenerator

Organization of this subsection

(1) Description

This annotation specifies the settings of the sequence generator that creates the primary key. The following settings are required when using @SequenceGenerator:

The sequence generator is specified in the fields or properties of the entity class or primary key. The scope of the sequence generator name is enabled in the persistence unit.

When creating a sequence object, specify a positive integer in the increment interval (INCREMENT BY) between sequential numbers, and in the initial value (START WITH) of the generated sequential number. When 1 is specified in the initial value (START WITH), the primary key is generated from 1. The operation will not be guaranteed if a negative value is specified.

The applicable targets are class, method, and field.

(2) Element

The following table lists the elements of @SequenceGenerator:

Element name

Optional/Required

Element description

name

Required

This element specifies the name specified in the generator element of the @GeneratedValue annotation.

sequenceName

Optional

This element specifies the name of the database sequence object for acquiring an existing primary key value, or an already defined primary key value.

initialValue

Optional

This element specifies the initial value when the generation of the primary key value by the sequence object is started.

Note that Cosminexus JPA provider does not support this attribute. Ignore when the value is specified.

allocationSize

Optional

This element specifies the size of allocating the primary key value from the sequence.

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

(a) name element

Type

String

Description

This element specifies the name specified in the generator element of the @GeneratedValue annotation.

The value that can be specified is a character string.

Default value

None

(b) sequenceName element

Type

String

Description

This element specifies the name of the database sequence object for acquiring an existing primary key value, or an already defined primary key value.

The sequence object name that can be specified depends on the database specifications.

Default value

Specified value of the generator element of @GeneratedValue

(c) allocationSize element

Type

int

Description

This element specifies the allocation size of the primary key value from the sequence. The sequence object name that can be specified depends on the database specifications.

The size that can be specified is a numeric value that is at least one more than the int type. Specify a value same as the increment interval of the sequence object. The operation will not be guaranteed if you specify a different value.

Note that in this element, you can specify the maximum value used during execution. If you specify a large value for acquiring the management area of the sequence number, the java.lang.OutOfMemoryError exception will occur during the execution.

Default value

50