From: Michael D. <mik...@us...> - 2004-08-28 04:26:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/src/NHibernate/Persister Modified Files: EntityPersister.cs NormalizedEntityPersister.cs Log Message: Moved from direct use of Preparer to Batcher Index: NormalizedEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** NormalizedEntityPersister.cs 22 Aug 2004 06:23:40 -0000 1.27 --- NormalizedEntityPersister.cs 28 Aug 2004 04:26:29 -0000 1.28 *************** *** 943,947 **** } ! IDbCommand st = session.Preparer.PrepareCommand((SqlString)lockers[lockMode]); try --- 943,947 ---- } ! IDbCommand st = session.Batcher.PrepareCommand( (SqlString)lockers[lockMode] ); try *************** *** 973,977 **** finally { ! session.Batcher.CloseStatement(st); } } --- 973,977 ---- finally { ! session.Batcher.CloseCommand(st); } } *************** *** 1041,1045 **** for (int i=0; i<tableNames.Length; i++ ) { ! insertCmds[i] = session.Preparer.PrepareCommand(sql[i]); } --- 1041,1045 ---- for (int i=0; i<tableNames.Length; i++ ) { ! insertCmds[i] = session.Batcher.PrepareCommand(sql[i]); } *************** *** 1055,1059 **** } //TODO: change this to SQLException catching and log it ! catch (Exception e) { throw e; --- 1055,1059 ---- } //TODO: change this to SQLException catching and log it ! catch( Exception e ) { throw e; *************** *** 1061,1067 **** finally { ! for (int i=0; i<tableNames.Length; i++) { ! //if (statements[i]!=null) session.Batcher.CloseStatement( statements[i] ); } } --- 1061,1070 ---- finally { ! for( int i=0; i<tableNames.Length; i++ ) { ! if( insertCmds[i]!=null ) ! { ! session.Batcher.CloseCommand( insertCmds[i] ); ! } } } *************** *** 1087,1091 **** object id; ! //TODO: something is really different here. Believe it has to do with Ms Sql Identity Select patch if(dialect.SupportsIdentitySelectInInsert) { --- 1090,1098 ---- object id; ! ! // still using the Preparer instead of Batcher because the Batcher won't work ! // with 2 commands being Prepared back to back - when the second SqlString gets ! // prepared that would cause it to execute the first SqlString - which is not ! // what we want because no values have been put into the parameter. if(dialect.SupportsIdentitySelectInInsert) { *************** *** 1186,1190 **** for (int i=0; i<naturalOrderTableNames.Length; i++) { ! statements[i] = session.Preparer.PrepareCommand(SqlDeleteStrings[i]); } --- 1193,1197 ---- for (int i=0; i<naturalOrderTableNames.Length; i++) { ! statements[i] = session.Batcher.PrepareCommand( SqlDeleteStrings[i] ); } *************** *** 1212,1216 **** for (int i=0; i<naturalOrderTableNames.Length; i++) { ! // if (statements[i]!=null ) session.Batcher.CloseStatement( statements[i] ); } } --- 1219,1223 ---- for (int i=0; i<naturalOrderTableNames.Length; i++) { ! if (statements[i]!=null ) session.Batcher.CloseCommand( statements[i] ); } } *************** *** 1285,1289 **** if ( includeTable[i] ) { ! statements[i] = session.Preparer.PrepareCommand(sql[i]); } } --- 1292,1296 ---- if ( includeTable[i] ) { ! statements[i] = session.Batcher.PrepareCommand( sql[i] ); } } *************** *** 1307,1313 **** finally { ! // for (int i=0; i<tables; i++ ) { ! // if ( statements[i]!=null ) session.Batcher.CloseStatement( statements[i] ); ! // } } } --- 1314,1324 ---- finally { ! for (int i=0; i<tables; i++ ) ! { ! if ( statements[i]!=null ) ! { ! session.Batcher.CloseCommand( statements[i] ); ! } ! } } } Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** EntityPersister.cs 22 Aug 2004 06:23:40 -0000 1.24 --- EntityPersister.cs 28 Aug 2004 04:26:29 -0000 1.25 *************** *** 715,719 **** } ! IDbCommand st = session.Preparer.PrepareCommand((SqlString)lockers[lockMode]); try --- 715,719 ---- } ! IDbCommand st = session.Batcher.PrepareCommand( (SqlString)lockers[lockMode] ); try *************** *** 739,743 **** finally { ! //session.Batcher.CloseStatement(st); } } --- 739,743 ---- finally { ! session.Batcher.CloseCommand(st); } } *************** *** 793,797 **** // Render the SQL query ! IDbCommand insertCmd = session.Preparer.PrepareCommand(sql); try --- 793,797 ---- // Render the SQL query ! IDbCommand insertCmd = session.Batcher.PrepareBatchCommand( sql ); try *************** *** 839,842 **** --- 839,846 ---- IDbCommand idSelect = null; + // still using the Preparer instead of Batcher because the Batcher won't work + // with 2 commands being Prepared back to back - when the second SqlString gets + // prepared that would cause it to execute the first SqlString - which is not + // what we want because no values have been put into the parameter. if(dialect.SupportsIdentitySelectInInsert) { *************** *** 846,851 **** else { ! statement = session.Preparer.PrepareCommand(sql); ! idSelect = session.Preparer.PrepareCommand(SqlIdentitySelect); } --- 850,855 ---- else { ! statement = session.Preparer.PrepareCommand( sql ); ! idSelect = session.Preparer.PrepareCommand( SqlIdentitySelect ); } *************** *** 911,915 **** } ! IDbCommand deleteCmd = session.Preparer.PrepareCommand(SqlDeleteString); try --- 915,929 ---- } ! IDbCommand deleteCmd = null; ! ! if( IsVersioned ) ! { ! deleteCmd = session.Batcher.PrepareCommand( SqlDeleteString ); ! } ! else ! { ! deleteCmd = session.Batcher.PrepareBatchCommand( SqlDeleteString ); ! } ! try *************** *** 923,938 **** { VersionType.NullSafeSet(deleteCmd, version, IdentifierColumnNames.Length, session); } - // when Batcher is brought back to life there is some synch points here... - - Check(deleteCmd.ExecuteNonQuery(), id); - - } ! // TODO: h2.0.3 - add some Sql Exception logging here catch (Exception e) { throw e; } } --- 937,959 ---- { VersionType.NullSafeSet(deleteCmd, version, IdentifierColumnNames.Length, session); + Check(deleteCmd.ExecuteNonQuery(), id); + } + else + { + session.Batcher.AddToBatch(1); } } ! // TODO: h2.0.3 - add some Sql Exception logging here catch (Exception e) { throw e; } + finally + { + if( IsVersioned ) + { + session.Batcher.CloseCommand( deleteCmd ); + } + } } *************** *** 991,995 **** if (!hasUpdateableColumns) return; ! IDbCommand statement = session.Preparer.PrepareCommand(sqlUpdateString); try --- 1012,1025 ---- if (!hasUpdateableColumns) return; ! ! IDbCommand statement = null; ! if( IsVersioned ) ! { ! statement = session.Batcher.PrepareCommand( sqlUpdateString ); ! } ! else ! { ! statement = session.Batcher.PrepareBatchCommand( sqlUpdateString ); ! } try *************** *** 1002,1015 **** { VersionType.NullSafeSet( statement, oldVersion, versionParamIndex, session); } - Check( statement.ExecuteNonQuery(), id ); } ! // TODO: h2.0.3 - add some sql exception logging here catch (Exception e) { throw e; } } --- 1032,1065 ---- { VersionType.NullSafeSet( statement, oldVersion, versionParamIndex, session); + Check( statement.ExecuteNonQuery(), id ); } + else + { + session.Batcher.AddToBatch(1); + } } ! // TODO: h2.0.3 - add some sql exception logging here catch (Exception e) { + if( IsVersioned ) + { + // log an exception here + } + else + { + session.Batcher.AbortBatch(e); + } + throw e; } + finally + { + if( IsVersioned ) + { + session.Batcher.CloseCommand( statement ); + } + } } |