-->
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.  [ 5 posts ] 
Author Message
 Post subject: Deleting an object tree
PostPosted: Fri Mar 10, 2006 6:39 pm 
Newbie

Joined: Sun Jul 24, 2005 2:19 am
Posts: 7
I have a model with object with a child collection which further has a child collection.

I have set the parent objects to cascade "All-Delete-Orphan".

When I try to delete the top level object - NH tries to update the children objects with NULL values first instead of just deleting them. Is that normal behaviour? How do I get around this?

Thanks
Manuj


Top
 Profile  
 
 Post subject: putting null instead of deleting
PostPosted: Mon Mar 13, 2006 5:50 pm 
Newbie

Joined: Mon Mar 13, 2006 5:35 pm
Posts: 2
I have exactly the same problem, hibernate puts null instead of deleting the complete row, suggestions??

Thanks!


Top
 Profile  
 
 Post subject: inverse
PostPosted: Tue Mar 14, 2006 1:20 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
Are you using bi-directional association, if yes have you correctly specified the inverse=true attribute for the bi-directional association. If yes then you should not be seeing this behaviour.

Please check this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 5:29 am 
Newbie

Joined: Mon Mar 13, 2006 5:35 pm
Posts: 2
I solved the problem using a composite-element instead of a mapped entity.
The old mapping:
Code:
<list name="centroids" table="CENTROIDS" cascade="all-delete-orphan">
     <key column="ID_PATTERN"></key>
     <index column="POSITION" />         
     <one-to-many class="Serie"/>
</list>

The new mapping:
Code:
<list name="centroids" table="CENTROIDS" cascade="all-delete-orphan">
     <key column="ID_PATTERN"></key>
     <index column="POSITION" />
      <composite-element class="Serie">
          <property name="SH00_00" type="float" />
          <property name="SH01_00" type="float" />
          <property name="SH02_00" type="float" />
          <property name="SH03_00" type="float" />            
      </composite-element>
</list>

Thanks!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 5:24 am 
Newbie

Joined: Wed Mar 15, 2006 4:59 am
Posts: 3
I have gone across the similar problem,and I really don't know what goes wrong:
this.m_Parent = this.m_Session.Load(typeof(Parent), 1) as Parent;
this.m_Child.SingleParent = this.m_Parent;
this.m_Child.ChildID = 1;
this.m_Child.Name = "Child01";
this.m_Parent.Children.Add(this.m_Child);
this.m_Session.Flush();
I have set the parent objects to cascade "All",and inverse"true" .But when I flush the session.An exception breaks out
:NHibernate.HibernateException was unhandled
Message="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."
Source="NHibernate"

While I having none trigger for the database


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