简体   繁体   中英

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

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

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM