Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to implement auto increment in jpa

I am about learning JPA, and I want to know how can we tel the entity manager that the primary key field is generated using the database auto increment to the table? I am using Mysql 5.5 and Oracle Enterprise For Eclipse(OEFE) thanks for help

like image 582
Rachid Avatar asked Dec 02 '22 21:12

Rachid


1 Answers

If you have a a id which needs to be auto incremented then ,

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
like image 175
vikiiii Avatar answered Dec 04 '22 09:12

vikiiii