我使用DB2为我的应用程序创建数据库后,运行一些插入脚本插入脚本表生成记录在插入脚本给定id的休眠:@GeneratedValue(策略= GenerationType
假设为ABC表。插入脚本创建具有ID的记录= 3的ID设置为休眠自动生成所以虽然从应用程序中保存的第三个记录我的异常。
Caused by: com.ibm.websphere.ce.cm.DuplicateKeyException: One or
more values in the INSERT statement, UPDATE statement, or foreign
key update caused by a DELETE statement are not valid
because the primary key, unique constraint or unique
index identified by "1" constrains table
我使用@GeneratedValue(strategy = GenerationType.AUTO)
什么strategy = GenerationType
我应该用来克服这个问题。
您必须在插入此规则后清除数据库 – SjB
@SjB插入哪个规则后? –