简体   繁体   English

如何在jpa中实现自动增量

[英]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? 我是关于学习JPA,我想知道如何使用数据库自​​动增量向表实体管理器调用主键字段生成? I am using Mysql 5.5 and Oracle Enterprise For Eclipse(OEFE) thanks for help 我正在使用Mysql 5.5和Oracle Enterprise For Eclipse(OEFE)感谢您的帮助

If you have aa id which needs to be auto incremented then , 如果你有一个需要自动递增的id,那么,

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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