Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6723/nhibernate/src/NHibernate/Impl Modified Files: CollectionEntry.cs CriteriaImpl.cs IExecutable.cs ScheduledCollectionAction.cs ScheduledCollectionRecreate.cs ScheduledCollectionRemove.cs ScheduledCollectionUpdate.cs ScheduledDeletion.cs ScheduledEntityAction.cs ScheduledIdentityInsertion.cs ScheduledInsertion.cs ScheduledUpdate.cs SessionImpl.cs Log Message: Refactored as per 2.1 Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** SessionImpl.cs 10 Mar 2005 02:21:06 -0000 1.70 --- SessionImpl.cs 14 Mar 2005 18:52:52 -0000 1.71 *************** *** 44,63 **** /// <c>true</c> if the Session has had the methods <c>Close()</c> or /// <c>Dispose()</c> invoked.</value> ! private bool closed; private FlushMode flushMode = FlushMode.Auto; ! /// <summary> ! /// A boolean indicating if the method AfterTransactionCompletion() should ! /// be called from the method Disconnect(). ! /// </summary> ! /// <value> [...1094 lines suppressed...] // that references it ! ICollectionPersister persister = factory.GetCollectionPersister( role ); ! PersistentCollection collection = GetLoadingCollection( role, id ); if (collection != null) *************** *** 4937,4941 **** log.Debug( "creating collection wrapper:" + MessageHelper.InfoString(persister, id) ); } ! collection = persister.CollectionType.Instantiate(this, persister); //TODO: suck into CollectionPersister.instantiate() AddUninitializedCollection(collection, persister, id); if ( persister.IsArray ) --- 5024,5029 ---- log.Debug( "creating collection wrapper:" + MessageHelper.InfoString(persister, id) ); } ! //TODO: suck into CollectionPersister.instantiate() ! collection = persister.CollectionType.Instantiate(this, persister); AddUninitializedCollection(collection, persister, id); if ( persister.IsArray ) Index: CriteriaImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CriteriaImpl.cs 31 Dec 2004 19:51:05 -0000 1.8 --- CriteriaImpl.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 1,4 **** --- 1,8 ---- using System.Collections; using NHibernate.Engine; + using NHibernate.Persister; + using NHibernate.Transform; + using NHibernate.Type; + using NHibernate.Util; using NExpression = NHibernate.Expression; *************** *** 10,20 **** internal class CriteriaImpl : ICriteria { ! private IList expressions = new ArrayList(); private IList orderings = new ArrayList(); private IDictionary fetchModes = new Hashtable(); ! ! private RowSelection selection = new RowSelection(); private System.Type persistentClass; private SessionImpl session; private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); --- 14,36 ---- internal class CriteriaImpl : ICriteria { ! private IList criteria = new ArrayList(); private IList orderings = new ArrayList(); private IDictionary fetchModes = new Hashtable(); ! private IDictionary associationPathByAlias = new Hashtable(); ! private IDictionary aliasByAssociationPath = new Hashtable(); ! private IDictionary classByAlias = new Hashtable(); ! private IDictionary lockModes = new Hashtable(); ! private int maxResults; ! private int firstResult; ! private int timeout; ! private int fetchSize; private System.Type persistentClass; private SessionImpl session; + private IResultTransformer resultTransformer; //== new RootEntityResultTransformer(); + private bool cacheable; + private string cacheRegion; + private RowSelection selection = new RowSelection(); + + private int counter = 0; private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); *************** *** 23,26 **** --- 39,90 ---- /// /// </summary> + public const string RootAlias = "this"; + + /// <summary> + /// + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="session"></param> + public CriteriaImpl( System.Type persistentClass, SessionImpl session ) + { + this.persistentClass = persistentClass; + this.session = session; + this.classByAlias[ CriteriaImpl.RootAlias ] = persistentClass ; + this.cacheable = false; + } + + /// <summary> + /// Copy all the internal attributes of the given CriteriaImpl + /// except alter the root persistent class type to be the given one. + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="original"></param> + public CriteriaImpl( System.Type persistentClass, CriteriaImpl original ) + { + this.persistentClass = persistentClass; + + //this.classByAlias = original.ClassByAlias; + //this.classByAlias.put( CriteriaImpl.RootAlias, persistentClass); + + this.criteria = original.Criteria; + this.orderings = original.Orderings; + this.fetchModes = original.FetchModes; + this.associationPathByAlias = original.AssociationPathByAlias; + this.aliasByAssociationPath = original.AliasByAssociationPath; + this.lockModes = original.LockModes; + this.maxResults = original.MaxResults; + this.firstResult = original.FirstResult; + this.timeout = original.Timeout; + this.fetchSize = original.FetchSize; + this.session = original.Session; + this.resultTransformer = original.ResultTransformer; + this.counter = original.Counter; + this.cacheable = original.Cacheable; + this.cacheRegion = original.CacheRegion; + } + + /// <summary> + /// + /// </summary> /// <param name="maxResults"></param> /// <returns></returns> *************** *** 56,65 **** /// /// </summary> ! /// <param name="expression"></param> /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { ! expressions.Add( expression ); ! conjunction.Add( expression ); return this; } --- 120,128 ---- /// /// </summary> ! /// <param name="fetchSize"></param> /// <returns></returns> ! public ICriteria SetFetchSize( int fetchSize ) { ! this.fetchSize = fetchSize; return this; } *************** *** 78,90 **** } /// <summary> /// /// </summary> ! /// <param name="persistentClass"></param> ! /// <param name="session"></param> ! public CriteriaImpl( System.Type persistentClass, SessionImpl session ) { ! this.persistentClass = persistentClass; ! this.session = session; } --- 141,239 ---- } + internal IList Criteria + { + get { return criteria; } + } + + internal IList Orderings + { + get { return orderings; } + } + + internal IDictionary LockModes + { + get { return lockModes; } + } + + internal IDictionary FetchModes + { + get { return fetchModes; } + } + + internal IDictionary AssociationPathByAlias + { + get { return associationPathByAlias; } + } + + internal IDictionary AliasByAssociationPath + { + get { return aliasByAssociationPath; } + } + + internal SessionImpl Session + { + get { return session; } + } + + internal IResultTransformer ResultTransformer + { + get { return resultTransformer; } + } + + internal int Counter + { + get { return counter; } + } + + internal bool Cacheable + { + get { return cacheable; } + } + + internal string CacheRegion + { + get { return cacheRegion; } + } + + /// <summary></summary> + public int MaxResults + { + get { return maxResults; } + } + + /// <summary></summary> + public int FirstResult + { + get { return firstResult; } + } + + /// <summary></summary> + public int Timeout + { + get { return timeout; } + } + + /// <summary></summary> + public int FetchSize + { + get { return fetchSize; } + } + + /// <summary></summary> + public bool IsJoin( string path ) + { + return aliasByAssociationPath.Contains( path ); + } + /// <summary> /// /// </summary> ! /// <param name="expression"></param> ! /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { ! criteria.Add( expression ); ! conjunction.Add( expression ); ! return this; } *************** *** 98,102 **** public IEnumerator IterateExpressions() { ! return expressions.GetEnumerator(); } --- 247,251 ---- public IEnumerator IterateExpressions() { ! return criteria.GetEnumerator(); } *************** *** 116,120 **** public override string ToString() { ! return expressions.ToString(); } --- 265,269 ---- public override string ToString() { ! return criteria.ToString(); } *************** *** 158,161 **** --- 307,409 ---- return this; } + + /// <summary> + /// + /// </summary> + /// <param name="lockMode"></param> + /// <returns></returns> + public ICriteria SetLockMode( LockMode lockMode ) + { + return SetLockMode( CriteriaImpl.RootAlias, lockMode ); + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="lockMode"></param> + /// <returns></returns> + public ICriteria SetLockMode( string alias, LockMode lockMode ) + { + lockModes[ alias ] = lockMode; + return this; + } + + /// <summary> + /// + /// </summary> + /// <param name="associationPath"></param> + /// <param name="alias"></param> + /// <returns></returns> + public ICriteria CreateAlias( string associationPath, string alias ) + { + CreateAlias( CriteriaImpl.RootAlias, associationPath, alias ); + return this; + } + + private void CreateAlias( string rootAlias, string associationPath, string alias ) + { + string testAlias = StringHelper.Root( associationPath ); + if ( classByAlias.Contains( testAlias ) ) + { + rootAlias = testAlias; + associationPath = associationPath.Substring( rootAlias.Length + 1 ); + } + + string rootPath = (string) associationPathByAlias[ rootAlias ]; + string wholeAssociationPath; + if ( rootPath == null ) + { + if ( !CriteriaImpl.RootAlias.Equals( rootAlias ) ) + { + throw new HibernateException( string.Format( "unknown alias: {0}", rootAlias ) ); + } + wholeAssociationPath = associationPath; + } + else + { + wholeAssociationPath = StringHelper.Qualify( rootPath, associationPath ); + } + + object oldPath = associationPathByAlias[ alias ] = wholeAssociationPath; + if ( oldPath != null ) + { + } + object oldAlias = aliasByAssociationPath[ wholeAssociationPath ] = alias; + if ( oldAlias != null ) + { + } + classByAlias[ alias ] = GetClassForPath( rootAlias, associationPath ); + } + + + /// <summary> + /// + /// </summary> + /// <param name="associationPath"></param> + /// <returns></returns> + public string GetAlias( string associationPath ) + { + return (string) aliasByAssociationPath[ associationPath ]; + } + + /// <summary> + /// + /// </summary> + /// <param name="rootAlias"></param> + /// <param name="associationPath"></param> + /// <returns></returns> + public System.Type GetClassForPath( string rootAlias, string associationPath ) + { + ISessionFactoryImplementor factory = session.Factory; + System.Type clazz = (System.Type) classByAlias[ rootAlias ]; + IType type = ( (IPropertyMapping) factory.GetPersister( clazz ) ).ToType( associationPath ); + if ( !type.IsAssociationType ) + { + throw new QueryException( string.Format( "not an association path: {0}", associationPath ) ); + } + + return ( (IAssociationType) type).GetAssociatedClass( factory ); + } } } \ No newline at end of file Index: ScheduledDeletion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledDeletion.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ScheduledDeletion.cs 6 Mar 2005 12:44:42 -0000 1.7 --- ScheduledDeletion.cs 14 Mar 2005 18:52:52 -0000 1.8 *************** *** 39,43 **** /// <summary></summary> ! public override void AfterTransactionCompletion() { if( Persister.HasCache ) --- 39,43 ---- /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { if( Persister.HasCache ) Index: IExecutable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/IExecutable.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IExecutable.cs 6 Mar 2005 12:44:42 -0000 1.3 --- IExecutable.cs 14 Mar 2005 18:52:52 -0000 1.4 *************** *** 25,33 **** /// Called after the Transaction has been completed. /// </summary> /// <remarks> /// Actions should make sure that the Cache is notified about /// what just happened. /// </remarks> ! void AfterTransactionCompletion(); /// <summary> --- 25,34 ---- /// Called after the Transaction has been completed. /// </summary> + /// <param name="success"></param> /// <remarks> /// Actions should make sure that the Cache is notified about /// what just happened. /// </remarks> ! void AfterTransactionCompletion( bool success ); /// <summary> Index: ScheduledIdentityInsertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledIdentityInsertion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ScheduledIdentityInsertion.cs 6 Mar 2005 12:44:43 -0000 1.1 --- ScheduledIdentityInsertion.cs 14 Mar 2005 18:52:52 -0000 1.2 *************** *** 10,14 **** { private readonly object[] state; ! private CacheEntry cacheEntry; private object generatedId; --- 10,14 ---- { private readonly object[] state; ! //private CacheEntry cacheEntry; private object generatedId; *************** *** 46,50 **** } ! public override void AfterTransactionCompletion( ) { // TODO: renable --- 46,54 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sucess"></param> ! public override void AfterTransactionCompletion( bool sucess ) { // TODO: renable Index: ScheduledCollectionRecreate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRecreate.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScheduledCollectionRecreate.cs 1 Mar 2005 16:24:46 -0000 1.6 --- ScheduledCollectionRecreate.cs 14 Mar 2005 18:52:52 -0000 1.7 *************** *** 28,33 **** { Persister.Recreate( _collection, Id, Session ); ! // TODO: Commented out as isn't in the 2.1 implementation - test ! //Persister.Softlock( Id ); } } --- 28,32 ---- { Persister.Recreate( _collection, Id, Session ); ! Evict(); } } Index: ScheduledInsertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledInsertion.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScheduledInsertion.cs 6 Mar 2005 12:44:42 -0000 1.6 --- ScheduledInsertion.cs 14 Mar 2005 18:52:52 -0000 1.7 *************** *** 10,14 **** { private readonly object[ ] state; ! private CacheEntry entry; private readonly object version; --- 10,14 ---- { private readonly object[ ] state; ! private CacheEntry cacheEntry; private readonly object version; *************** *** 32,58 **** public override void Execute() { Persister.Insert( Id, state, Instance, Session ); Session.PostInsert( Instance ); ! /* ! if ( Persister.HasCache && Persister.IsCacheInvalidationRequired ) { cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Put( Id, cacheEntry ); } - */ } /// <summary></summary> ! public override void AfterTransactionCompletion() { // Make 100% certain that this is called before any subsequent ScheduledUpdate.AfterTransactionCompletion()!! ! /* ! if ( Persister.HasCache && Persister.IsCacheInvalidationRequired ) { - cacheEntry = new CacheEntry( Instance, Persister, Session ); Persister.Cache.AfterInsert( Id, cacheEntry, version ); } - */ } } --- 32,55 ---- public override void Execute() { + // Don't need to lock the cache here, since if someone + // else inserted the same pk first, the insert would fail Persister.Insert( Id, state, Instance, Session ); Session.PostInsert( Instance ); ! if ( Persister.HasCache && !Persister.IsCacheInvalidationRequired ) { cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Insert( Id, cacheEntry ); } } /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { // Make 100% certain that this is called before any subsequent ScheduledUpdate.AfterTransactionCompletion()!! ! if ( success && Persister.HasCache && !Persister.IsCacheInvalidationRequired ) { Persister.Cache.AfterInsert( Id, cacheEntry, version ); } } } Index: CollectionEntry.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CollectionEntry.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CollectionEntry.cs 1 Mar 2005 16:24:46 -0000 1.7 --- CollectionEntry.cs 14 Mar 2005 18:52:52 -0000 1.8 *************** *** 93,96 **** --- 93,100 ---- internal ICollectionPersister currentPersister; + /// <summary></summary> + [NonSerialized] + internal object currentKey; + /// <summary> /// The <see cref="ICollectionPersister"/> when the Collection was loaded. *************** *** 103,110 **** internal ICollectionPersister loadedPersister; - /// <summary></summary> - [NonSerialized] - internal object currentKey; - /// <summary> /// The identifier of the Entity that is the owner of this Collection --- 107,110 ---- *************** *** 113,120 **** internal object loadedKey; ! /// <summary></summary> ! internal object snapshot; //session-start/post-flush persistent state ! /// <summary></summary> internal string role; --- 113,120 ---- internal object loadedKey; ! /// <summary>session-start/post-flush persistent state</summary> ! internal object snapshot; ! /// <summary>allow the snapshot to be serialized</summary> internal string role; *************** *** 128,131 **** --- 128,133 ---- public CollectionEntry() { + //a newly wrapped collection is NOT dirty (or we get unnecessary version updates) + this.dirty = false; // A newly wrapped collection is NOT dirty (or we get unnecessary version updates) //this.dirty = false; *************** *** 133,137 **** // New collections that get found and wrapped during flush shouldn't be ignored ! //this.ignore = false; } --- 135,139 ---- // New collections that get found and wrapped during flush shouldn't be ignored ! this.ignore = false; } *************** *** 151,157 **** public CollectionEntry( ICollectionPersister loadedPersister, object loadedID, bool ignore ) { ! // dirty & initialized are set to false by the runtime ! //this.dirty = false; ! //this.initialized = false; this.loadedKey = loadedID; SetLoadedPersister( loadedPersister ); --- 153,158 ---- public CollectionEntry( ICollectionPersister loadedPersister, object loadedID, bool ignore ) { ! this.dirty = false; ! this.initialized = false; this.loadedKey = loadedID; SetLoadedPersister( loadedPersister ); *************** *** 177,181 **** // Detached collections that get found and reattached during flush // shouldn't be ignored ! //this.ignore = false; SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); } --- 178,182 ---- // Detached collections that get found and reattached during flush // shouldn't be ignored ! this.ignore = false; SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); } *************** *** 277,284 **** // if it was initialized or any of the scheduled actions were performed then ! // need to resnpashot the contents of the collection. if( initialized && ( doremove || dorecreate || doupdate ) ) { ! InitSnapshot(collection, loadedPersister); } } --- 278,285 ---- // if it was initialized or any of the scheduled actions were performed then ! // need to resnapshot the contents of the collection. if( initialized && ( doremove || dorecreate || doupdate ) ) { ! InitSnapshot( collection, loadedPersister ); } } *************** *** 374,381 **** public bool IsNew { ! // TODO: is this correct implementation - h2.0.3 get { return initialized && ( snapshot == null ); } } } - } \ No newline at end of file --- 375,381 ---- public bool IsNew { ! // TODO: is this correct implementation get { return initialized && ( snapshot == null ); } } } } \ No newline at end of file Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ScheduledCollectionAction.cs 6 Mar 2005 12:44:42 -0000 1.11 --- ScheduledCollectionAction.cs 14 Mar 2005 18:52:52 -0000 1.12 *************** *** 58,62 **** /// <summary></summary> ! public void AfterTransactionCompletion() { if ( persister.HasCache ) --- 58,63 ---- /// <summary></summary> ! /// <param name="success"></param> ! public void AfterTransactionCompletion( bool success ) { if ( persister.HasCache ) *************** *** 90,93 **** --- 91,105 ---- } + /// <summary> + /// + /// </summary> + protected void Evict( ) + { + if ( persister.HasCache ) + { + persister.Cache.Evict( id ); + } + } + /// <summary></summary> public object[ ] PropertySpaces Index: ScheduledEntityAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledEntityAction.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ScheduledEntityAction.cs 6 Mar 2005 12:44:42 -0000 1.9 --- ScheduledEntityAction.cs 14 Mar 2005 18:52:52 -0000 1.10 *************** *** 86,90 **** /// Called when the Transaction this action occurred in has completed. /// </summary> ! public abstract void AfterTransactionCompletion(); /// <summary> --- 86,91 ---- /// Called when the Transaction this action occurred in has completed. /// </summary> ! /// <param name="success"></param> ! public abstract void AfterTransactionCompletion( bool success ); /// <summary> Index: ScheduledUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledUpdate.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ScheduledUpdate.cs 6 Mar 2005 12:44:42 -0000 1.10 --- ScheduledUpdate.cs 14 Mar 2005 18:52:52 -0000 1.11 *************** *** 10,18 **** internal class ScheduledUpdate : ScheduledEntityAction { ! private object[ ] _fields; ! private object _lastVersion; ! private object _nextVersion; ! private int[ ] _dirtyFields; ! private object[ ] _updatedState; private ISoftLock _lock; --- 10,20 ---- internal class ScheduledUpdate : ScheduledEntityAction { ! private readonly object[] fields; ! private readonly object[] oldFields; ! private readonly object lastVersion; ! private readonly object nextVersion; ! private readonly int[ ] dirtyFields; ! private readonly object[ ] updatedState; ! private CacheEntry cacheEntry; private ISoftLock _lock; *************** *** 23,26 **** --- 25,29 ---- /// <param name="fields">An array of objects that contains the value of each Property.</param> /// <param name="dirtyProperties">An array that contains the indexes of the dirty Properties.</param> + /// <param name="oldFields"></param> /// <param name="lastVersion">The current version of the object.</param> /// <param name="nextVersion">The version the object should be after update.</param> *************** *** 29,40 **** /// <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; } --- 32,44 ---- /// <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[ ] oldFields, object lastVersion, object nextVersion, object instance, object[ ] updatedState, IClassPersister persister, ISessionImplementor session ) : base( session, id, instance, persister ) { ! this.fields = fields; ! this.oldFields = oldFields; ! this.lastVersion = lastVersion; ! this.nextVersion = nextVersion; ! this.dirtyFields = dirtyProperties; ! this.updatedState = updatedState; } *************** *** 44,59 **** if( Persister.HasCache ) { ! _lock = Persister.Cache.Lock( Id, _lastVersion ); } - Persister.Update( Id, _fields, _dirtyFields, _lastVersion, Instance, Session ); - Session.PostUpdate( Instance, _updatedState, _nextVersion ); } /// <summary></summary> ! public override void AfterTransactionCompletion() { if( Persister.HasCache ) { ! Persister.Cache.Release( Id, _lock ); } } --- 48,84 ---- if( Persister.HasCache ) { ! _lock = Persister.Cache.Lock( Id, lastVersion ); ! } ! Persister.Update( Id, fields, dirtyFields, oldFields, lastVersion, Instance, Session ); ! Session.PostUpdate( Instance, updatedState, nextVersion ); ! ! if ( Persister.HasCache ) ! { ! if ( Persister.IsCacheInvalidationRequired ) ! { ! Persister.Cache.Evict( Id ); ! } ! else ! { ! // TODO: Inefficient if that cache is just going to ignore the updated state! ! cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Update( Id, cacheEntry ); ! } } } /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { if( Persister.HasCache ) { ! if ( success && !Persister.IsCacheInvalidationRequired ) ! { ! Persister.Cache.AfterUpdate( Id, cacheEntry, nextVersion, _lock ); ! } ! else ! { ! Persister.Cache.Release( Id, _lock ); ! } } } Index: ScheduledCollectionUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionUpdate.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScheduledCollectionUpdate.cs 1 Mar 2005 16:24:46 -0000 1.8 --- ScheduledCollectionUpdate.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 34,41 **** public override void Execute() { - if ( Persister.HasCache ) - { - Persister.Cache.Remove( Id ); - } if( !_collection.WasInitialized ) { --- 34,37 ---- *************** *** 78,82 **** Persister.InsertRows( _collection, Id, Session ); } ! } } --- 74,78 ---- Persister.InsertRows( _collection, Id, Session ); } ! Evict(); } } Index: ScheduledCollectionRemove.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRemove.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScheduledCollectionRemove.cs 6 Mar 2005 12:44:42 -0000 1.8 --- ScheduledCollectionRemove.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 30,39 **** public override void Execute() { - // TODO: 2.1 Remove this clause - if ( Persister.HasCache ) - { - Persister.Cache.Lock( Id, null ); - } - // if there were no entries in the snapshot of the collection then there // is nothing to remove so verify that the snapshot was not empty. --- 30,33 ---- *************** *** 42,45 **** --- 36,40 ---- Persister.Remove( Id, Session ); } + Evict(); } } |