How do I tell NHibernate to load a component as not null even when all its properties are null?
Posted
by SharePoint Newbie
on Stack Overflow
See other posts from Stack Overflow
or by SharePoint Newbie
Published on 2010-05-21T06:30:50Z
Indexed on
2010/05/23
12:40 UTC
Read the original article
Hit count: 240
nhibernate
|nhibernate-mapping
Hi,
I have a Date class which wraps over the DateTime? class (aids in mocking DateTime.Now, our domain ,etc).
The Date class class only has one protected property : DateTime? date
public class Date
{
protected DateTime? date;
}
// mapping in hbm
<component name="CompletedOn">
<property column="StartedOn" name="date" access="field" not-null="false" />
</component>
From the nhibernate docs:
Like all value types, components do not support shared references. The null value semantics of a component are ad hoc. When reloading the containing object, NHibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes.
Can I override this behaviour? I want my Date class to be instantiated even if date is null.
Thanks,
© Stack Overflow or respective owner