spring data jpa 循环插入数据库报错 A different object with the same identifier value was already associated w

朱雀 2023-01-09 12:58 180阅读 0赞

A different object with the same identifier value was already associated with the session

  1. @Id
  2. @Column(name = "id")
  3. @GeneratedValue(strategy = GenerationType.IDENTITY)
  4. private int id;

在主码上加上
IDENTITY:主键由数据库自动生成(主要是自动增长型)

发表评论

表情:
评论列表 (有 0 条评论,180人围观)

还没有评论,来说两句吧...

相关阅读