Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hibernate @GeneratedValue correct?

I set my entity property

@GeneratedValue
Long id;

and I able to generate id for the entity in database. My question is why all the entities are sharing the same incremental number? aren't each table should start counting from zero?

like image 457
cometta Avatar asked Jan 22 '23 22:01

cometta


1 Answers

It depends on the underlying database. GenerationType is AUTO by default, and Hibernate chooses one of the three variants depending on the database. If you want to use one in particular, set it as attribute of @GeneratedValue

like image 81
Bozho Avatar answered Jan 25 '23 13:01

Bozho