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.  [ 2 posts ] 
Author Message
 Post subject: Very simple "question" (newbie)
PostPosted: Mon Feb 14, 2005 3:24 pm 
Beginner
Beginner

Joined: Thu Dec 23, 2004 8:47 am
Posts: 32
Location: Brazil State:Rio Grande do Sul City:Porto Alegre
Hello all!

I have a simple bidirectional One to Many (Parent / Child ) relationship,
and when i´m trying to insert a new child into a existing parent , hibernate
generates two selects.
This way

parent.addChild(child)
{
child.setParent(thisParent);
* thisParent.getChilds.add(child);
}



select Parent... -> because i´m using session.get and it´s fine.
*select Childs... -> in my case it is unnecessary, because i am just inserting a new child with no other transaction or operation where i use my set of childs.

So i just use child.setParent(thisParent) and it´s ok right ?!
then it generates just one select and one insert.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 10:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Have a read of this.
http://www.hibernate.org/hib_docs/reference/en/html/example-parentchild.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.