-->
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: Cascade problem -- object with two parents
PostPosted: Wed Jan 05, 2005 11:22 am 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
I have the following parent/child relations:

Code:
         ClassA
         /      \
      ClassB  ClassC
         \      /
          ClassD


Relations from top to bottom are all one-to-many. A has many Bs, A has many Cs, and both B and C have many Ds. D basically implements a many-to-many between B and C.

All associations are bi-directional. For all one-to-many set mappings, I have cascade="all-delete-orphan". For all many-to-one mappings, I have no cascade defined and not-null="true". In other words, all children must have a parent, and all operations cascade from parents to children.

The problem is I can't create a simple four object graph and save it. When I call saveOrUpdate on an object of ClassA, I get the following exception:

Code:
net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: com.mycompany.ClassD.objectC


I assume this happens because Hibernate tries to persist the ClassD object before the ClassC object. How can I make this work? Isn't Hibernate supposed to correctly order saves so this doesn't happen? I am using version 2.1.6.

Thanks.


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.