From: Michael D. <mik...@us...> - 2004-08-31 13:14:39
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23761/src/NHibernate/Impl Modified Files: BatcherImpl.cs SessionFactoryImpl.cs Log Message: Removed PreparedStatementCache code. Index: SessionFactoryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** SessionFactoryImpl.cs 28 Aug 2004 04:07:04 -0000 1.28 --- SessionFactoryImpl.cs 31 Aug 2004 13:14:25 -0000 1.29 *************** *** 19,23 **** using NHibernate.Metadata; using NHibernate.Persister; - using NHibernate.Ps; using NHibernate.Transaction; using NHibernate.Type; --- 19,22 ---- *************** *** 82,86 **** [NonSerialized] private IDictionary querySubstitutions; [NonSerialized] private Dialect.Dialect dialect; - [NonSerialized] private PreparedStatementCache statementCache; [NonSerialized] private ITransactionFactory transactionFactory; [NonSerialized] private int adoBatchSize; --- 81,84 ---- *************** *** 133,142 **** connectionProvider = ConnectionProviderFactory.NewConnectionProvider(properties); - // TODO: DESIGNQUESTION: There are other points in the application that have questions about the - // statementCache - I just don't see this as being needed yet. - int cacheSize = PropertiesHelper.GetInt32( Cfg.Environment.StatementCacheSize, properties, 0); - statementCache = ( cacheSize<1 || connectionProvider.IsStatementCache ) ? null : new PreparedStatementCache(cacheSize); - //statementCache = null; - statementFetchSize = PropertiesHelper.GetInt32( Cfg.Environment.StatementFetchSize, properties, -1); if((int)statementFetchSize==-1) statementFetchSize = null; --- 131,134 ---- *************** *** 569,633 **** } - //TODO: revisit if we want the SessionFactoryImpl to store the PreparedStatements considering - // that ADO.NET handles prepared Commands differently depending on the provider - public IDbCommand GetPreparedStatement(IDbConnection conn, string sql, bool scrollable) { - - if ( log.IsDebugEnabled ) log.Debug("prepared statement get: " + sql); - if ( showSql ) log.Debug("Hibernate: " + sql); - - //TODO: what would be the implications of hooking up the PreparedStatment (IDbCommand) to - // the IDbTransaction at this point. I am a little nervous about this because the SessionFactory - // is not specific to a Session. So would the IDbCommand object be shared among different sessions? - // Would that cause us to run into problems where one Session would be using the Transaction from - // a different Session?? - // NOTE: I have commented out the code that assigns the statement cache - so it will always - // be null and we will be creating a new command each time. - - if ( statementCache != null ) - { - return statementCache.GetPreparedStatement(sql, conn); - } - else { - try { - log.Debug("preparing statement"); - IDbCommand retVal = conn.CreateCommand(); - retVal.CommandText = sql; - retVal.CommandType = CommandType.Text; - - - // Hack: disable Prepare() as long as the parameters have no datatypes!! - #if FALSE - retVal.Prepare(); - #endif - // end-of Hack - - return retVal; - } - catch (Exception e) { - throw e; - } - } - } - - public void ClosePreparedStatement(IDbCommand ps) - { - if ( statementCache != null ) { - statementCache.ClosePreparedStatement(ps); - } else { - try { - log.Debug("closing statement"); - //TODO: there is some missing logic about when this gets called - with the OleDb driver - // as soon as the Dispose is called the CommandText=="", with SqlServer driver that - // is not occurring - don't know why not??? This prevents a command from being called - // more than 1 time in a row... - // In H2.0.3 this is a Close - not a dispose. It looks like each Provider implements - // Dispose just a bit differently... - //ps.Dispose(); - } catch (Exception e) { - throw e; - } - } - } - public bool UseAdoBatch { get { return adoBatchSize > 0; } --- 561,564 ---- Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BatcherImpl.cs 28 Aug 2004 04:18:40 -0000 1.3 --- BatcherImpl.cs 31 Aug 2004 13:14:25 -0000 1.4 *************** *** 77,83 **** LogOpenPreparedCommands(); - //return JoinTransaction( factory.GetPreparedStatement( session.Connection, sql, false) ); return session.Preparer.PrepareCommand(sql); - } --- 77,81 ---- *************** *** 88,92 **** 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 --- 86,89 ---- *************** *** 167,171 **** { LogClosePreparedCommands(); - // factory.ClosePreparedStatement(cmd); } --- 164,167 ---- |