JPA SequenceGenerator annotation

The SequenceGenerator annotation defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A sequence generator may be specified on the entity class or on the primary key field or property. The scope of the generator name is global to the persistence unit (across all generator types).


private Integer studentId;

In first line we declared a SequenceGenerator with SeqTest name. It points to TEST_SEQ which is a database object. The SequenceGenerator name “SeqTest” will be used by @GeneratedValue annotation.


Name: A unique generator name that can be referenced by one or more classes to be the generator for primary key values. It is a required attribute.

Please follow and like us:
Content Protection by