-->
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: Why SaveOrUpdateCopy doesnt call Interceptor.IsUnSaved?
PostPosted: Mon Apr 24, 2006 10:54 pm 
Regular
Regular

Joined: Fri Jul 29, 2005 9:46 am
Posts: 101
Hi!
NHibernate version: 1.02

I am triggering some validation logic that uses the interceptor similar
to the one described in http://www.hibernate.org/156.html in the second part "Using Session.isDirty() to Perform Complex Validations"

Everything seemed to be worked fine... until I realized that code only validates "changed" entities (not recently added ones) so I decided to use the "IsUnsaved" method of the interceptor to add the "just saved" objects to my list of "dirty objects" and everything worked fine while I was using SaverOrUpdate... but then I tried to call SaveOrUpdateCopy... and Interceptor.IsUnSaved just wasn't called! Why? well saveOrUpdateCopy calls the method DoCopy and:

In SessionImpl.cs in the DoCopy method there is a code around line 5412:

if( id == null && persister.IsUnsaved( obj ) )
{
copiedAlready[ obj ] = obj;
SaveWithGeneratedIdentifier( obj, Cascades.CascadingAction.ActionCopy, copiedAlready );
result = obj; // TODO: Handle its proxy (reassociate it, I suppose)
target = obj;
}

The problem, for me is that persister.IsUnsaved( obj ) is not preceded by a call to the Interceptor like in SaveOrUpdate

In SessionImpl.cs in the SaveOrUpdate method there is a code around line 1531:

object isUnsaved = interceptor.IsUnsaved( theObj );
IClassPersister persister = GetPersister( theObj );
if( isUnsaved == null )
{
// use unsaved-value
if( persister.IsUnsaved( theObj ) )

Now... AFAIK shouldnt Interceptor.IsUnSaved be called before every call to persister.IsUnsaved( theObj ) ? Is this a bug?
Wouldn't it be a good idea to have the IClassPersister automatically call the Interceptor? Is there a reason for this behavior? should I fix it? or will it cause me future problems?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 25, 2006 4:04 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Looks very much like a bug to me, please create a JIRA issue.


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.