gpt4 book ai didi

mysql - 如何给 Jpa @GeneratedValue(strategy = GenerationType.AUTO) 一个起始值而不是 0

转载 作者:行者123 更新时间:2023-11-28 23:26:14 26 4
gpt4 key购买 nike

I have an entity that is supposed to get an id from the database automatically. I use MySQL so I would expect annotating that @GeneratedValue(strategy=GenerationType.AUTO) When i run the project i will import hardcoded master data needed for my application, but when i add a new data to same table using jpa it starts with id 0 thus saying id already exist. I have to make jpa start auto increment from the last id i have added . Is this possible

最佳答案

在此使用 GenerationType.TABLE 方法,以便根据数据库中已有的值提供数据。

关于mysql - 如何给 Jpa @GeneratedValue(strategy = GenerationType.AUTO) 一个起始值而不是 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39220921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com