-->
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: Persisting objects with A->B, B->A independent relatio
PostPosted: Mon Jul 16, 2007 5:44 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
Let's say I have a persistent object of class A and B. There is an unidirectional relation from A to B as a property. And there is also an independant unidirectional relation from B to A as a property. I would like the relations to have a not-null constraint (and a unique constraint on on of the relation).

The problem is that after creating A or B and setting the relations to eachother I cannot make either A or B persistent, because Hibernate complains that there is a null or transient propery. Which is true, because when I save A there is a property to B which is not persistent yet. And when I save B there is a propery to A which is not persisten yet. It's like the chicken or the egg problem.

So is there something I can about this besides dropping the constraints? And setting one the relations after making the objects persistent? Is there for example a possibility to make two objects persistent at the same time?


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.