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: Update in parent table forces deletion of all childs
PostPosted: Thu Apr 12, 2007 6:59 am 
Newbie

Joined: Thu Apr 12, 2007 6:48 am
Posts: 1
Hi all,

I have 2 objects linked with many-to-many relation (using many-to-many mapping), see hibernate mapping file fragment on the bottom.

Everything works fine when I create object (also with relations specified in documentCollections property), retrieve, update it also with documentCollections property set.

But I want also to be able to update just parent table and don't touch childs. But if I set documentCollections to null, it deletes all references to child objects.

Is there a way to do it easy?

Regards,
Andrei


<hibernate-mapping default-cascade="all">
<class name="ModulePO" table="MODULE">

.....

<set name="documentCollections" table="MOD_DC" lazy="true" cascade="all">
<key>
<column name="FK_MODULE_ID" not-null="true" />
</key>
<many-to-many class="DocumentCollectionPO" fetch="join" unique="true">
<column name="FK_DOCUMENTCOLLECTION_ID" not-null="true" />
</many-to-many>
</set>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 9:29 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
One question. Why do you set documentCollections to null?

Quote:
NHibernate does not distinguish between a null collection reference and an empty collection.

You can find it here: http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/collections.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.