From: Michael D. <mik...@us...> - 2004-09-22 04:46:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20582/Collection Modified Files: ArrayHolder.cs Bag.cs IdentifierBag.cs List.cs Map.cs PersistentCollection.cs Set.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: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Bag.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bag.cs 9 Sep 2004 21:22:14 -0000 1.6 --- Bag.cs 22 Sep 2004 04:46:43 -0000 1.7 *************** *** 71,96 **** { object element = persister.ElementType.ResolveIdentifier(bagIdentifiers[i], session, owner); ! bag[i] = element; } } public override object ReadFrom(IDataReader reader, CollectionPersister persister, object owner) { object elementIdentifier = persister.ReadElementIdentifier(reader, owner, session); ! int index = bag.Add(null); ! bagIdentifiers.Insert(index, elementIdentifier); return elementIdentifier; } - [Obsolete("See PersistentCollection.ReadEntries for reason")] - public override void ReadEntries(ICollection entries) - { - foreach(object obj in entries) - { - bag.Add(obj); - } - } - public override void WriteTo(IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder) { --- 71,93 ---- { object element = persister.ElementType.ResolveIdentifier(bagIdentifiers[i], session, owner); ! bag.Add( element ); ! } ! ! if( Additions!=null ) ! { ! DelayedAddAll( Additions ); ! Additions = null; } } + public override object ReadFrom(IDataReader reader, CollectionPersister persister, object owner) { object elementIdentifier = persister.ReadElementIdentifier(reader, owner, session); ! bagIdentifiers.Add( elementIdentifier ); return elementIdentifier; } public override void WriteTo(IDbCommand st, CollectionPersister persister, object entry, int i, bool writeOrder) { Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Set.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Set.cs 16 Sep 2004 14:03:29 -0000 1.14 --- Set.cs 22 Sep 2004 04:46:43 -0000 1.15 *************** *** 319,331 **** } - /// <summary> - /// <see cref="PersistentCollection.ReadEntries"/> - /// </summary> - [Obsolete("See PersistentCollection for why it is obsolete")] - public override void ReadEntries(ICollection entries) { - foreach(DictionaryEntry entry in entries) { - map[entry.Key] = entry.Value; - } - } /// <summary> --- 319,322 ---- Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/List.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** List.cs 2 Sep 2004 15:07:19 -0000 1.13 --- List.cs 22 Sep 2004 04:46:43 -0000 1.14 *************** *** 155,163 **** } ! public override void EndRead(CollectionPersister persister, object owner) { ! for(int i = 0 ;i < listIdentifiers.Count; i++) { object element = persister.ElementType.ResolveIdentifier(listIdentifiers[i], session, owner); list[i] = element; } } --- 155,171 ---- } ! public override void EndRead(CollectionPersister persister, object owner) ! { ! for(int i = 0 ;i < listIdentifiers.Count; i++) ! { object element = persister.ElementType.ResolveIdentifier(listIdentifiers[i], session, owner); list[i] = element; } + + if( Additions!=null ) + { + DelayedAddAll( Additions ); + Additions = null; + } } *************** *** 197,208 **** } - [Obsolete("See PersistentCollection.ReadEntries for reason")] - public override void ReadEntries(ICollection entries) - { - foreach(object obj in entries) { - list.Add(obj); - } - } - public List(ISessionImplementor session, CollectionPersister persister, object disassembled, object owner) : base(session) { BeforeInitialize(persister); --- 205,208 ---- Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Map.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Map.cs 16 Sep 2004 14:03:29 -0000 1.14 --- Map.cs 22 Sep 2004 04:46:43 -0000 1.15 *************** *** 230,241 **** } - [Obsolete("See PersistentCollection.ReadEntries for reason")] - public override void ReadEntries(ICollection entries) - { - foreach(DictionaryEntry entry in entries) { - map[entry.Key] = entry.Value; - } - } - public override object Disassemble(CollectionPersister persister) { object[] result = new object[map.Count * 2]; --- 230,233 ---- Index: ArrayHolder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/ArrayHolder.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ArrayHolder.cs 16 Sep 2004 14:03:29 -0000 1.12 --- ArrayHolder.cs 22 Sep 2004 04:46:43 -0000 1.13 *************** *** 123,137 **** } - [Obsolete("See PersistentCollection.ReadEntries for reason")] - public override void ReadEntries(ICollection entries) - { - ArrayList list = new ArrayList(); - foreach(object obj in entries) - { - list.Add(obj); - } - array = list.ToArray( elementClass ); - } - public override void BeginRead() { --- 123,126 ---- Index: PersistentCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/PersistentCollection.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PersistentCollection.cs 16 Sep 2004 14:03:29 -0000 1.15 --- PersistentCollection.cs 22 Sep 2004 04:46:43 -0000 1.16 *************** *** 123,126 **** --- 123,153 ---- } + /// <summary> + /// Gets or Sets an <see cref="ArrayList"/> of objects that have been placed in the Queue + /// to be added. + /// </summary> + /// <value>An <see cref="ArrayList"/> of objects or null.</value> + protected ArrayList Additions + { + get { return additions; } + set { additions = value; } + } + + /// <summary> + /// Clears out any Queued Additions. + /// </summary> + /// <remarks> + /// After a Flush() the database is in synch with the in-memory + /// contents of the Collection. Since everything is in synch remove + /// any Queued Additions. + /// </remarks> + public virtual void PostFlush() + { + if( additions!=null ) + { + additions.Clear(); + } + } + protected PersistentCollection(ISessionImplementor session) { *************** *** 251,258 **** public abstract ICollection Entries(); - //TODO: determine where this is used - not in H2.0.3 - [Obsolete("Not in H2.0.3 - can't find any usage in NH")] - public abstract void ReadEntries(ICollection entries); - /// <summary> /// Reads the elements Identifier from the reader. --- 278,281 ---- Index: IdentifierBag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/IdentifierBag.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierBag.cs 9 Aug 2004 03:11:45 -0000 1.3 --- IdentifierBag.cs 22 Sep 2004 04:46:43 -0000 1.4 *************** *** 225,234 **** } - [Obsolete("See PersistentCollection.ReadEntries for reason")] - public override void ReadEntries(ICollection entries) - { - throw new NotSupportedException("Should not call..."); - } - public override ICollection Entries() { --- 225,228 ---- |