-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem updating records with unique index
PostPosted: Sat Jun 09, 2007 11:32 am 
Regular
Regular

Joined: Sat May 20, 2006 3:49 am
Posts: 78
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.