Hello!
I have some problems merging the state of an Object with the database. I have the following tables and relations:
Table1
Table1.ID
Table1.SOME_COLUMN
Table2
Table2.ID
Table2.REF_COLUMN references Table1.ID
Table2.SOME_COLUMN
I have a unique index on Table2.REF_COLUMN, this means only one reference from Table2 to Table1 may exist. Note that I use DELETE_ORPHAN for all references.
Then I have a persisted Object for Table1 with an Reference to Table2. Now I do the following:
1) delete the referenced object
2) add a new referenced object
3) make a persist on the Object from Table1
Now Hibernate first tries to create the new object, but gets an error because of the unique index. Is there a way to tell Hibernate to make a delete before it inserts the new record to the database?
Regards,
Christoph.
|