This annotation specifies the settings of the generator that creates the primary key.
The following settings are required when using @TableGenerator:
The table generator is specified in the fields or properties of the entity class or primary key. The scope of the generator name is enabled in the persistence unit.
Use the rows of the generator table when generating the primary key value in an entity.
When creating a table for managing the sequence, specify a positive integer in the initial value. If 0 is specified in the initial value, the primary key will be generated from 1.
The applicable targets are class, method, and field.
The following table lists the elements of @TableGenerator:
Element name | Optional/Required | Element description |
---|---|---|
name | Required | This element specifies the generator name for the primary key value. |
table | Optional | This element specifies the name of the table that maintains the generated primary key values. |
catalog | Optional | This element specifies the catalog name of the table that maintains the generated primary key values. Note that Cosminexus JPA provider does not support this attribute. |
schema | Optional | This element specifies the schema name of the table that maintains the generated primary key values. |
pkColumnName | Optional | This element specifies the primary key column name of the table that maintains the generated primary key values. |
valueColumnName | Optional | This element specifies the column name that maintains the final generated value. |
pkColumnValue | Optional | This element specifies the primary key value of the table that maintains the generated primary key values. |
initialValue | Optional | This element specifies the value used for initializing the column that maintains the recent generated values. 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 generator. |
uniqueConstraints | Optional | This element specifies the unique key constraints in the table that maintains the generated primary key values. Note that Cosminexus JPA provider does not support this attribute. Ignore when the value is specified. |
The details of attributes that are supported with Cosminexus JPA provider are as follows: