I am using NHibernate and this error appears when I use Get method of Session.
This is my code:
public T GetById(object id)
{
T entity;
entity = (T)ReportHttpModule.CurrentSession.Get(typeof(T), id);
return entity;
}
note that I don’t get this error when use CreateCriteria(T) before calling that method!
I’ve found the solution. It is weird but it was a problem in mapping file. One of my columns had
not-null="true"in mapping file but in database was not nullable!