-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: SaveOrUpdateCopy with non-database properties
PostPosted: Thu Mar 29, 2007 4:16 pm 
Newbie

Joined: Sun Feb 25, 2007 6:59 pm
Posts: 8
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.