If you are using conformist mapping-by-code introduced by NHibernate in the 3.2, and are facing this exception maybe you have another problem.
If you define a Bag map like this
Bag(x => x.CollectionProp
, map =>
{
map.Key(km => km.Column("col_id"));
map.Cascade(Cascade.All | Cascade.DeleteOrphans);
});
for a one-to-many association, you will retrieve this (misleading) exception.
To solve it you have to specific the action in a way like this:
Bag(x => x.CollectionProp
, map =>
{
map.Key(km => km.Column("col_id"));
map.Cascade(Cascade.All | Cascade.DeleteOrphans);
}
, action => action.OneToMany()
);
A
post about it on stack overflow.
That problem has just wasted a few hours of my life! Thank you for posting the solution.
ReplyDeleteYou're welcome :)
ReplyDeleteMan, you saved my day!
ReplyDeleteThank you!!!!
ReplyDeleteYou helped me out. Didn't know where to look. Much obliged.
ReplyDeleteYou're welcome =)
ReplyDeleteThank you sir !
ReplyDeleteI was trying out mapping by code (mixed with hbm files)
and this exception was driving me crazy.
The funny thing is, it identified wrong column mapping for class mapped by hbm file.
Adding the action solved the issue.
btw.: also applies to ISet.
You're welcome!
ReplyDeleteGood, another case to add to this exception .. =)
Finally! Thank you very much!
ReplyDeleteYou are welcome =)
ReplyDeleteDude, right now I would be prepared to have your babies (if it wasn't biologically impossible).
ReplyDeleteThank you! There's no way I would have looked there.