Tutorialspoint examples

Learn java tutorial with examples for beginners online

JPA TableGenerator annotation


The TableGenerator defines a primary key generator that may be referenced by name when a generator element is specified for the GeneratedValue annotation. A table 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).The TableGenerator annotation uses a standard database table for primary key values.

Example:

@Id
@GeneratedValue(strategy=GenerationType.TABLE , generator="employee_generator")
@TableGenerator(name="student_generator",
               table="pk_table",
               pkColumnName="columnName",
               valueColumnName="value",
               allocationSize=100)
private Integer studentId;

Attribute:

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.

Posted in JPA   
Download tutorialspointexamples Android App
Copyright © 2018 Tutorialspoint examples DMCA.com Protection Status