我使用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插入哪個規則後? –