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.
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: