-
1. Re: @OneToMany audit entry -- Integrity constraint violation: Duplicate entry for primarykey
adamw Mar 16, 2012 12:53 AM (in response to lingling788)So the entry was removed from the ordinal 1 and added with ordinal 0. That seems correct.
Was the constraint that was violated created automatically? Or did you create it yourself?
Adam
-
2. Re: @OneToMany audit entry -- Integrity constraint violation: Duplicate entry for primarykey
lingling788 Mar 16, 2012 1:37 PM (in response to adamw)Thank you for your reply.
It was mysql database refused the change, some error like:
SQL Error: 1062, SQLState: 23000
Duplicate entry '1305063-1088737-14201' for key 1
I was confused about the operation on this ordinal update, do you mean the hibernate will remove the old record and generate a new one with the same id?
If that's the case, can I update the table with composite primary key: REV, account_holder_id, id, REVTYPE? Currently it's REV, account_holder_id, id and gives me error.
Will it cause any other issue? Because I've never put REVTYPE column as part of primary key in any of my audit tables.
Thank you very much.
-
3. Re: @OneToMany audit entry -- Integrity constraint violation: Duplicate entry for primarykey
adamw Mar 24, 2012 11:06 PM (in response to lingling788)The generated schema should have the correct constraints - did you auto-generate the schama, or do it by hand? I think you should add ordinal, not revtype, to your constraint.
Adam
-
4. Re: @OneToMany audit entry -- Integrity constraint violation: Duplicate entry for primarykey
lingling788 Mar 26, 2012 4:38 PM (in response to adamw)I think I should try with auto-generated schema. Thanks very much for the solution.