From: Michael D. <mik...@us...> - 2004-11-28 03:29:11
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7017/src/NHibernate/Impl Modified Files: ScheduledCollectionAction.cs ScheduledCollectionRecreate.cs ScheduledCollectionRemove.cs ScheduledCollectionUpdate.cs ScheduledDeletion.cs ScheduledEntityAction.cs ScheduledInsertion.cs ScheduledUpdate.cs SessionImpl.cs Log Message: fix for NH-158 Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** SessionImpl.cs 8 Nov 2004 02:53:58 -0000 1.47 --- SessionImpl.cs 28 Nov 2004 03:13:44 -0000 1.48 *************** *** 2522,2526 **** // wrap up any new collections directly referenced by the object ! // or its compoents // NOTE: we need to do the wrap here even if its not "dirty", --- 2522,2526 ---- // wrap up any new collections directly referenced by the object ! // or its components // NOTE: we need to do the wrap here even if its not "dirty", Index: ScheduledInsertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledInsertion.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScheduledInsertion.cs 28 Mar 2004 06:08:10 -0000 1.2 --- ScheduledInsertion.cs 28 Nov 2004 03:13:44 -0000 1.3 *************** *** 10,24 **** { ! private readonly object[] state; ! public ScheduledInsertion(object id, object[] state, object instance, IClassPersister persister, ISessionImplementor session) : base(session, id, instance, persister) { ! this.state = state; } public override void Execute() { ! Persister.Insert( Id, state, Instance, Session); ! Session.PostInsert(Instance); } --- 10,33 ---- { ! private readonly object[] _state; ! /// <summary> ! /// Initializes a new instance of <see cref="ScheduledInsertion"/>. ! /// </summary> ! /// <param name="id">The identifier of the object.</param> ! /// <param name="state">An object array that contains the state of the object being inserted.</param> ! /// <param name="instance">The actual object instance.</param> ! /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> ! /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledInsertion(object id, object[] state, object instance, IClassPersister persister, ISessionImplementor session) ! : base(session, id, instance, persister) { ! _state = state; } public override void Execute() { ! Persister.Insert( Id, _state, Instance, Session); ! Session.PostInsert( Instance ); } Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledCollectionAction.cs 28 Mar 2004 06:08:10 -0000 1.5 --- ScheduledCollectionAction.cs 28 Nov 2004 03:13:44 -0000 1.6 *************** *** 9,46 **** internal abstract class ScheduledCollectionAction : SessionImpl.IExecutable { ! private CollectionPersister persister; ! private object id; ! private ISessionImplementor session; public ScheduledCollectionAction(CollectionPersister persister, object id, ISessionImplementor session) { ! this.persister = persister; ! this.session = session; ! this.id = id; } public void AfterTransactionCompletion() { ! persister.ReleaseSoftlock(id); } public object[] PropertySpaces { ! get { return new string[] { persister.QualifiedTableName }; } //TODO: cache the array on the persister } public CollectionPersister Persister { ! get { return persister;} } public object Id { ! get { return id;} } public ISessionImplementor Session { ! get { return session;} } --- 9,46 ---- internal abstract class ScheduledCollectionAction : SessionImpl.IExecutable { ! private CollectionPersister _persister; ! private object _id; ! private ISessionImplementor _session; public ScheduledCollectionAction(CollectionPersister persister, object id, ISessionImplementor session) { ! _persister = persister; ! _session = session; ! _id = id; } public void AfterTransactionCompletion() { ! _persister.ReleaseSoftlock( _id ); } public object[] PropertySpaces { ! get { return new string[] { _persister.QualifiedTableName }; } //TODO: cache the array on the persister } public CollectionPersister Persister { ! get { return _persister;} } public object Id { ! get { return _id;} } public ISessionImplementor Session { ! get { return _session;} } Index: ScheduledDeletion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledDeletion.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScheduledDeletion.cs 28 Mar 2004 06:08:10 -0000 1.2 --- ScheduledDeletion.cs 28 Nov 2004 03:13:44 -0000 1.3 *************** *** 8,28 **** internal class ScheduledDeletion : ScheduledEntityAction { ! private object version; ! public ScheduledDeletion(object id, object version, object instance, IClassPersister persister, ISessionImplementor session) : base(session, id, instance, persister) { ! this.version = version; } public override void Execute() { ! if ( Persister.HasCache ) Persister.Cache.Lock(Id); ! Persister.Delete(Id, version, Instance, Session); ! Session.PostDelete(Instance); } public override void AfterTransactionCompletion() { ! if ( Persister.HasCache ) Persister.Cache.Release(Id); } } --- 8,37 ---- internal class ScheduledDeletion : ScheduledEntityAction { ! private object _version; ! /// <summary> ! /// Initializes a new instance of <see cref="ScheduledDeletion"/>. ! /// </summary> ! /// <param name="id">The identifier of the object.</param> ! /// <param name="version">The version of the object being deleted.</param> ! /// <param name="instance">The actual object instance.</param> ! /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> ! /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledDeletion(object id, object version, object instance, IClassPersister persister, ISessionImplementor session) ! : base(session, id, instance, persister) { ! _version = version; } public override void Execute() { ! if( Persister.HasCache ) Persister.Cache.Lock( Id ); ! Persister.Delete( Id, _version, Instance, Session ); ! Session.PostDelete( Instance ); } public override void AfterTransactionCompletion() { ! if ( Persister.HasCache ) Persister.Cache.Release( Id ); } } Index: ScheduledCollectionRecreate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRecreate.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ScheduledCollectionRecreate.cs 28 Mar 2004 06:08:10 -0000 1.2 --- ScheduledCollectionRecreate.cs 28 Nov 2004 03:13:44 -0000 1.3 *************** *** 8,22 **** internal sealed class ScheduledCollectionRecreate : ScheduledCollectionAction { ! private PersistentCollection collection; public ScheduledCollectionRecreate(PersistentCollection collection, CollectionPersister persister, object id, ISessionImplementor session) : base(persister, id, session) { ! this.collection = collection; } public override void Execute() { ! Persister.Softlock(Id); ! Persister.Recreate(collection, Id, Session); } } --- 8,22 ---- internal sealed class ScheduledCollectionRecreate : ScheduledCollectionAction { ! private PersistentCollection _collection; public ScheduledCollectionRecreate(PersistentCollection collection, CollectionPersister persister, object id, ISessionImplementor session) : base(persister, id, session) { ! _collection = collection; } public override void Execute() { ! Persister.Softlock( Id ); ! Persister.Recreate( _collection, Id, Session ); } } Index: ScheduledEntityAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledEntityAction.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScheduledEntityAction.cs 28 Mar 2004 06:08:10 -0000 1.3 --- ScheduledEntityAction.cs 28 Nov 2004 03:13:44 -0000 1.4 *************** *** 10,44 **** { ! private readonly ISessionImplementor session; ! private readonly object id; ! private readonly IClassPersister persister; ! private readonly object instance; protected ScheduledEntityAction(ISessionImplementor session, object id, object instance, IClassPersister persister) { ! this.session = session; ! this.id = id; ! this.persister = persister; ! this.instance = instance; } ! public object[] PropertySpaces { ! get { return persister.PropertySpaces; } } protected ISessionImplementor Session { ! get { return session;} } protected object Id { ! get { return id; } } protected IClassPersister Persister { ! get { return persister;} } --- 10,52 ---- { ! private readonly ISessionImplementor _session; ! private readonly object _id; ! private readonly IClassPersister _persister; ! private readonly object _instance; + /// <summary> + /// Initializes a new instance of <see cref="ScheduledEntityAction"/>. + /// </summary> + /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> + /// <param name="id">The identifier of the object.</param> + /// <param name="instance">The actual object instance.</param> + /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> protected ScheduledEntityAction(ISessionImplementor session, object id, object instance, IClassPersister persister) { ! _session = session; ! _id = id; ! _persister = persister; ! _instance = instance; } ! public object[] PropertySpaces ! { ! get { return _persister.PropertySpaces; } } protected ISessionImplementor Session { ! get { return _session;} } protected object Id { ! get { return _id; } } protected IClassPersister Persister { ! get { return _persister;} } *************** *** 46,54 **** protected object Instance { ! get { return instance; } } public abstract void AfterTransactionCompletion(); public abstract void Execute(); --- 54,68 ---- protected object Instance { ! get { return _instance; } } + /// <summary> + /// Called when the Transaction this action occurred in has completed. + /// </summary> public abstract void AfterTransactionCompletion(); + /// <summary> + /// Execute the action using the <see cref="IClassPersister"/>. + /// </summary> public abstract void Execute(); Index: ScheduledUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledUpdate.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledUpdate.cs 27 Nov 2004 01:03:39 -0000 1.5 --- ScheduledUpdate.cs 28 Nov 2004 03:13:44 -0000 1.6 *************** *** 8,24 **** internal class ScheduledUpdate : ScheduledEntityAction { ! private object[] fields; ! private object lastVersion; ! private object nextVersion; ! private int[] dirtyFields; ! private object[] updatedState; public ScheduledUpdate(object id, object[] fields, int[] dirtyProperties, object lastVersion, object nextVersion, object instance, object[] updatedState, IClassPersister persister, ISessionImplementor session) : base(session, id, instance, persister) { ! this.fields = fields; ! this.lastVersion = lastVersion; ! this.nextVersion = nextVersion; ! this.dirtyFields = dirtyFields; ! this.updatedState = updatedState; } --- 8,36 ---- internal class ScheduledUpdate : ScheduledEntityAction { ! private object[] _fields; ! private object _lastVersion; ! private object _nextVersion; ! private int[] _dirtyFields; ! private object[] _updatedState; + /// <summary> + /// Initializes a new instance of <see cref="ScheduledUpdate"/>. + /// </summary> + /// <param name="id">The identifier of the object.</param> + /// <param name="fields">An object array that contains the value of each Property.</param> + /// <param name="dirtyProperties">An array that contains the indexes of the dirty Properties.</param> + /// <param name="lastVersion">The current version of the object.</param> + /// <param name="nextVersion">The version the object should be after update.</param> + /// <param name="instance">The actual object instance.</param> + /// <param name="updatedState"></param> + /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> + /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> public ScheduledUpdate(object id, object[] fields, int[] dirtyProperties, object lastVersion, object nextVersion, object instance, object[] updatedState, IClassPersister persister, ISessionImplementor session) : base(session, id, instance, persister) { ! _fields = fields; ! _lastVersion = lastVersion; ! _nextVersion = nextVersion; ! _dirtyFields = dirtyProperties; ! _updatedState = updatedState; } *************** *** 26,36 **** { if ( Persister.HasCache ) Persister.Cache.Lock(Id); ! Persister.Update(Id, fields, dirtyFields, lastVersion, Instance, Session); ! Session.PostUpdate(Instance, updatedState, nextVersion); } public override void AfterTransactionCompletion() { ! if ( Persister.HasCache ) Persister.Cache.Release(Id); } } --- 38,48 ---- { if ( Persister.HasCache ) Persister.Cache.Lock(Id); ! Persister.Update( Id, _fields, _dirtyFields, _lastVersion, Instance, Session ); ! Session.PostUpdate( Instance, _updatedState, _nextVersion ); } public override void AfterTransactionCompletion() { ! if( Persister.HasCache ) Persister.Cache.Release( Id) ; } } Index: ScheduledCollectionUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionUpdate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScheduledCollectionUpdate.cs 28 Mar 2004 06:08:10 -0000 1.4 --- ScheduledCollectionUpdate.cs 28 Nov 2004 03:13:44 -0000 1.5 *************** *** 9,43 **** { ! private readonly PersistentCollection collection; ! private readonly bool emptySnapshot; public ScheduledCollectionUpdate(PersistentCollection collection, CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session) : base(persister, id, session) { ! this.collection = collection; ! this.emptySnapshot = emptySnapshot; } public override void Execute() { ! Persister.Softlock(Id); ! if ( !collection.WasInitialized ) { ! if ( !collection.HasQueuedAdds ) throw new AssertionFailure("bug processing queued adds"); //do nothing - we only need to notify the cache... } ! else if ( collection.Empty ) { ! if( !emptySnapshot ) Persister.Remove(Id, Session); } ! else if ( collection.NeedsRecreate(Persister) ) { ! if( !emptySnapshot ) Persister.Remove(Id, Session); ! Persister.Recreate(collection, Id, Session); } else { ! Persister.DeleteRows(collection, Id, Session); ! Persister.UpdateRows(collection, Id, Session); ! Persister.InsertRows(collection, Id, Session); } --- 9,43 ---- { ! private readonly PersistentCollection _collection; ! private readonly bool _emptySnapshot; public ScheduledCollectionUpdate(PersistentCollection collection, CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session) : base(persister, id, session) { ! _collection = collection; ! _emptySnapshot = emptySnapshot; } public override void Execute() { ! Persister.Softlock( Id ); ! if( !_collection.WasInitialized ) { ! if ( !_collection.HasQueuedAdds ) throw new AssertionFailure("bug processing queued adds"); //do nothing - we only need to notify the cache... } ! else if( _collection.Empty ) { ! if( !_emptySnapshot ) Persister.Remove( Id, Session ); } ! else if( _collection.NeedsRecreate( Persister ) ) { ! if( !_emptySnapshot ) Persister.Remove( Id, Session ); ! Persister.Recreate( _collection, Id, Session ); } else { ! Persister.DeleteRows( _collection, Id, Session ); ! Persister.UpdateRows( _collection, Id, Session ); ! Persister.InsertRows( _collection, Id, Session ); } Index: ScheduledCollectionRemove.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRemove.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScheduledCollectionRemove.cs 28 Mar 2004 06:08:10 -0000 1.3 --- ScheduledCollectionRemove.cs 28 Nov 2004 03:13:44 -0000 1.4 *************** *** 8,22 **** { ! private bool emptySnapshot; public ScheduledCollectionRemove(CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session) : base(persister, id, session) { ! this.emptySnapshot = emptySnapshot; } public override void Execute() { ! Persister.Softlock(Id); ! if(!emptySnapshot) Persister.Remove(Id, Session); } } --- 8,22 ---- { ! private bool _emptySnapshot; public ScheduledCollectionRemove(CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session) : base(persister, id, session) { ! _emptySnapshot = emptySnapshot; } public override void Execute() { ! Persister.Softlock( Id ); ! if( !_emptySnapshot ) Persister.Remove( Id, Session ); } } |