Strange ony-to-many mapping

7 views
Skip to first unread message

mynkow

unread,
Jun 14, 2012, 5:07:10 PM6/14/12
to castle-pro...@googlegroups.com
Hi

I have two classes with corresponding tables. User and Group. Each Group can have many members (User). Currently it is mapped like this:

References(x=>x.Members).Cascade.AllDeleteOrphan().blah

and the Group class has a collection for ex. 

IList<User> Members{get;set}

What I really want to do is Members to be a collection of Guid but still be able to cascade delete.

And the mapping should look like:

References<User>(x=>x.Members).Cascade.AllDeleteOrphan().blah 
IList<Guid> Members{get;set} 

The question is how to achieve this with NHibernate, some Custom types? I don't know. Or which classes should I change in fluent nhibernate to do such thing?

PS: Can we skip the question why I want such thing with NHibernate? 10x :)

Best regards.
mynkow

Jury Soldatenkov

unread,
Jun 16, 2012, 3:50:09 PM6/16/12
to castle-pro...@googlegroups.com
I'm not sure it's possible (especially with FHN)

I can imagine two possible workarounds at the moment, but it depends on your needs:
1. Map members as map of value types with index guid.
2. Map as collection of guid, and implement IPostCollectionRemovedEventListener to perform cascade delete "by hand".
3. Add new entity UserBinding, and map it with cascade deletion. It's not pure guid, but it should be very humble entity.


PS. Ask the question at nhusers group.
Reply all
Reply to author
Forward
0 new messages