From: Michael D. <mik...@us...> - 2004-08-28 04:23:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30506/src/NHibernate/Collection Modified Files: CollectionPersister.cs Log Message: Removed all the hacks with expected row count now that batcher is implemented. Index: CollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/CollectionPersister.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** CollectionPersister.cs 19 Aug 2004 17:42:25 -0000 1.26 --- CollectionPersister.cs 28 Aug 2004 04:23:44 -0000 1.27 *************** *** 679,696 **** if (log.IsDebugEnabled ) log.Debug("Deleting collection: " + role + "#" + id); ! //IDbCommand st = session.Batcher.PrepareBatchStatement( SQLDeleteString ); ! IDbCommand st = session.Preparer.PrepareCommand(SqlDeleteString); try { WriteKey(st, id, false, session); ! //TODO: this is hackish for expected row count ! int expectedRowCount = -1; ! int rowCount = st.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(-1); } catch (Exception e) --- 679,688 ---- if (log.IsDebugEnabled ) log.Debug("Deleting collection: " + role + "#" + id); ! IDbCommand st = session.Batcher.PrepareBatchCommand( SqlDeleteString ); try { WriteKey(st, id, false, session); ! session.Batcher.AddToBatch(-1); } catch (Exception e) *************** *** 713,718 **** if (entries.Count > 0) { ! //IDbCommand st = session.Batcher.PrepareBatchStatement( SQLInsertRowString ); ! IDbCommand st = session.Preparer.PrepareCommand(SqlInsertRowString); int i=0; --- 705,709 ---- if (entries.Count > 0) { ! IDbCommand st = session.Batcher.PrepareBatchCommand( SqlInsertRowString ); int i=0; *************** *** 760,764 **** if (entries.Count > 0) { ! IDbCommand st = session.Preparer.PrepareCommand(SqlDeleteRowString); try { --- 751,755 ---- if (entries.Count > 0) { ! IDbCommand st = session.Batcher.PrepareBatchCommand( SqlDeleteRowString ); try { *************** *** 767,778 **** if(!hasIdentifier) WriteKey(st, id, false, session); WriteRowSelect(st, entry, session); ! //TODO: this is hackish for expected row count ! int expectedRowCount = -1; ! int rowCount = st.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(-1); } } --- 758,762 ---- if(!hasIdentifier) WriteKey(st, id, false, session); WriteRowSelect(st, entry, session); ! session.Batcher.AddToBatch(-1); } } *************** *** 802,816 **** if (collection.NeedsUpdating(entry, i, elementType)) { ! if (st==null) st = session.Preparer.PrepareCommand(SqlUpdateRowString); //st = session.Batcher.PrepareBatchStatement( SQLUpdateRowString ); if(!hasIdentifier) WriteKey(st, id, true, session); collection.WriteTo(st, this, entry, i, true); ! //TODO: this is hackish for expected row count ! int expectedRowCount = 1; ! int rowCount = st.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(1); } i++; --- 786,796 ---- if (collection.NeedsUpdating(entry, i, elementType)) { ! if (st==null) ! { ! st = session.Batcher.PrepareBatchCommand( SqlUpdateRowString ); ! } if(!hasIdentifier) WriteKey(st, id, true, session); collection.WriteTo(st, this, entry, i, true); ! session.Batcher.AddToBatch(1); } i++; *************** *** 834,848 **** if (collection.NeedsUpdating(entry, i, elementType) ) { ! if (rmvst==null) rmvst = session.Preparer.PrepareCommand(SqlDeleteRowString);//rmvst = session.Batcher.PrepareBatchStatement( SQLDeleteRowString ); WriteKey(rmvst, id, false, session); WriteIndex(rmvst, collection.GetIndex(entry, i), false, session); ! //TODO: this is hackish for expected row count ! int expectedRowCount = -1; ! int rowCount = rmvst.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(-1); } i++; --- 814,824 ---- if (collection.NeedsUpdating(entry, i, elementType) ) { ! if (rmvst==null) ! { ! rmvst = session.Batcher.PrepareBatchCommand( SqlDeleteRowString ); ! } WriteKey(rmvst, id, false, session); WriteIndex(rmvst, collection.GetIndex(entry, i), false, session); ! session.Batcher.AddToBatch(-1); } i++; *************** *** 851,854 **** --- 827,831 ---- catch(Exception e) { + session.Batcher.AbortBatch( e ); throw e; } *************** *** 865,879 **** if (collection.NeedsUpdating(entry, i, elementType) ) { ! if (insst==null) insst = session.Preparer.PrepareCommand(SqlInsertRowString); //session.Batcher.PrepareBatchStatement( SQLInsertRowString ); WriteKey(insst, id, false, session); collection.WriteTo(insst, this, entry, i, false); ! //TODO: this is hackish for expected row count ! int expectedRowCount = 1; ! int rowCount = insst.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(1); } i++; --- 842,852 ---- if (collection.NeedsUpdating(entry, i, elementType) ) { ! if (insst==null) ! { ! insst = session.Batcher.PrepareBatchCommand( SqlInsertRowString ); ! } WriteKey(insst, id, false, session); collection.WriteTo(insst, this, entry, i, false); ! session.Batcher.AddToBatch(1); } i++; *************** *** 922,936 **** { collection.PreInsert(this, entry, i); //TODO: (Big): this here screws up batching! H2.0.3 comment ! if (st==null) st = session.Preparer.PrepareCommand(SqlInsertRowString); //st = session.Batcher.PrepareBatchStatement(SQLInsertRowString); WriteKey(st, id, false, session); collection.WriteTo(st, this, entry, i, false); ! //TODO: this is hackish for expected row count ! int expectedRowCount = 1; ! int rowCount = st.ExecuteNonQuery(); ! ! //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) ! throw new HibernateException("SQL update or deletion failed (row not found)"); ! //session.Batcher.AddToBatch(1); } i++; --- 895,905 ---- { collection.PreInsert(this, entry, i); //TODO: (Big): this here screws up batching! H2.0.3 comment ! if (st==null) ! { ! st = session.Batcher.PrepareBatchCommand(SqlInsertRowString); ! } WriteKey(st, id, false, session); collection.WriteTo(st, this, entry, i, false); ! session.Batcher.AddToBatch(1); } i++; |