This is my first time using NHibernate, and I'm currently in the process off writing mappings and restructuring the objects in my application so they map more cleanly.
I have a situation which looks a bit like this:
class A
{
// Properties of A
//..
// References an instance of B (but can be null)
public B BInstance { get; set; }
}
class B
{
// Properties relevant to a particular instance of A
}
Now, this seems like a one-to-one association to me, but I can find no references in the NHibernate documentation as to whether a nullable one-to-one association is actually possible.
Ideally, the "B Table" in my database would have an "A_ID" column. The presence of a row with that A_ID would indicate that the associated instance of A is in a non-null association. If there is no row with that A_ID, it would indicate a null association.
The only way I can think to map this is to map a collection from A (which the application restricts to 1 or 0 elements), but I'm wondering if there's a more obvious solution that I'm missing.
Thanks in advance for your assistance.
To clarify: I'm using vanilla NHibernate, not Fluent.