本文主要介绍在使用jpa向数据库添加数据时,如果表中主键为自增ID,对应实体类的设定方法。
只需要在自增主键上添加@GeneratedValue注解就可以实现自增,如下图:
关键代码:
@GeneratedValue(strategy=GenerationType.IDENTITY)
有关注解的详细说明及用法,请参考:
https://blog.csdn.net/u012493207/article/details/50846616