-->
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.  [ 5 posts ] 
Author Message
 Post subject: I was wonder why Hibernate can handle this...
PostPosted: Sat Mar 13, 2004 11:43 am 
Newbie

Joined: Sat Mar 13, 2004 9:46 am
Posts: 10
Hello,

I have modelled a parent-child relationship. All is done according to the document that describes the parent chid relationship.

I have one parent and one child object which are connected to each other.

Everything works just fine, when I save the parent object with session.save(parent) the parent and child are inserted into the database. I was wondering how Hibernate reacts when I save the child object instead of the parent object. So I replaced the session.save(parent) by session.save(child) and ran my app again. I thought Hibernate knows how to handle this case, but I received the following exception
Quote:
Exception in thread "main" net.sf.hibernate.PropertyValueException: not-null property references a null or transient value: Parent


I just wonder why can't Hibernate handle this save order?

dee3lmo!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 11:45 am 
Newbie

Joined: Sat Mar 13, 2004 9:46 am
Posts: 10
SORRY THE TITLE MUST BE 'I was wonder why Hibernate CAN'T handle this...'


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 11:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
because you didn't enable cascade save on the many-to-one association


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 11:58 am 
Newbie

Joined: Sat Mar 13, 2004 9:46 am
Posts: 10
Thanks gavin now it works!
I really appreciate that the Hibernate team reponse so quickly on issues of beginners!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 13, 2004 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
next time you'd better write
'I was wonder why i CAN'T handle this knowing hibernate can do a lot of things...' ;))


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

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.