-->
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.  [ 2 posts ] 
Author Message
 Post subject: SessionImpl.DoSave() and IInterceptor.OnSave()
PostPosted: Mon Oct 03, 2005 2:54 pm 
It's not a problem, but I see something wierd,
As I was testing an interceptor implementing following:
Code:
      public bool OnSave(object entity, object id, object[] state, string[] propertyNames, NHibernate.Type.IType[] types)
      {
         IAuditItem item = entity as IAuditItem;

         if( item != null )
         {
            item.LastUpdated = DateTime.Now;

            return true; // indicate we've modified the object
         }
         else
            return false; // indicate we didn't touch the entity
      }


I found the SQL server complaining that my LastUpdated is out of range.
Stepping through the NHibernate code I see that my properties are overwritten by:
Code:
         if( substitute )
         {
            persister.SetPropertyValues( theObj, values );
         }


ServerSide artice (erroneously apparently) describes the return value as indicator that the object has been modified. Would be nice to actually work with the object instead of 2 arrays.

Later it's followed by:
Code:
         TypeFactory.DeepCopy( values, types, persister.PropertyUpdateability, values );


Is it me or the array is copied into itself? Is there a point?

Thanks,
E.


Top
  
 
 Post subject: Re: SessionImpl.DoSave() and IInterceptor.OnSave()
PostPosted: Mon Oct 03, 2005 3:57 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
E.T. wrote:
Would be nice to actually work with the object instead of 2 arrays.


On the other hand, working with the arrays avoids any possible side effects of property accessors.

E.T. wrote:
Later it's followed by:
Code:
         TypeFactory.DeepCopy( values, types, persister.PropertyUpdateability, values );


Is it me or the array is copied into itself? Is there a point?

I think the point is to create a (independent) copy of the contained values.


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

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.