How do I tell NHibernate to load a component as not null even when all its properties are null?

I don't think you can override that behavior.

Up vote 2 down vote favorite share g+ share fb share tw.

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 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, nhibernate nhibernate-mapping link|improve this question asked May 21 '10 at 6:30SharePoint Newbie1,52512154 66% accept rate.

I don't think you can override that behavior. However, it's usually easier to have NH work as usual (retrieving null) and wrap that in your domain model. But from what I see, it looks like you are doing this maybe for a presentation (data binding?

) concern. Isn't it easier to just expose a DateTime?

Mocking datetime. Now is a problem then... – SharePoint Newbie May 21 '10 at 17:39 Either way, you can't mock a static method. You should inject a "current time" service.

You are trying to deal with that at the wrong level. – Diego Mijelshon May 21 '10 at 18:33.

I think you could achieve this behavior by using a listener that implements IPostLoadEventListener. After the entity is loaded, you can check if the component is null and new it if it is.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions