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?