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.
|
|