Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Hibernate Automatic value generation strategies?

What is the difference between these two Automatic value generation strategies?

 1. @GeneratedValue
 2. @GeneratedValue(strategy=IDENTITY)
like image 592
Nandkumar Tekale Avatar asked Nov 26 '25 11:11

Nandkumar Tekale


1 Answers

This is like following:

AUTO Indicates that the persistence provider should pick an appropriate strategy for the particular database.

IDENTITY Indicates that the persistence provider must assign primary keys for the entity using database identity column.

SEQUENCE Indicates that the persistence provider must assign primary keys for the entity using database sequence column.

TABLE Indicates that the persistence provider must assign primary keys for the entity using an underlying database table to ensure uniqueness.

Refer to the API here http://docs.oracle.com/javaee/5/api/javax/persistence/GenerationType.html

like image 120
Hemant Metalia Avatar answered Nov 28 '25 02:11

Hemant Metalia