I've got a property on my entity base class which is not bound to the database (not a property in the mapping file). As it's on the base class it appears on many objects in the hierarchy. When I use SaveOrUpdateCopy and the disconnected object is merged back into the graph I lose the value of this property when the connected object is returned. Is there anyway to have NHibernate copy non-database bound properties when reattaching an object or do I need to write a reflection based copy?
Code:
obj.NotInDatabaseProperty = true;
obj.Children[0].NotInDatabaseProperty = true;
obj.Children[0].Children[0].NotInDatabaseProperty = true;
obj = session.SaveOrUpdateCopy(obj);
// NotInDatabaseProperty(s) back to default value
Based on the following code it doesn't appear to be the case, but perhaps I'm missing something:
Code:
// SessionImpl.DoCopy()
// no need to handle the version differently
object[] copiedValues = TypeFactory.Replace(
persister.GetPropertyValues(obj),
persister.GetPropertyValues(target),
persister.PropertyTypes,
this,
target, copiedAlready);
persister.SetPropertyValues(target, copiedValues);
[/code]