Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10755/NHibernate/Impl
Modified Files:
BatcherImpl.cs SessionFactoryImpl.cs
Log Message:
Added a config parameter "hibernate.prepare_sql". This along with if the
Driver supports preparing commands determines if .Prepare() gets called
on the command.
Index: SessionFactoryImpl.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionFactoryImpl.cs,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** SessionFactoryImpl.cs 8 Nov 2004 02:53:57 -0000 1.36
--- SessionFactoryImpl.cs 21 Dec 2004 20:43:40 -0000 1.37
***************
*** 312,315 ****
--- 312,320 ----
}
+ public bool PrepareSql
+ {
+ get { return settings.PrepareSql; }
+ }
+
public QueryTranslator GetQuery(string query)
{
Index: BatcherImpl.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** BatcherImpl.cs 4 Dec 2004 22:41:20 -0000 1.12
--- BatcherImpl.cs 21 Dec 2004 20:43:40 -0000 1.13
***************
*** 33,40 ****
--- 33,45 ----
private ISet readersToClose = new HashedSet();
+ // key = SqlString
+ // value = IDbCommand
+ private IDictionary commands;
+
public BatcherImpl(ISessionImplementor session)
{
this.session = session;
this.factory = session.Factory;
+ commands = new Hashtable();
}
***************
*** 49,57 ****
public IDbCommand Generate(SqlString sqlString)
{
! IDbCommand cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sqlString);
if(log.IsDebugEnabled)
{
log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() );
}
return cmd;
--- 54,77 ----
public IDbCommand Generate(SqlString sqlString)
{
! IDbCommand cmd = commands[ sqlString ] as IDbCommand;
!
! if( cmd!=null )
! {
! if( log.IsDebugEnabled )
! {
! log.Debug( "Using prebuilt IDbCommand object for the SqlString: " + sqlString.ToString() );
! }
!
! return cmd;
! }
!
! // need to build the IDbCommand from the sqlString bec
! cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sqlString);
if(log.IsDebugEnabled)
{
log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() );
}
+
+ commands[ sqlString ] = cmd;
return cmd;
***************
*** 78,85 ****
if( command.Connection!=null )
{
if( command.Connection!=session.Connection )
{
! throw new AssertionFailure("The IDbCommand for " + command.CommandText + " has a different connection " +
! "than the Connection the Session is providing.");
}
}
--- 98,106 ----
if( command.Connection!=null )
{
+ // make sure the commands connection is the same as the Sessions connection
+ // these can be different when the session is disconnected and then reconnected
if( command.Connection!=session.Connection )
{
! command.Connection = session.Connection;
}
}
***************
*** 94,99 ****
}
!
! if( factory.ConnectionProvider.Driver.SupportsPreparingCommands )
{
command.Prepare();
--- 115,119 ----
}
! if( factory.PrepareSql && factory.ConnectionProvider.Driver.SupportsPreparingCommands )
{
command.Prepare();
***************
*** 140,144 ****
// another open one Command is doing something then an exception will be
// thrown.
! IDbCommand command = Generate( sql ); // session.Preparer.BuildCommand(sql);
commandsToClose.Add(command);
--- 160,164 ----
// another open one Command is doing something then an exception will be
// thrown.
! IDbCommand command = Generate( sql );
commandsToClose.Add(command);
|