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: Child deletion for dummies
PostPosted: Tue Sep 25, 2007 9:21 am 
Newbie

Joined: Mon Sep 17, 2007 1:35 pm
Posts: 2
A newbe question, but I didn't found the response in the forum nor the docs.

Supose following:

Code:
Table "Person"
+Id
+Name
+IdAddress (allow null)

Table "Meeting"
+Id
+Date
+IdAddress (allow null)

Table "Address"
+Id
+Street


So the table "Address" is referenced by other two (Address.Id -> Person.IdAddress, Address.Id -> Meeting.IdAddress).

I would like to do something like that:

Code:
Person p1 = ... 'retrieve from database
p1.IdAdress = null
mysession.flush()


This should delete the date in table "Address". I try to use "all-delete-orphan" in the association xml file but it doesn't work. NHibernate don't do it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 11:51 am 
Beginner
Beginner

Joined: Tue Sep 14, 2004 1:03 pm
Posts: 33
Location: Calgary, Alberta Canada
Code:
Person p1 = session.get(personID);
p1.IdAddress = null;
session.Update(p1);


You have to update the persistent instance to the database.


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.