Is my understanding correct, that the following class and table design is not possible in NHibernate:
public class Parent
{
public virtual Guid Id { get; set; }
public virtual ISet<Child> Children { get; set; }
...
}
public class Child
{
public virtual Guid Id { get; set; }
...
}
table Parent { Id, ... }
table Child { Id, ParentId (not null), ... }
So notice the following:
- a one-to-many association between parent and child
- using an ISet
- no bidirectional association from Child back to Parent
- Child’s ParentId column is not null
My knee jerk reaction was to say that that it was supported but I think you are right. Your options are either – bidirectional relationship or nullable ParentId column in Child table.
Here’s a interesting thread where Ayende gets into it in the bug tracker for NH
http://nhjira.koah.net/browse/NH-1050(it’s the previous release of NH but I think the answer is the same)UPDATE 5/7/11
Seems like something weird is going on with the Nhibernate JIRA (I.e. no domain name). The link can currently be found at https://nhibernate.jira.com/browse/NH-1050. However with NHibernate 3 out in the wild I have not checked to see if this question is still an issue.