Hi,
I'm using a table that gets most of it's data including the primary key from an external system.
The code that I expected to work looks something like this.
Code:
try
{
// try to get the object from database...
return session.Get<MyClass>(externalId);
}
catch(ObjectNotFoundException)
{
// if not there create a new one...
return new MyClass(externalId);
}
I think the Get<T> method used to throw right away when calling it with an erraneous id, but instead it returns an invalid object. This objects throws when I try to get any properties. Can I change anything to get the exception when calling Get<T>? Any suggestions on an alternative strategy for this situation?
Thanks, Cristian
nhibernate version: 1.2.0.2002
mapping: A subclassed class with assigned id:s