From: Michael D. <mik...@us...> - 2004-09-22 04:46:53
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20582/Impl Modified Files: SessionImpl.cs Log Message: Removed Obsoleted method from PersistentCollection Fixed bug with Bags that are lazy loading being flushed after an addition that would end up putting the same item in the bag twice. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** SessionImpl.cs 14 Sep 2004 17:49:55 -0000 1.41 --- SessionImpl.cs 22 Sep 2004 04:46:44 -0000 1.42 *************** *** 284,287 **** --- 284,288 ---- public void PostInitialize(PersistentCollection collection) { + initialized = true; snapshot = collection.GetSnapshot(loadedPersister); } *************** *** 290,298 **** public void PostFlush(PersistentCollection collection) { ! if (!processed) throw new AssertionFailure("Hibernate has a bug processing collections"); loadedKey = currentKey; SetLoadedPersister( currentPersister ); dirty = false; if ( initialized && ( doremove || dorecreate || doupdate ) ) { --- 291,307 ---- public void PostFlush(PersistentCollection collection) { ! if( !processed ) ! { throw new AssertionFailure("Hibernate has a bug processing collections"); + } loadedKey = currentKey; SetLoadedPersister( currentPersister ); dirty = false; + + // collection needs to know its' representation in memory and with + // the db is now in synch - esp important for collections like a bag + // that can add without initializing the collection. + collection.PostFlush(); + if ( initialized && ( doremove || dorecreate || doupdate ) ) { *************** *** 2917,2920 **** --- 2926,2930 ---- AddUninitializedCollection(pc, GetCollectionPersister(snapshot.Role), id); pc.ForceLoad(); + // commented out in h2.0.3 also // ugly & inefficient little hack to force collection to be recreated // after "disconnected" collection replaces the "connected" one *************** *** 3242,3245 **** --- 3252,3256 ---- // TODO: replace with owner version of this method... + [Obsolete("Use the one with CollectionPersister, id, owner) instead")] public PersistentCollection GetLoadingCollection(CollectionPersister persister, object id) { *************** *** 3445,3452 **** } - ce.initialized = true; ce.PostInitialize(collection); ! if (!writing) persister.Cache(id, collection, this); } } --- 3456,3466 ---- } ce.PostInitialize(collection); ! //removed this because it is not in h2.1 - I was having problems with Bags and ! // lazy additions and trying to cache uninitialized collections at this point. ! // Collections are still written to the Cache in EndLoadingCollection and that ! // is probably the most appropriate place for that code anyway. ! // if (!writing) persister.Cache(id, collection, this); } } |