-->
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: new extra update issue
PostPosted: Wed Sep 14, 2005 1:29 am 
Newbie

Joined: Sun Sep 11, 2005 6:28 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Mapping documents:
in Child mapping file:
<many-to-one name="parent" column="parent_id" not-null="true"/>

in Parent mapping file
<set name="children" inverse="true">
<key column="parent_id"/>
<one-to-many class="Child"/>
</set>

I have above standard one-to-many association, in the Parent POJO, I also have a standard setter for the children set, like:
public class Parent implements serializable{
Set childrenSet = new HashSet();
...
public void setChildren(Set childrenSet){
this.children = childrenSet;
}
...
}


everything worked fine when I go like:

Parent p = new Parent();
p.setId(1);
Child c = new Child();
c.setParent(p);
p.getChildren().add(c);
session.save(p);

But, when I change the setter to following code:
public void setChildren(Set childrenSet){
this.children = new HashSet(childrenSet);
}

I got a problem, hibernate inserted parent and child first, but after that , it did an extra update on parent.

Is there any way to get rid of this extra update?
(The reason of doing this is that we want to pass a standard Set back to the RMI client instead of a Hibernate's Set as we don't want to have client end include hibernate3.jar in the classpath)

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.