You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Michael D. <mik...@us...> - 2004-08-28 04:57:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1669/src/NHibernate/Util Modified Files: ReflectHelper.cs Log Message: Fixed http://jira.nhibernate.org:8080/browse/NH-82 - a <property> that was mapping a class property of System.String[] was not mapping to SerializableType like h2.0.3. Index: ReflectHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/ReflectHelper.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ReflectHelper.cs 22 Aug 2004 06:26:06 -0000 1.13 --- ReflectHelper.cs 28 Aug 2004 04:57:15 -0000 1.14 *************** *** 64,68 **** public static IType ReflectedPropertyType(System.Type theClass, string name) { ! return TypeFactory.HueristicType( GetGetter(theClass, name).ReturnType.Name ); } --- 64,68 ---- public static IType ReflectedPropertyType(System.Type theClass, string name) { ! return TypeFactory.HueristicType( GetGetter(theClass, name).ReturnType.AssemblyQualifiedName ); } |
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 ); + } + } } |
From: Michael D. <mik...@us...> - 2004-08-28 04:26:07
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30724/src/NHibernate/Loader Modified Files: Loader.cs Log Message: Fixed up some issues with Batcher Index: Loader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/Loader.cs,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Loader.cs 27 Aug 2004 04:13:17 -0000 1.30 --- Loader.cs 28 Aug 2004 04:25:57 -0000 1.31 *************** *** 230,234 **** finally { ! ClosePreparedStatement(st, selection, session); } } --- 230,234 ---- finally { ! ClosePreparedStatement(st, rs, session); } } *************** *** 597,601 **** if(useLimit) sqlString = dialect.GetLimitString(sqlString); ! IDbCommand command = session.Preparer.PrepareCommand(sqlString); try --- 597,601 ---- if(useLimit) sqlString = dialect.GetLimitString(sqlString); ! IDbCommand command = session.Batcher.PrepareQueryCommand( sqlString, scrollable ); try *************** *** 632,638 **** } catch(Exception sqle) { ! ClosePreparedStatement(command, selection, session); throw sqle; } --- 632,639 ---- } + //TODO: fix up the Exception handling here... catch(Exception sqle) { ! ClosePreparedStatement(command, null, session); throw sqle; } *************** *** 675,678 **** --- 676,680 ---- protected IDataReader GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session) { + IDataReader rs = null; try { *************** *** 681,685 **** // of directly executing the reader - the Batcher can be smarter // about when to wrap the IDataReader in an NDataReader ! IDataReader rs = st.ExecuteReader(); //TODO: make this a much smarter implementation that looks at the Type --- 683,687 ---- // of directly executing the reader - the Batcher can be smarter // about when to wrap the IDataReader in an NDataReader ! rs = st.ExecuteReader(); //TODO: make this a much smarter implementation that looks at the Type *************** *** 704,708 **** catch (Exception sqle) { ! ClosePreparedStatement(st, selection, session); throw sqle; } --- 706,710 ---- catch (Exception sqle) { ! ClosePreparedStatement(st, rs, session); throw sqle; } *************** *** 711,723 **** //TODO: H2.0.3 - synch with CloseQueryStatement in the Batcher also ! protected void ClosePreparedStatement(IDbCommand st, RowSelection selection, ISessionImplementor session) { ! try { ! if (selection!=null) { ! //TODO: figure out why this doesn't work for all drivers ! //st.CommandTimeout = 0; ! } ! } finally { ! session.Batcher.CloseQueryStatement(st); ! } } --- 713,719 ---- //TODO: H2.0.3 - synch with CloseQueryStatement in the Batcher also ! protected void ClosePreparedStatement(IDbCommand st, IDataReader reader, ISessionImplementor session) ! { ! session.Batcher.CloseQueryCommand(st, reader); } |
From: Michael D. <mik...@us...> - 2004-08-28 04:24:30
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30596/src/NHibernate/Id Modified Files: SequenceGenerator.cs Log Message: Used to be using Batcher with just a string - changed that to a SqlString. Index: SequenceGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/SequenceGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SequenceGenerator.cs 28 Mar 2004 06:06:40 -0000 1.3 --- SequenceGenerator.cs 28 Aug 2004 04:24:20 -0000 1.4 *************** *** 3,10 **** using System.Collections; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; - using NHibernate.Dialect; --- 3,11 ---- using System.Collections; + using NHibernate.Dialect; using NHibernate.Engine; + using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; *************** *** 41,45 **** public virtual object Generate(ISessionImplementor session, object obj) { ! IDbCommand st = session.Batcher.PrepareStatement(sql); try { --- 42,46 ---- public virtual object Generate(ISessionImplementor session, object obj) { ! IDbCommand st = session.Batcher.PrepareCommand( new SqlString(sql) ); try { *************** *** 65,69 **** finally { ! session.Batcher.CloseStatement(st); } } --- 66,70 ---- finally { ! session.Batcher.CloseCommand(st); } } |
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++; |
From: Michael D. <mik...@us...> - 2004-08-28 04:19:31
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29981/src/NHibernate/Impl Modified Files: SessionImpl.cs Log Message: method renamed in IBatcher Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** SessionImpl.cs 19 Aug 2004 17:48:35 -0000 1.39 --- SessionImpl.cs 28 Aug 2004 04:19:22 -0000 1.40 *************** *** 3504,3508 **** if (connection==null) throw new HibernateException("session already disconnected"); ! if (batcher!=null) batcher.CloseStatements(); IDbConnection c = connection; connection=null; --- 3504,3508 ---- if (connection==null) throw new HibernateException("session already disconnected"); ! if (batcher!=null) batcher.CloseCommands(); IDbConnection c = connection; connection=null; |
From: Michael D. <mik...@us...> - 2004-08-28 04:18:50
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29864/src/NHibernate/Impl Modified Files: BatcherImpl.cs NonBatchingBatcher.cs Log Message: Modified Batcher implementation to be more .net and synched with h2.0.3 Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BatcherImpl.cs 10 Feb 2004 18:31:55 -0000 1.2 --- BatcherImpl.cs 28 Aug 2004 04:18:40 -0000 1.3 *************** *** 1,9 **** using System; - using System.Data; using System.Collections; ! using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> /// Manages prepared statements and batching. Class exists to enfores seperation of concerns --- 1,11 ---- using System; using System.Collections; ! using System.Data; ! using NHibernate.Engine; ! using NHibernate.SqlCommand; + namespace NHibernate.Impl + { /// <summary> /// Manages prepared statements and batching. Class exists to enfores seperation of concerns *************** *** 22,32 **** /// would be because I don't want to even think about writing that code :) /// </summary> ! internal abstract class BatcherImpl : IBatcher { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(BatcherImpl)); ! public static int open; ! protected ISessionImplementor session; ! protected ISessionFactoryImplementor factory; // batchCommand used to be called batchUpdate - that name to me implied that updates --- 24,36 ---- /// would be because I don't want to even think about writing that code :) /// </summary> ! internal abstract class BatcherImpl : IBatcher ! { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(BatcherImpl)); ! private static int openCommandCount; ! private static int openReaderCount; ! protected readonly ISessionImplementor session; ! protected readonly ISessionFactoryImplementor factory; // batchCommand used to be called batchUpdate - that name to me implied that updates *************** *** 34,42 **** // just update. However I haven't seen this being used with read statements... private IDbCommand batchCommand; ! private string batchCommandSQL; ! private ArrayList statementsToClose = new ArrayList(); ! public BatcherImpl(ISessionImplementor session) { this.session = session; this.factory = session.Factory; --- 38,48 ---- // just update. However I haven't seen this being used with read statements... private IDbCommand batchCommand; ! private SqlString batchCommandSql; ! private ArrayList commandsToClose = new ArrayList(); ! private ArrayList readersToClose = new ArrayList(); ! public BatcherImpl(ISessionImplementor session) ! { this.session = session; this.factory = session.Factory; *************** *** 60,183 **** /// </remarks> /// <returns></returns> ! protected IDbCommand GetStatement() { return batchCommand; } ! public IDbCommand PrepareStatement(string sql) { ExecuteBatch(); ! LogOpen(); ! return JoinTransaction( factory.GetPreparedStatement( session.Connection, sql, false) ); } ! public IDbCommand PrepareQueryStatement(string sql) { ! LogOpen(); ! IDbCommand command = factory.GetPreparedStatement( session.Connection, sql, false ); factory.SetFetchSize(command); ! statementsToClose.Add(command); ! return JoinTransaction(command); } ! /// <summary> ! /// Joins the Command to the Transaction and ensures that the Session and IDbCommand are in ! /// the same Transaction. ! /// </summary> ! /// <param name="command">The command to setup the Transaction on.</param> ! /// <returns>A IDbCommand with a valid Transaction property.</returns> ! private IDbCommand JoinTransaction(IDbCommand command) { ! IDbTransaction sessionAdoTrx = null; ! ! // at this point in the code if the Transaction is not null then we know we ! // have a Transaction object that has the .AdoTransaction property. In the future ! // we will have a seperate object to represent an AdoTransaction and won't have a ! // generic Transaction class - the existing Transaction class will become Abstract. ! if(this.session.Transaction!=null) sessionAdoTrx = ((Transaction.Transaction)session.Transaction).AdoTransaction; ! // if the sessionAdoTrx is null then we don't want the command to be a part of ! // any Transaction - so lets set the command trx to null ! if(sessionAdoTrx==null) { ! ! if(command.Transaction!=null) log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction"); ! command.Transaction = null; ! } ! // make sure these are the same transaction - I don't know why we would have a command ! // in a different Transaction than the Session, but I don't understand all of the code ! // well enough yet to verify that. ! else if (sessionAdoTrx!=command.Transaction) { ! // got into here because the command was being initialized and had a null Transaction - probably ! // don't need to be confused by that - just a normal part of initialization... ! log.Warn("The IDbCommand had a different Transaction than the Session. What is going on???"); ! command.Transaction = sessionAdoTrx; } - - return command; - } - - public void CloseQueryStatement(IDbCommand st) { - statementsToClose.Remove(st); - LogClose(); - factory.ClosePreparedStatement(st); - } - - public void CloseStatement(IDbCommand ps) { - LogClose(); - factory.ClosePreparedStatement(ps); } ! public IDbCommand PrepareBatchStatement(string sql) { ! if ( !sql.Equals(batchCommandSQL) ) { ! batchCommand = PrepareStatement(sql); ! batchCommandSQL=sql; } return batchCommand; } ! public void ExecuteBatch() { ! if ( batchCommand!=null ) { IDbCommand ps = batchCommand; batchCommand = null; ! batchCommandSQL = null; ! try { DoExecuteBatch(ps); ! } finally { ! CloseStatement(ps); } } } ! public void CloseStatements() { ! foreach( IDbCommand cmd in statementsToClose ) { ! try { ! CloseStatement(cmd); ! } catch(Exception e) { // no big deal log.Warn("Could not close a JDBC statement", e); } } ! statementsToClose.Clear(); } protected abstract void DoExecuteBatch(IDbCommand ps) ; ! public abstract void AddToBatch(int expectedCount); ! private static void LogOpen() { ! if ( log.IsDebugEnabled ) { ! open++; ! log.Debug( open + " open PreparedStatements" ); } } ! private static void LogClose() { ! if ( log.IsDebugEnabled ) ! open--; } } --- 66,265 ---- /// </remarks> /// <returns></returns> ! protected IDbCommand GetCommand() ! { return batchCommand; } ! public IDbCommand PrepareCommand(SqlString sql) ! { ExecuteBatch(); ! LogOpenPreparedCommands(); ! //return JoinTransaction( factory.GetPreparedStatement( session.Connection, sql, false) ); ! return session.Preparer.PrepareCommand(sql); } ! ! public IDbCommand PrepareQueryCommand(SqlString sql, bool scrollable) ! { ! //TODO: figure out what to do with scrollable - don't think it applies ! // to ado.net since DataReader is forward only ! LogOpenPreparedCommands(); ! IDbCommand command = session.Preparer.PrepareCommand(sql); ! //factory.GetPreparedStatement( session.Connection, sql, false ); + // not sure if this is needed because fetch size doesn't apply factory.SetFetchSize(command); ! commandsToClose.Add(command); ! return command; } ! public void AbortBatch(Exception e) { ! // log the exception here ! IDbCommand cmd = batchCommand; ! batchCommand = null; ! batchCommandSql = null; ! // close the statement closeStatement(cmd) ! } + public IDataReader GetDataReader(IDbCommand cmd) + { + IDataReader reader = cmd.ExecuteReader(); + readersToClose.Add(reader); + LogOpenReaders(); + return reader; + } ! public void CloseQueryCommand(IDbCommand st, IDataReader reader) ! { ! commandsToClose.Remove(st); ! if( reader!=null ) { ! readersToClose.Remove(reader); } ! try { ! if( reader!=null) ! { ! LogCloseReaders(); ! reader.Close(); ! } ! } ! finally ! { ! CloseQueryCommand(st); } } ! public IDbCommand PrepareBatchCommand(SqlString sql) ! { ! if ( !sql.Equals(batchCommandSql) ) ! { ! batchCommand = PrepareCommand(sql); // calls ExecuteBatch() ! batchCommandSql=sql; } return batchCommand; } ! public void ExecuteBatch() ! { ! if ( batchCommand!=null ) ! { IDbCommand ps = batchCommand; batchCommand = null; ! batchCommandSql = null; ! try ! { DoExecuteBatch(ps); ! } ! finally ! { ! CloseCommand(ps); } } } ! public void CloseCommand(IDbCommand cmd) ! { ! LogClosePreparedCommands(); ! // factory.ClosePreparedStatement(cmd); ! } ! ! private void CloseQueryCommand(IDbCommand cmd) ! { ! try ! { ! // no equiv to the java code in here ! } ! catch( Exception e ) ! { ! log.Warn( "exception clearing maxRows/queryTimeout", e ); ! //cmd.close(); if there was a close method in command ! return; // NOTE: early exit! ! } ! ! CloseCommand( cmd ); ! } ! ! public void CloseCommands() ! { ! foreach( IDataReader reader in readersToClose ) ! { ! try ! { ! LogCloseReaders(); ! reader.Close(); ! } ! catch( Exception e ) ! { ! log.Warn( "Could not close IDataReader", e ); ! } ! } ! readersToClose.Clear(); ! ! foreach( IDbCommand cmd in commandsToClose ) ! { ! try ! { ! CloseQueryCommand(cmd); ! } ! catch(Exception e) ! { // no big deal log.Warn("Could not close a JDBC statement", e); } } ! commandsToClose.Clear(); } protected abstract void DoExecuteBatch(IDbCommand ps) ; ! public abstract void AddToBatch(int expectedRowCount); ! protected ISessionFactoryImplementor Factory ! { ! get { return factory; } ! } ! ! protected ISessionImplementor Session ! { ! get { return session; } ! } ! ! private static void LogOpenPreparedCommands() ! { ! if ( log.IsDebugEnabled ) ! { ! log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); ! openCommandCount++; } } ! private static void LogClosePreparedCommands() ! { ! if ( log.IsDebugEnabled ) ! { ! openCommandCount--; ! log.Debug( "done closing: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); ! } ! } ! ! private static void LogOpenReaders() ! { ! if( log.IsDebugEnabled ) ! { ! openReaderCount++; ! } ! } ! ! private static void LogCloseReaders() ! { ! if( log.IsDebugEnabled ) ! { ! openReaderCount--; ! } } } Index: NonBatchingBatcher.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/NonBatchingBatcher.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NonBatchingBatcher.cs 10 Feb 2004 18:31:55 -0000 1.4 --- NonBatchingBatcher.cs 28 Aug 2004 04:18:40 -0000 1.5 *************** *** 7,42 **** /// An implementation of the <c>IBatcher</c> inteface that does no batching /// </summary> ! internal class NonBatchingBatcher : BatcherImpl { ! public NonBatchingBatcher(ISessionImplementor session) : base(session) { } ! ! public override void AddToBatch(int expectedRowCount) { ! ! IDbCommand command = GetStatement(); ! ! // this should not be needed because all commands added to the Batcher should ! // have their Transaction property set. ! // Hack: join transaction ! //Impl.AdoHack.JoinTx(s); ! // end-of Hack ! ! // verify that the commands IDbTransaction and the Session.Transaction.IDbTransaction are the ! // same object ! // TODO: remove this copy and pasted code (in BatcherImpl.JoinTransaction) ! IDbTransaction sessionAdoTrx = null; ! if(this.session.Transaction!=null) sessionAdoTrx = ((Transaction.Transaction)session.Transaction).AdoTransaction; ! ! if(command.Transaction!= sessionAdoTrx) ! throw new HibernateException("In NonBatchingBatcher.AddToBatch there is a Command's IDbTransaction that is different than the Session.Transaction.AdoTransaction"); ! ! int rowCount = command.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)"); } ! protected override void DoExecuteBatch(IDbCommand ps) { } --- 7,30 ---- /// An implementation of the <c>IBatcher</c> inteface that does no batching /// </summary> ! internal class NonBatchingBatcher : BatcherImpl ! { ! public NonBatchingBatcher(ISessionImplementor session) : base(session) ! { ! } ! public override void AddToBatch(int expectedRowCount) ! { ! int rowCount = GetCommand().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)"); + } } ! protected override void DoExecuteBatch(IDbCommand ps) ! { } |
From: Michael D. <mik...@us...> - 2004-08-28 04:18:49
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29864/src/NHibernate/Engine Modified Files: IBatcher.cs Log Message: Modified Batcher implementation to be more .net and synched with h2.0.3 Index: IBatcher.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/IBatcher.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IBatcher.cs 10 Feb 2004 18:30:20 -0000 1.2 --- IBatcher.cs 28 Aug 2004 04:18:40 -0000 1.3 *************** *** 2,24 **** using System.Data; ! namespace NHibernate.Engine { /// <summary> /// Manages <c>IDbCommand</c>s for a session. /// </summary> /// <remarks> ! /// Abstracts ADO.NET batching to maintain the illusion ! /// that a single logical batch exists for the whole session, even when batching is disabled. /// Provides transparent <c>IDbCommand</c> caching. ! /// ! /// TODO: DESIGNQUESTION: we might want to use this to tie together the Connection.IConnection and Transaction.ITransaction because ! /// of how closely ADO.NET ties together the IDbConnection and IDbTransaction and IDbCommand - namely that creating ! /// a IDbCommand from an IDbConnection doesn't automattically give it the IDbTransaction. /// </remarks> ! public interface IBatcher { ! /// <summary> /// Get a prepared statement for using in loading / querying. /// </summary> /// <remarks> /// If not explicitly released by <c>CloseQueryStatement()</c>, it will be --- 2,31 ---- using System.Data; ! using NHibernate.SqlCommand; + namespace NHibernate.Engine + { /// <summary> /// Manages <c>IDbCommand</c>s for a session. /// </summary> /// <remarks> ! /// <para> ! /// Abstracts ADO.NET batching to maintain the illusion that a single logical batch ! /// exists for the whole session, even when batching is disabled. /// Provides transparent <c>IDbCommand</c> caching. ! /// </para> ! /// <para> ! /// This will be useful once ADO.NET gets support for batching. Until that point ! /// no code exists that will do batching, but this will provide a good point to do ! /// error checking and making sure the correct number of rows were affected. ! /// </para> /// </remarks> ! public interface IBatcher ! { /// <summary> /// Get a prepared statement for using in loading / querying. /// </summary> + /// <param name="sql"></param> + /// <param name="scrollable">TODO: not sure how to use this yet</param> /// <remarks> /// If not explicitly released by <c>CloseQueryStatement()</c>, it will be *************** *** 28,38 **** /// does NOT cause the batch to execute... /// </remarks> ! IDbCommand PrepareQueryStatement(string sql); /// <summary> /// Closes a command opened with <c>PrepareQueryStatement</c> /// </summary> ! /// <param name="db"></param> ! void CloseQueryStatement(IDbCommand cm); /// <summary> --- 35,51 ---- /// does NOT cause the batch to execute... /// </remarks> ! IDbCommand PrepareQueryCommand(SqlString sql, bool scrollable); + // TODO: how applicable is this???? /// <summary> /// Closes a command opened with <c>PrepareQueryStatement</c> /// </summary> ! /// <param name="cmd"></param> ! /// <param name="reader"></param> ! /// <remarks> ! /// TODO: Not sure this is needed - with jdbc you can close a statement - does this ! /// have an equivalent of Disposing and IDbCommand??? ! /// </remarks> ! void CloseQueryCommand(IDbCommand cmd, IDataReader reader); /// <summary> *************** *** 40,52 **** /// Must be explicitly released by <c>CloseStatement()</c> /// </summary> ! /// <param name="sql"></param> /// <returns></returns> ! IDbCommand PrepareStatement(string sql); /// <summary> ! /// Close a prepared statement opened using <c>PrepareStatement()</c> /// </summary> /// <param name="cm"></param> ! void CloseStatement(IDbCommand cm); /// <summary> --- 53,66 ---- /// Must be explicitly released by <c>CloseStatement()</c> /// </summary> ! /// <param name="sql">The SqlString to convert to an IDbCommand.</param> /// <returns></returns> ! IDbCommand PrepareCommand(SqlString sql); + //TODO: how applicable is this??? /// <summary> ! /// Close a IDbCommand opened using <c>PrepareStatement()</c> /// </summary> /// <param name="cm"></param> ! void CloseCommand(IDbCommand cm); /// <summary> *************** *** 60,64 **** /// <param name="sql"></param> /// <returns></returns> ! IDbCommand PrepareBatchStatement(string sql); /// <summary> --- 74,78 ---- /// <param name="sql"></param> /// <returns></returns> ! IDbCommand PrepareBatchCommand(SqlString sql); /// <summary> *************** *** 67,70 **** --- 81,88 ---- /// </summary> /// <param name="expectedRowCount"></param> + /// <remarks> + /// A negative number in expectedRowCount means that you don't know how many rows to + /// expect. + /// </remarks> void AddToBatch(int expectedRowCount); *************** *** 74,81 **** void ExecuteBatch(); /// <summary> /// Close any query statements that were left lying around /// </summary> ! void CloseStatements(); } } --- 92,109 ---- void ExecuteBatch(); + // TODO: how applicable is this??? /// <summary> /// Close any query statements that were left lying around /// </summary> ! void CloseCommands(); ! ! IDataReader GetDataReader(IDbCommand cmd); ! ! /// <summary> ! /// Must be called when an exception occurs. ! /// </summary> ! /// <param name="e"></param> ! void AbortBatch(Exception e); ! } } |
From: Michael D. <mik...@us...> - 2004-08-28 04:15:23
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29479/src/NHibernate/Engine Modified Files: ISessionFactoryImplementor.cs Log Message: Added property to get IsolationLevel Index: ISessionFactoryImplementor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/ISessionFactoryImplementor.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ISessionFactoryImplementor.cs 29 Mar 2004 04:06:09 -0000 1.6 --- ISessionFactoryImplementor.cs 28 Aug 2004 04:15:12 -0000 1.7 *************** *** 8,18 **** using NHibernate.Type; ! namespace NHibernate.Engine { /// <summary> /// Defines the internal contract between the <c>ISessionFactory</c> and other parts of NHibernate /// such as implementors of <c>IType</c>. /// </summary> ! public interface ISessionFactoryImplementor : IMapping, ISessionFactory { ! /// <summary> /// TODO: determine if this is more appropriate for ISessionFactory --- 8,19 ---- using NHibernate.Type; ! namespace NHibernate.Engine ! { /// <summary> /// Defines the internal contract between the <c>ISessionFactory</c> and other parts of NHibernate /// such as implementors of <c>IType</c>. /// </summary> ! public interface ISessionFactoryImplementor : IMapping, ISessionFactory ! { /// <summary> /// TODO: determine if this is more appropriate for ISessionFactory *************** *** 20,24 **** IConnectionProvider ConnectionProvider {get;} ! /// <summary> /// Get the persister for a class --- 21,32 ---- IConnectionProvider ConnectionProvider {get;} ! /// <summary> ! /// Gets the IsolationLevel an IDbTransaction should be set to. ! /// </summary> ! /// <remarks> ! /// This is only applicable to manually controlled NHibernate Transactions. ! /// </remarks> ! IsolationLevel Isolation { get; } ! /// <summary> /// Get the persister for a class |
From: Michael D. <mik...@us...> - 2004-08-28 04:14:09
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29299/src/NHibernate/Connection Modified Files: ConnectionProvider.cs Log Message: Minor formatting changes made while working on other code. Index: ConnectionProvider.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Connection/ConnectionProvider.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConnectionProvider.cs 24 Jul 2004 20:43:22 -0000 1.5 --- ConnectionProvider.cs 28 Aug 2004 04:14:01 -0000 1.6 *************** *** 38,42 **** public virtual void Configure(IDictionary settings) { ! log.Info("Configuring ConnectionProvider"); // default the poolSize to 0 if no setting was made because most of the .net DataProvider --- 38,42 ---- public virtual void Configure(IDictionary settings) { ! log.Info( "Configuring ConnectionProvider" ); // default the poolSize to 0 if no setting was made because most of the .net DataProvider *************** *** 44,52 **** // if the .net DataProvider did not provide their own connection pooling. I don't know of // any instances of this yet. ! poolSize = PropertiesHelper.GetInt32(Cfg.Environment.PoolSize, settings, 0); ! log.Info("NHibernate connection pool size: " + poolSize); connString = settings[ Cfg.Environment.ConnectionString ] as string; ! if (connString==null) throw new HibernateException("Could not find connection string setting"); ConfigureDriver(settings); --- 44,55 ---- // if the .net DataProvider did not provide their own connection pooling. I don't know of // any instances of this yet. ! poolSize = PropertiesHelper.GetInt32( Cfg.Environment.PoolSize, settings, 0 ); ! log.Info( "NHibernate connection pool size: " + poolSize ); connString = settings[ Cfg.Environment.ConnectionString ] as string; ! if (connString==null) ! { ! throw new HibernateException("Could not find connection string setting"); ! } ConfigureDriver(settings); |
From: Michael D. <mik...@us...> - 2004-08-28 04:08:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28637/src/NHibernate/Cfg Modified Files: Environment.cs Log Message: This was ported code that was not needed. The enum IsolationLevel already converts itself to a nice friendly name. Index: Environment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Environment.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Environment.cs 20 Jul 2004 13:52:52 -0000 1.15 --- Environment.cs 28 Aug 2004 04:08:43 -0000 1.16 *************** *** 31,36 **** private static IDictionary properties = new Hashtable(); ! private static IDictionary isolationLevels = new Hashtable(); ! private const string Version = "prealpha"; --- 31,35 ---- private static IDictionary properties = new Hashtable(); ! private const string Version = "prealpha"; *************** *** 63,72 **** log4net.Config.DOMConfigurator.Configure(); - isolationLevels.Add( System.Data.IsolationLevel.Chaos, "NONE" ); - isolationLevels.Add( System.Data.IsolationLevel.ReadUncommitted, "READ_UNCOMMITTED" ); - isolationLevels.Add( System.Data.IsolationLevel.ReadCommitted, "READ_COMMITTED" ); - isolationLevels.Add( System.Data.IsolationLevel.RepeatableRead, "REPEATABLE_READ" ); - isolationLevels.Add( System.Data.IsolationLevel.Serializable, "SERIALIZABLE" ); - NameValueCollection props = System.Configuration.ConfigurationSettings.GetConfig("nhibernate") as NameValueCollection; if (props==null) --- 62,65 ---- |
From: Michael D. <mik...@us...> - 2004-08-28 04:07:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28447/src/NHibernate/Impl Modified Files: SessionFactoryImpl.cs Log Message: Added code so BeginTransaction(IsolationLevel) works with hibernate.connection.isolation configuration Index: SessionFactoryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** SessionFactoryImpl.cs 19 Aug 2004 17:48:35 -0000 1.27 --- SessionFactoryImpl.cs 28 Aug 2004 04:07:04 -0000 1.28 *************** *** 77,80 **** --- 77,81 ---- [NonSerialized] private bool showSql; [NonSerialized] private bool useOuterJoin; + [NonSerialized] private IsolationLevel isolation; // TODO: figure out why this is commented out in nh and not h2.0.3 //[NonSerialized] private Templates templates; *************** *** 145,148 **** --- 146,173 ---- log.Info("use outer join fetching: " + useOuterJoin); + // default the isolationLevel to Unspecified to indicate to our code that no isolation level + // has been set so just use the default of the DataProvider. + string isolationString = PropertiesHelper.GetString( Cfg.Environment.Isolation, properties, String.Empty ); + if( isolationString!=String.Empty ) + { + try + { + isolation = (IsolationLevel)Enum.Parse( typeof(IsolationLevel), isolationString ); + log.Info( "Using Isolation Level: " + isolation.ToString() ); + } + catch( ArgumentException ae ) + { + log.Error( "error configuring IsolationLevel " + isolationString, ae ); + throw new HibernateException( + "The isolation level of " + isolationString + " is not a valid IsolationLevel. Please " + + "use one of the Member Names from the IsolationLevel.", ae ); + } + } + else + { + isolation = IsolationLevel.Unspecified; + } + + bool usrs = PropertiesHelper.GetBoolean(Cfg.Environment.UseScrollableResultSet, properties); int batchSize = PropertiesHelper.GetInt32(Cfg.Environment.StatementBatchSize, properties, 0); *************** *** 395,398 **** --- 420,428 ---- } + public IsolationLevel Isolation + { + get { return isolation; } + } + public QueryTranslator GetQuery(string query) { |
From: Michael D. <mik...@us...> - 2004-08-28 04:07:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28447/src/NHibernate/Transaction Modified Files: Transaction.cs Log Message: Added code so BeginTransaction(IsolationLevel) works with hibernate.connection.isolation configuration Index: Transaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/Transaction.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Transaction.cs 10 Feb 2004 18:40:53 -0000 1.2 --- Transaction.cs 28 Aug 2004 04:07:05 -0000 1.3 *************** *** 1,7 **** using System; using System.Data; - using NHibernate.Engine; - namespace NHibernate.Transaction { /// <summary> /// Wraps an ADO.NET transaction to implements the <c>ITransaction</c> interface --- 1,8 ---- using System; using System.Data; + using NHibernate.Engine; + namespace NHibernate.Transaction + { /// <summary> /// Wraps an ADO.NET transaction to implements the <c>ITransaction</c> interface *************** *** 12,16 **** /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Transaction)); private ISessionImplementor session; --- 13,18 ---- /// for JDBC Transactions or JTA Transactions. /// </remarks> ! public class Transaction : ITransaction ! { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Transaction)); private ISessionImplementor session; *************** *** 20,37 **** private bool rolledBack; ! public Transaction(ISessionImplementor session) { this.session = session; } ! public IDbTransaction AdoTransaction { get { return trans; } } ! public void Begin() { log.Debug("begin"); ! try { ! trans = session.Connection.BeginTransaction(); ! } catch (Exception e) { log.Error("Begin transaction failed", e); throw new TransactionException("Begin failed with SQL exception", e); --- 22,53 ---- private bool rolledBack; ! public Transaction(ISessionImplementor session) ! { this.session = session; } ! public IDbTransaction AdoTransaction ! { get { return trans; } } ! public void Begin() ! { log.Debug("begin"); ! try ! { ! IsolationLevel isolation = session.Factory.Isolation; ! if( isolation==IsolationLevel.Unspecified ) ! { ! trans = session.Connection.BeginTransaction(); ! } ! else ! { ! trans = session.Connection.BeginTransaction( isolation ); ! } ! } ! catch( Exception e ) ! { log.Error("Begin transaction failed", e); throw new TransactionException("Begin failed with SQL exception", e); *************** *** 41,83 **** } ! public void Commit() { ! if (!begun) throw new TransactionException("Transaction not successfully started"); log.Debug("commit"); ! try { ! if ( session.FlushMode != FlushMode.Never ) session.Flush(); ! try { trans.Commit(); committed = true; ! } catch (Exception e) { log.Error("Commit failed", e); throw new TransactionException("Commit failed with SQL exception", e); } ! } finally { session.AfterTransactionCompletion(); } } ! public void Rollback() { ! if (!begun) throw new TransactionException("Transaction not successfully started"); log.Debug("rollback"); ! try { trans.Rollback(); rolledBack = true; ! } catch(Exception e) { log.Error("Rollback failed", e); throw new TransactionException("Rollback failed with SQL Exception", e); ! } finally { session.AfterTransactionCompletion(); } } ! public bool WasRolledBack { get { return rolledBack; } } ! public bool WasCommitted { get { return committed; } } --- 57,123 ---- } ! public void Commit() ! { ! if (!begun) ! { ! throw new TransactionException("Transaction not successfully started"); ! } log.Debug("commit"); ! try ! { ! if( session.FlushMode!=FlushMode.Never ) ! { ! session.Flush(); ! } ! try ! { trans.Commit(); committed = true; ! } ! catch( Exception e ) ! { log.Error("Commit failed", e); throw new TransactionException("Commit failed with SQL exception", e); } ! } ! finally ! { session.AfterTransactionCompletion(); } } ! public void Rollback() ! { ! if (!begun) ! { ! throw new TransactionException("Transaction not successfully started"); ! } log.Debug("rollback"); ! try ! { trans.Rollback(); rolledBack = true; ! } ! catch( Exception e ) ! { log.Error("Rollback failed", e); throw new TransactionException("Rollback failed with SQL Exception", e); ! } ! finally ! { session.AfterTransactionCompletion(); } } ! public bool WasRolledBack ! { get { return rolledBack; } } ! public bool WasCommitted ! { get { return committed; } } |
From: Michael D. <mik...@us...> - 2004-08-27 13:30:58
|
Update of /cvsroot/nhibernate/nhibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10857 Modified Files: releasenotes.txt Log Message: updated with latest change Index: releasenotes.txt =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/releasenotes.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** releasenotes.txt 25 Aug 2004 04:16:38 -0000 1.9 --- releasenotes.txt 27 Aug 2004 13:30:47 -0000 1.10 *************** *** 15,18 **** --- 15,19 ---- - Added "access" attribute for NHibernate to get to fields and properties with no setters. See NHibernate.Property.PropertyAccessorFactory for all valid value types and how to plug in your own implementation of IPropertyAccessor. - Added Types to read BLOB/CLOB columns to a byte[]/string Property. + - TypeFactory was modified to allow the attribute "type" to be the Assembly Qualified Name, Full Name, NHibernate IType.Name, or Hibernate name to help with porting hibernate hbm.xml files and Net2Hbm that John is writing. PreAlpha Build 0.1.0.0 |
From: Michael D. <mik...@us...> - 2004-08-27 13:30:08
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10632/src/NHibernate.DomainModel Modified Files: ABC.hbm.xml Log Message: Modified to test NH-86 Index: ABC.hbm.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/ABC.hbm.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ABC.hbm.xml 11 Jul 2004 21:07:24 -0000 1.7 --- ABC.hbm.xml 27 Aug 2004 13:29:57 -0000 1.8 *************** *** 51,54 **** --- 51,55 ---- name="Address" column="c2" + type="System.String" /> </subclass> |
From: Michael D. <mik...@us...> - 2004-08-27 04:21:43
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CfgTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5704/NHibernate.Test/CfgTest Modified Files: ConfigurationFixture.cs Log Message: modifed cfg.xml file slightly so I could make extra, extra sure that it was pulling from there and not the app.config settings. Index: ConfigurationFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/CfgTest/ConfigurationFixture.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConfigurationFixture.cs 27 Jul 2004 03:23:58 -0000 1.6 --- ConfigurationFixture.cs 27 Aug 2004 04:21:22 -0000 1.7 *************** *** 29,33 **** Assert.AreEqual( "true 1, false 0, yes 'Y', no 'N'", cfg.Properties[Cfg.Environment.QuerySubstitutions]); ! Assert.AreEqual( "Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI", cfg.Properties[Cfg.Environment.ConnectionString]); } --- 29,33 ---- Assert.AreEqual( "true 1, false 0, yes 'Y', no 'N'", cfg.Properties[Cfg.Environment.QuerySubstitutions]); ! Assert.AreEqual( "Server=localhost;initial catalog=nhibernate;User Id=;Password=", cfg.Properties[Cfg.Environment.ConnectionString]); } |
From: Michael D. <mik...@us...> - 2004-08-27 04:21:43
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5704/NHibernate.Test Modified Files: hibernate.cfg.xml Log Message: modifed cfg.xml file slightly so I could make extra, extra sure that it was pulling from there and not the app.config settings. Index: hibernate.cfg.xml =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/hibernate.cfg.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hibernate.cfg.xml 26 Jul 2004 12:38:47 -0000 1.4 --- hibernate.cfg.xml 27 Aug 2004 04:21:22 -0000 1.5 *************** *** 5,9 **** <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> ! <property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI</property> <property name="show_sql">false</property> <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> --- 5,9 ---- <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property> ! <property name="connection.connection_string">Server=localhost;initial catalog=nhibernate;User Id=;Password=</property> <property name="show_sql">false</property> <property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property> |
From: Michael D. <mik...@us...> - 2004-08-27 04:14:28
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4733/Impl Modified Files: EnumerableImpl.cs Log Message: Cleaned up the implementation details in the class. Index: EnumerableImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EnumerableImpl.cs 29 Mar 2004 04:03:17 -0000 1.3 --- EnumerableImpl.cs 27 Aug 2004 04:14:19 -0000 1.4 *************** *** 13,17 **** /// This is the IteratorImpl in H2.0.3 /// </remarks> - //TODO: revisit this class and make sure the port is what is intended internal class EnumerableImpl : IEnumerable, IEnumerator { --- 13,16 ---- *************** *** 22,36 **** private IType[] types; private bool single; - private object[] nextResults; private object[] currentResults; private bool hasNext; private string[][] names; ! private IDbCommand ps; ! //TODO: H2.0.3 change ctor to include ps ! public EnumerableImpl(IDataReader rs, ISessionImplementor sess, IType[] types, string[][] columnNames) { this.rs = rs; ! //this.ps = ps; this.sess = sess; this.types = types; --- 21,33 ---- private IType[] types; private bool single; private object[] currentResults; private bool hasNext; private string[][] names; ! private IDbCommand cmd; ! public EnumerableImpl(IDataReader rs, IDbCommand cmd, ISessionImplementor sess, IType[] types, string[][] columnNames) { this.rs = rs; ! this.cmd = cmd; this.sess = sess; this.types = types; *************** *** 38,63 **** single = types.Length==1; - - //TODO: find out if we do need to move to the NextResult right away. - //PostNext(rs.NextResult()); } ! private void PostNext(bool hasNext) { this.hasNext = hasNext; if (!hasNext) { log.Debug("exhausted results"); ! nextResults = null; rs.Close(); //TODO: H2.0.3 code to synch here to close the QueryStatement } else { log.Debug("retreiving next results"); ! nextResults = new object[types.Length]; for (int i=0; i<types.Length; i++) { ! nextResults[i] = types[i].NullSafeGet(rs, names[i], sess, null); } } --- 35,60 ---- single = types.Length==1; } ! private void PostMoveNext(bool hasNext) { this.hasNext = hasNext; + + // there are no more records in the DataReader so clean up if (!hasNext) { log.Debug("exhausted results"); ! currentResults = null; rs.Close(); //TODO: H2.0.3 code to synch here to close the QueryStatement + //sess.Batcher.CloseQueryStatement( cmd, rs ); } else { log.Debug("retreiving next results"); ! currentResults = new object[types.Length]; for (int i=0; i<types.Length; i++) { ! currentResults[i] = types[i].NullSafeGet(rs, names[i], sess, null); } } *************** *** 77,85 **** if (single) { ! return nextResults[0]; } else { ! return nextResults; } } --- 74,82 ---- if (single) { ! return currentResults[0]; } else { ! return currentResults; } } *************** *** 88,97 **** public bool MoveNext() { ! PostNext(rs.Read()); return hasNext; } ! public void Reset() { //can't reset the reader...we are SOL } --- 85,95 ---- public bool MoveNext() { ! PostMoveNext( rs.Read() ); return hasNext; } ! public void Reset() ! { //can't reset the reader...we are SOL } |
From: Michael D. <mik...@us...> - 2004-08-27 04:13:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4516/Hql Modified Files: QueryTranslator.cs Log Message: Changed Loader.GetResultSet() method to protected so I coud call the method in QueryTranslator Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** QueryTranslator.cs 20 Aug 2004 17:39:02 -0000 1.41 --- QueryTranslator.cs 27 Aug 2004 04:13:17 -0000 1.42 *************** *** 930,962 **** sqlWithLock, values, types, namedParams, selection, false, session); ! try ! { ! SetMaxRows(st, selection); ! ! //TODO: H2.0.3 - uses session.Batcher.GetResultSet(st) instead ! // of directly executing the reader - the Batcher can be smarter ! // about when to wrap the IDataReader in an NDataReader ! IDataReader rs = st.ExecuteReader(); ! ! //TODO: make this a much smarter implementation that looks at the Type ! // that is being loaded and determines wether or not to wrap this IDataReader ! // in a NDataReader. I believe the problem of multiple readers being opened ! // are occuring in <composite-id> with <many-to-one> and <component> with ! // a <collection>, <many-to-one>, and <one-to-one> inside of them. I believe ! // this is caused when the NullSafeGet() method calls other methods that can ! // potentially perform a Load of another object. ! if(!session.Factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders) ! { ! rs = new Driver.NDataReader(rs); ! } ! ! Advance(rs, selection, session); ! return new EnumerableImpl(rs, session, ReturnTypes, ScalarColumnNames ); ! } ! catch (Exception e) ! { ! ClosePreparedStatement(st, selection, session); ! throw e; ! } } --- 930,937 ---- sqlWithLock, values, types, namedParams, selection, false, session); ! ! IDataReader rs = GetResultSet( st, selection, session ); ! return new EnumerableImpl(rs, st, session, ReturnTypes, ScalarColumnNames ); ! } |
From: Michael D. <mik...@us...> - 2004-08-27 04:13:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4516/Loader Modified Files: Loader.cs Log Message: Changed Loader.GetResultSet() method to protected so I coud call the method in QueryTranslator Index: Loader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/Loader.cs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Loader.cs 20 Aug 2004 15:31:37 -0000 1.29 --- Loader.cs 27 Aug 2004 04:13:17 -0000 1.30 *************** *** 673,677 **** /// <param name="session"></param> /// <returns></returns> ! private IDataReader GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session) { try --- 673,677 ---- /// <param name="session"></param> /// <returns></returns> ! protected IDataReader GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session) { try |
From: Michael D. <mik...@us...> - 2004-08-26 14:28:53
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14918/NHibernate.Test/SqlCommandTest Modified Files: SqlStringFixture.cs Log Message: Added test for SQLExpression and new method in SqlString Index: SqlStringFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/SqlCommandTest/SqlStringFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SqlStringFixture.cs 20 Aug 2004 15:26:23 -0000 1.3 --- SqlStringFixture.cs 26 Aug 2004 14:28:44 -0000 1.4 *************** *** 173,176 **** --- 173,195 ---- [Test] + public void Replace() + { + SqlString sql = new SqlString( new object[] {"select ", "from table ", "where a = ", new Parameter(), " and c = ", new Parameter() } ); + + SqlString replacedSql = sql.Replace( "table", "replacedTable" ); + Assert.AreEqual( "select from replacedTable where a = ", replacedSql.SqlParts[0], "replaced single instance" ); + + replacedSql = sql.Replace( "not found", "not in here" ); + Assert.AreEqual( sql.ToString(), replacedSql.ToString(), "replace no found string" ); + + replacedSql = sql.Replace( "le", "LE" ); + Assert.AreEqual( "seLEct from tabLE where a = ", replacedSql.SqlParts[0], "multi-match replace" ); + Assert.IsTrue( replacedSql.SqlParts[1] is Parameter, "multi-match replace - Param 1" ); + Assert.AreEqual(" and c = ", replacedSql.SqlParts[2], "multi-match replace" ); + Assert.IsTrue( replacedSql.SqlParts[3] is Parameter, "multi-match replace - Param 2" ); + + } + + [Test] public void StartsWith() { |
From: Michael D. <mik...@us...> - 2004-08-26 14:28:53
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/ExpressionTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14918/NHibernate.Test/ExpressionTest Added Files: SQLExpressionFixture.cs Log Message: Added test for SQLExpression and new method in SqlString --- NEW FILE: SQLExpressionFixture.cs --- using System; using NHibernate.SqlCommand; using NExpression = NHibernate.Expression; using NHibernate.DomainModel; using NUnit.Framework; namespace NHibernate.Test.ExpressionTest { /// <summary> /// Summary description for SQLExpressionFixture. /// </summary> [TestFixture] public class SQLExpressionFixture : BaseExpressionFixture { [Test] public void StraightSqlTest() { ISession session = factory.OpenSession(); NExpression.Expression sqlExpression = NExpression.Expression.Sql("$alias.address is not null"); SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address is not null"; CompareSqlStrings(sqlString, expectedSql); session.Close(); } [Test] public void NoParamsSqlStringTest() { ISession session = factory.OpenSession(); NExpression.Expression sqlExpression = NExpression.Expression.Sql( new SqlString( "$alias.address is not null") ); SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); string expectedSql = "simple_alias.address is not null"; CompareSqlStrings(sqlString, expectedSql); session.Close(); } [Test] public void WithParameterTest() { ISession session = factory.OpenSession(); SqlStringBuilder builder = new SqlStringBuilder(); string expectedSql = "simple_alias.address = :address"; Parameter[] expectedParams = new Parameter[1]; Parameter firstAndParam = new Parameter(); firstAndParam.SqlType = new SqlTypes.StringSqlType(); firstAndParam.Name = "address"; expectedParams[0] = firstAndParam; builder.Add( "$alias.address = " ); builder.Add( firstAndParam ); NExpression.Expression sqlExpression = NExpression.Expression.Sql(builder.ToSqlString(), "some address", NHibernate.String ); SqlString sqlString = sqlExpression.ToSqlString(factoryImpl, typeof(Simple), "simple_alias"); CompareSqlStrings(sqlString, expectedSql, expectedParams); session.Close(); } } } |
From: Michael D. <mik...@us...> - 2004-08-26 14:28:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14918/NHibernate.Test Modified Files: NHibernate.Test-1.1.csproj Log Message: Added test for SQLExpression and new method in SqlString Index: NHibernate.Test-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHibernate.Test-1.1.csproj,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** NHibernate.Test-1.1.csproj 25 Aug 2004 04:06:59 -0000 1.37 --- NHibernate.Test-1.1.csproj 26 Aug 2004 14:28:43 -0000 1.38 *************** *** 302,305 **** --- 302,310 ---- /> <File + RelPath = "ExpressionTest\SQLExpressionFixture.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NHSpecificTest\BasicBinaryFixture.cs" SubType = "Code" |
From: Michael D. <mik...@us...> - 2004-08-26 14:28:28
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14868/NHibernate/Expression Modified Files: Expression.cs SQLExpression.cs Log Message: Modified SQLExpression so the user must specify a SqlString if there are any parameters required. Index: SQLExpression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/SQLExpression.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SQLExpression.cs 28 Mar 2004 06:05:09 -0000 1.6 --- SQLExpression.cs 26 Aug 2004 14:28:18 -0000 1.7 *************** *** 6,20 **** using NHibernate.Util; ! namespace NHibernate.Expression { ! /// <summary> ! /// SQLExpression /// </summary> ! public class SQLExpression : Expression { ! private readonly string sql; private readonly TypedValue[] typedValues; ! internal SQLExpression(string sql, object[] values, IType[] types) { this.sql = sql; --- 6,25 ---- using NHibernate.Util; ! namespace NHibernate.Expression ! { /// <summary> ! /// Creates a SQLExpression /// </summary> ! /// <remarks> ! /// This allows for database specific Expressions at the cost of needing to ! /// write a correct <see cref="SqlString"/>. ! /// </remarks> ! public class SQLExpression : Expression ! { ! private readonly SqlString sql; private readonly TypedValue[] typedValues; ! internal SQLExpression(SqlString sql, object[] values, IType[] types) { this.sql = sql; *************** *** 29,33 **** public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias) { ! return new SqlString(StringHelper.Replace(sql, "$alias", alias)); } --- 34,38 ---- public override SqlString ToSqlString(ISessionFactoryImplementor factory, System.Type persistentClass, string alias) { ! return sql.Replace( "$alias", alias ); } *************** *** 39,43 **** public override string ToString() { ! return sql; } } --- 44,48 ---- public override string ToString() { ! return sql.ToString(); } } Index: Expression.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Expression/Expression.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Expression.cs 2 Aug 2004 04:30:37 -0000 1.9 --- Expression.cs 26 Aug 2004 14:28:18 -0000 1.10 *************** *** 230,234 **** /// <param name="types"></param> /// <returns></returns> ! public static Expression Sql(string sql, object[] values, IType[] types) { return new SQLExpression(sql, values, types); --- 230,234 ---- /// <param name="types"></param> /// <returns></returns> ! public static Expression Sql(SqlString sql, object[] values, IType[] types) { return new SQLExpression(sql, values, types); *************** *** 242,246 **** /// <param name="type"></param> /// <returns></returns> ! public static Expression Sql(string sql, object value, IType type) { return new SQLExpression(sql, new object[] { value }, new IType[] { type } ); --- 242,246 ---- /// <param name="type"></param> /// <returns></returns> ! public static Expression Sql(SqlString sql, object value, IType type) { return new SQLExpression(sql, new object[] { value }, new IType[] { type } ); *************** *** 252,260 **** /// <param name="sql"></param> /// <returns></returns> ! public static Expression Sql(string sql) { return new SQLExpression(sql, NoObjects, NoTypes); } /// <summary> --- 252,270 ---- /// <param name="sql"></param> /// <returns></returns> ! public static Expression Sql(SqlString sql) { return new SQLExpression(sql, NoObjects, NoTypes); } + /// <summary> + /// Apply a constraint expressed in SQL + /// </summary> + /// <param name="sql"></param> + /// <returns></returns> + public static Expression Sql(string sql) + { + return new SQLExpression(new SqlString(sql), NoObjects, NoTypes); + } + /// <summary> |
From: Michael D. <mik...@us...> - 2004-08-26 14:27:53
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14770/NHibernate/SqlCommand Modified Files: SqlString.cs Log Message: Added a Replace method for SQLExpression to use. Index: SqlString.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlString.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SqlString.cs 20 Aug 2004 15:26:24 -0000 1.12 --- SqlString.cs 26 Aug 2004 14:27:43 -0000 1.13 *************** *** 201,204 **** --- 201,235 ---- } + + /// <summary> + /// Replaces all occurrences of a specified <see cref="String"/> in this instance, + /// with another specified <see cref="String"/> . + /// </summary> + /// <param name="oldValue">A String to be replaced.</param> + /// <param name="newValue">A String to replace all occurrences of oldValue. </param> + /// <returns> + /// A new SqlString with oldValue replaced by the newValue. The new SqlString is + /// in the Compacted form. + /// </returns> + public SqlString Replace(string oldValue, string newValue) + { + // compacting returns a new SqlString object, so we are free to modify + // any of the parts because it has not been put in a hashtable so we can + // consider it mutable - there is no danger yet in changing the value that + // GetHashCode would return. + SqlString compacted = this.Compact(); + + for( int i=0; i<compacted.SqlParts.Length; i++ ) + { + string sqlPart = compacted.SqlParts[i] as string; + if( sqlPart!=null ) + { + compacted.SqlParts[i] = sqlPart.Replace( oldValue, newValue ); + } + } + + return compacted; + } + /// <summary> /// Determines whether the beginning of this SqlString matches the specified System.String |