-->
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.  [ 4 posts ] 
Author Message
 Post subject: why I can't cascade update child class
PostPosted: Tue Dec 20, 2005 11:13 am 
Newbie

Joined: Fri Dec 02, 2005 4:25 am
Posts: 2
Child child = new Child();
child.parentid=parent;
parent.childlist.add(child);

when i session1.update(parent),they will post a Error:

NHibernate.HibernateException: SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count.

who can help me?thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 2:56 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
If you have cascading set up correctly, you should save the child:
Code:
session1.Save( child );
I believe parent.childlist should have inverse="true" on it as well. That's just off the top of my head, though, could be wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 12:39 am 
Newbie

Joined: Fri Dec 02, 2005 4:25 am
Posts: 2
thanks,I can cascade child.Because I change child's id befor post parent.I found "unsaved-value" is a import key.
But I found, if i make child's id use "assigned",I can't cascade child. And it will view the same failure as before if I change child's id before post parent.

who can help me? in "assigned" status, how I can cascade child via post parent


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 22, 2005 4:17 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
If you can, add a version to your object/table, and use the version/@unsaved-value attribute in your mapping. That, I think, is the most elegant solution for assigned-id objects.


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