one-to-one and cascade="all,delete-orphan"

73 views
Skip to first unread message

gusgorman

unread,
Nov 22, 2010, 12:02:43 PM11/22/10
to nhusers
Hi,

Was cascade="all,delete-orphan" ever implemented in Nhibernate?

It certainly wasn't at one point (see
http://colinjack.blogspot.com/2008/03/nhibernate-gotchas-orphans-and-one-to.html).

many thanks,
Jordan.

Hendry Luk

unread,
Nov 23, 2010, 1:14:10 AM11/23/10
to nhu...@googlegroups.com
I think this is asked very frequently (including by me, just a couple weeks ago), and very little reply, but it's safe to say that it's still unsuported till date, and possibly will never be.
Currently the workaround I use has always been mapping to a one-to-many private list field, and have your setter/getter to access the first item in that list.
I.e.
private readonly IList<Something> list = new List<Something>();
public Something Property{
   get{return list.First();}
   set{list.Clear(); if(value != null) list.Add(value);}
}
Then map that "list" field in the hbm using one-to-many


--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.


gusgorman

unread,
Nov 23, 2010, 6:22:36 AM11/23/10
to nhusers
> Currently the workaround I use has always been mapping to a one-to-many
> private list field, and have your setter/getter to access the first item in
> that list.

Hi Hendry,

Many thanks for the reply. Thats the workaround I've gone with.
This is a shame but not the end of the world.

Jordan.

Fabio Maulo

unread,
Nov 23, 2010, 7:02:11 AM11/23/10
to nhu...@googlegroups.com
What exactly mean "orphan" ?
Which is the parent ?

--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages