To NH, all component fields null means that the component i missing, i.e. null.

To always have instance in your object model:
public AuditInfo {
    get { return _AInfo; }
    set { _AInfo = value ?? new AuditInfo(); }
}

/Oskar


2011/5/19  <[email protected]>:
> Hi,
>
> most of my entities need informations about when and from whom they were
> changed and created. So i added the
> following component to the mappings:
>
> <component name="AuditInfo" class="Domain.Base.AuditInfo,Domain.Base">
> <property name="CreatedAt" column="CREATE_DATE"/>
> <property name="ChangedAt" column="CHANGE_DATE"/>
> <many-to-one name="CreatedBy" class ="Domain.Base.User.AppUser, Domain.Base"
> column="CREATE_USER" cascade="none" fetch="join" lazy="false"
> not-found="ignore"/>
> <many-to-one name="ChangedBy" class ="Domain.Base.User.AppUser, Domain.Base"
> column="CHANGE_USER" cascade="none" fetch="join" lazy="false"
> not-found="ignore"/>
> </component>
>
> So far this works very well. Now my assumption was, that If all fields in
> the DB are NULL, an empty AuditInfo instance would be created. But the
> property AuditInfo is alyways null in this case.
> To avoid this, i tried to create the AuditInfo instance by myself in the
> constructor ( AuditInfo = new Domain.Base.AuditInfo() ). But this does'nt
> help because NH sets the property back to null
> when it loads the entity from the DB.
> Is there a way to avoid that behaviour or am i doing something wrong?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to