CodesJava

Easy learning with example program codes

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   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki