| Previous CloneSet | Next CloneSet | Back to Main Report |
| Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
|---|---|---|---|---|
| 228 | 4 | 3 | 0.987 | class_member_declarations[19] |
| Clone Abstraction | Parameter Bindings |
| Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
|---|---|---|---|
| 1 | 224 | 85 | src/NHibernate.ByteCode.Castle.Tests/TestCase.cs |
| 2 | 224 | 85 | src/NHibernate.ByteCode.LinFu.Tests/TestCase.cs |
| 3 | 224 | 85 | src/NHibernate.ByteCode.Spring.Tests/TestCase.cs |
| 4 | 228 | 115 | src/NHibernate.Test/TestCase.cs |
| ||||
/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs. This
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
DropSchema();
Cleanup();
}
protected virtual void OnSetUp()
{
}
/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
OnSetUp();
}
protected virtual void OnTearDown()
{
}
/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
OnTearDown();
bool wasClosed = CheckSessionWasClosed();
bool wasCleaned = CheckDatabaseWasCleaned();
bool wereConnectionsClosed = CheckConnectionsWereClosed();
bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
if (fail)
{
Assert.Fail("Test didn't clean up after itself");
}
}
private bool CheckSessionWasClosed()
{
if (lastOpenedSession != null && lastOpenedSession.IsOpen)
{
log.Error("Test case didn't close a session, closing");
lastOpenedSession.Close();
return false;
}
return true;
}
private bool CheckDatabaseWasCleaned()
{
if (sessions.GetAllClassMetadata().Count == 0)
{
// Return early in the case of no mappings, also avoiding
// a warning when executing the HQL below.
return true;
}
bool empty;
using (ISession s = sessions.OpenSession())
{
IList objects = s.CreateQuery("from System.Object o").List();
empty = objects.Count == 0;
}
if ( !empty)
{
log.Error("Test case didn't clean up the database after itself, re-creating the schema");
DropSchema();
CreateSchema();
}
return empty;
}
private bool CheckConnectionsWereClosed()
{
if (connectionProvider == null || !connectionProvider.HasOpenConnections)
{
return true;
}
log.Error("Test case didn't close all open connections, closing");
connectionProvider.CloseAllConnections();
return false;
}
private void Configure()
{
cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
Assembly assembly = Assembly.Load(MappingsAssembly);
foreach (string file in Mappings)
{
cfg.AddResource(MappingsAssembly + "." + file, assembly);
}
Configure(cfg);
ApplyCacheSettings(cfg);
}
private void CreateSchema()
{
new SchemaExport(cfg).Create(OutputDdl, true);
}
private void DropSchema()
{
new SchemaExport(cfg).Drop(OutputDdl, true);
}
protected virtual void BuildSessionFactory()
{
sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}
private void Cleanup()
{
sessions.Close();
sessions = null;
connectionProvider = null;
lastOpenedSession = null;
cfg = null;
}
public int ExecuteStatement(string sql)
{
if (cfg == null)
{
cfg = new Configuration();
}
using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
{
IDbConnection conn = prov.GetConnection();
try
{
using (IDbTransaction tran = conn.BeginTransaction())
using (IDbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
comm.Transaction = tran;
comm.CommandType = CommandType.Text;
int result = comm.ExecuteNonQuery();
tran.Commit();
return result;
}
}
finally
{
prov.CloseConnection(conn);
}
}
}
protected ISessionFactoryImplementor Sfi
{
get { return sessions;
}
}
protected virtual ISession OpenSession()
{
lastOpenedSession = sessions.OpenSession();
return lastOpenedSession;
}
protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
return lastOpenedSession;
}
protected void ApplyCacheSettings(Configuration configuration)
{
if (CacheConcurrencyStrategy == null)
{
return;
}
foreach (PersistentClass clazz in configuration.ClassMappings)
{
bool hasLob = false;
foreach (Property prop in clazz.PropertyClosureIterator)
{
if (prop.Value.IsSimpleValue)
{
IType type = ((SimpleValue)prop.Value).Type;
if (type == NHibernateUtil.BinaryBlob)
{
hasLob = true;
}
}
}
if ( !hasLob && !clazz.IsInherited)
{
configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
}
}
foreach (Mapping.Collection coll in configuration.CollectionMappings)
{
configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
}
}
#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
return true;
}
|
| ||||
/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs. This
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
DropSchema();
Cleanup();
}
protected virtual void OnSetUp()
{
}
/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
OnSetUp();
}
protected virtual void OnTearDown()
{
}
/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
OnTearDown();
bool wasClosed = CheckSessionWasClosed();
bool wasCleaned = CheckDatabaseWasCleaned();
bool wereConnectionsClosed = CheckConnectionsWereClosed();
bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
if (fail)
{
Assert.Fail("Test didn't clean up after itself");
}
}
private bool CheckSessionWasClosed()
{
if (lastOpenedSession != null && lastOpenedSession.IsOpen)
{
log.Error("Test case didn't close a session, closing");
lastOpenedSession.Close();
return false;
}
return true;
}
private bool CheckDatabaseWasCleaned()
{
if (sessions.GetAllClassMetadata().Count == 0)
{
// Return early in the case of no mappings, also avoiding
// a warning when executing the HQL below.
return true;
}
bool empty;
using (ISession s = sessions.OpenSession())
{
IList objects = s.CreateQuery("from System.Object o").List();
empty = objects.Count == 0;
}
if ( !empty)
{
log.Error("Test case didn't clean up the database after itself, re-creating the schema");
DropSchema();
CreateSchema();
}
return empty;
}
private bool CheckConnectionsWereClosed()
{
if (connectionProvider == null || !connectionProvider.HasOpenConnections)
{
return true;
}
log.Error("Test case didn't close all open connections, closing");
connectionProvider.CloseAllConnections();
return false;
}
private void Configure()
{
cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
Assembly assembly = Assembly.Load(MappingsAssembly);
foreach (string file in Mappings)
{
cfg.AddResource(MappingsAssembly + "." + file, assembly);
}
Configure(cfg);
ApplyCacheSettings(cfg);
}
private void CreateSchema()
{
new SchemaExport(cfg).Create(OutputDdl, true);
}
private void DropSchema()
{
new SchemaExport(cfg).Drop(OutputDdl, true);
}
protected virtual void BuildSessionFactory()
{
sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}
private void Cleanup()
{
sessions.Close();
sessions = null;
connectionProvider = null;
lastOpenedSession = null;
cfg = null;
}
public int ExecuteStatement(string sql)
{
if (cfg == null)
{
cfg = new Configuration();
}
using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
{
IDbConnection conn = prov.GetConnection();
try
{
using (IDbTransaction tran = conn.BeginTransaction())
using (IDbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
comm.Transaction = tran;
comm.CommandType = CommandType.Text;
int result = comm.ExecuteNonQuery();
tran.Commit();
return result;
}
}
finally
{
prov.CloseConnection(conn);
}
}
}
protected ISessionFactoryImplementor Sfi
{
get { return sessions;
}
}
protected virtual ISession OpenSession()
{
lastOpenedSession = sessions.OpenSession();
return lastOpenedSession;
}
protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
return lastOpenedSession;
}
protected void ApplyCacheSettings(Configuration configuration)
{
if (CacheConcurrencyStrategy == null)
{
return;
}
foreach (PersistentClass clazz in configuration.ClassMappings)
{
bool hasLob = false;
foreach (Property prop in clazz.PropertyClosureIterator)
{
if (prop.Value.IsSimpleValue)
{
IType type = ((SimpleValue)prop.Value).Type;
if (type == NHibernateUtil.BinaryBlob)
{
hasLob = true;
}
}
}
if ( !hasLob && !clazz.IsInherited)
{
configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
}
}
foreach (Mapping.Collection coll in configuration.CollectionMappings)
{
configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
}
}
#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
return true;
}
|
| ||||
/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs. This
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
DropSchema();
Cleanup();
}
protected virtual void OnSetUp()
{
}
/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
OnSetUp();
}
protected virtual void OnTearDown()
{
}
/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
OnTearDown();
bool wasClosed = CheckSessionWasClosed();
bool wasCleaned = CheckDatabaseWasCleaned();
bool wereConnectionsClosed = CheckConnectionsWereClosed();
bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
if (fail)
{
Assert.Fail("Test didn't clean up after itself");
}
}
private bool CheckSessionWasClosed()
{
if (lastOpenedSession != null && lastOpenedSession.IsOpen)
{
log.Error("Test case didn't close a session, closing");
lastOpenedSession.Close();
return false;
}
return true;
}
private bool CheckDatabaseWasCleaned()
{
if (sessions.GetAllClassMetadata().Count == 0)
{
// Return early in the case of no mappings, also avoiding
// a warning when executing the HQL below.
return true;
}
bool empty;
using (ISession s = sessions.OpenSession())
{
IList objects = s.CreateQuery("from System.Object o").List();
empty = objects.Count == 0;
}
if ( !empty)
{
log.Error("Test case didn't clean up the database after itself, re-creating the schema");
DropSchema();
CreateSchema();
}
return empty;
}
private bool CheckConnectionsWereClosed()
{
if (connectionProvider == null || !connectionProvider.HasOpenConnections)
{
return true;
}
log.Error("Test case didn't close all open connections, closing");
connectionProvider.CloseAllConnections();
return false;
}
private void Configure()
{
cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
Assembly assembly = Assembly.Load(MappingsAssembly);
foreach (string file in Mappings)
{
cfg.AddResource(MappingsAssembly + "." + file, assembly);
}
Configure(cfg);
ApplyCacheSettings(cfg);
}
private void CreateSchema()
{
new SchemaExport(cfg).Create(OutputDdl, true);
}
private void DropSchema()
{
new SchemaExport(cfg).Drop(OutputDdl, true);
}
protected virtual void BuildSessionFactory()
{
sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}
private void Cleanup()
{
sessions.Close();
sessions = null;
connectionProvider = null;
lastOpenedSession = null;
cfg = null;
}
public int ExecuteStatement(string sql)
{
if (cfg == null)
{
cfg = new Configuration();
}
using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
{
IDbConnection conn = prov.GetConnection();
try
{
using (IDbTransaction tran = conn.BeginTransaction())
using (IDbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
comm.Transaction = tran;
comm.CommandType = CommandType.Text;
int result = comm.ExecuteNonQuery();
tran.Commit();
return result;
}
}
finally
{
prov.CloseConnection(conn);
}
}
}
protected ISessionFactoryImplementor Sfi
{
get { return sessions;
}
}
protected virtual ISession OpenSession()
{
lastOpenedSession = sessions.OpenSession();
return lastOpenedSession;
}
protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
return lastOpenedSession;
}
protected void ApplyCacheSettings(Configuration configuration)
{
if (CacheConcurrencyStrategy == null)
{
return;
}
foreach (PersistentClass clazz in configuration.ClassMappings)
{
bool hasLob = false;
foreach (Property prop in clazz.PropertyClosureIterator)
{
if (prop.Value.IsSimpleValue)
{
IType type = ((SimpleValue)prop.Value).Type;
if (type == NHibernateUtil.BinaryBlob)
{
hasLob = true;
}
}
}
if ( !hasLob && !clazz.IsInherited)
{
configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
}
}
foreach (Mapping.Collection coll in configuration.CollectionMappings)
{
configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
}
}
#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
return true;
}
|
| ||||
/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs. This
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
DropSchema();
Cleanup();
}
protected virtual void OnSetUp()
{
}
/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
OnSetUp();
}
protected virtual void OnTearDown()
{
}
/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
OnTearDown();
bool wasClosed = CheckSessionWasClosed();
bool wasCleaned = CheckDatabaseWasCleaned();
bool wereConnectionsClosed = CheckConnectionsWereClosed();
bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
if (fail)
{
Assert.Fail("Test didn't clean up after itself. session closed: " + wasClosed + " database cleaned: " + wasCleaned +
" connection closed: " + wereConnectionsClosed);
}
}
private bool CheckSessionWasClosed()
{
if (lastOpenedSession != null && lastOpenedSession.IsOpen)
{
log.Error("Test case didn't close a session, closing");
lastOpenedSession.Close();
return false;
}
return true;
}
private bool CheckDatabaseWasCleaned()
{
if (sessions.GetAllClassMetadata().Count == 0)
{
// Return early in the case of no mappings, also avoiding
// a warning when executing the HQL below.
return true;
}
bool empty;
using (ISession s = sessions.OpenSession())
{
IList objects = s.CreateQuery("from System.Object o").List();
empty = objects.Count == 0;
}
if ( !empty)
{
log.Error("Test case didn't clean up the database after itself, re-creating the schema");
DropSchema();
CreateSchema();
}
return empty;
}
private bool CheckConnectionsWereClosed()
{
if (connectionProvider == null || !connectionProvider.HasOpenConnections)
{
return true;
}
log.Error("Test case didn't close all open connections, closing");
connectionProvider.CloseAllConnections();
return false;
}
private void Configure()
{
cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
Assembly assembly = Assembly.Load(MappingsAssembly);
foreach (string file in Mappings)
{
cfg.AddResource(MappingsAssembly + "." + file, assembly);
}
Configure(cfg);
ApplyCacheSettings(cfg);
}
protected virtual void CreateSchema()
{
new SchemaExport(cfg).Create(OutputDdl, true);
}
private void DropSchema()
{
new SchemaExport(cfg).Drop(OutputDdl, true);
}
protected virtual void BuildSessionFactory()
{
sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}
private void Cleanup()
{
if (sessions != null)
{
sessions.Close();
}
sessions = null;
connectionProvider = null;
lastOpenedSession = null;
cfg = null;
}
public int ExecuteStatement(string sql)
{
if (cfg == null)
{
cfg = new Configuration();
}
using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
{
IDbConnection conn = prov.GetConnection();
try
{
using (IDbTransaction tran = conn.BeginTransaction())
using (IDbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
comm.Transaction = tran;
comm.CommandType = CommandType.Text;
int result = comm.ExecuteNonQuery();
tran.Commit();
return result;
}
}
finally
{
prov.CloseConnection(conn);
}
}
}
protected ISessionFactoryImplementor Sfi
{
get { return sessions;
}
}
protected virtual ISession OpenSession()
{
lastOpenedSession = sessions.OpenSession();
return lastOpenedSession;
}
protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
return lastOpenedSession;
}
protected void ApplyCacheSettings(Configuration configuration)
{
if (CacheConcurrencyStrategy == null)
{
return;
}
foreach (PersistentClass clazz in configuration.ClassMappings)
{
bool hasLob = false;
foreach (Property prop in clazz.PropertyClosureIterator)
{
if (prop.Value.IsSimpleValue)
{
IType type = ((SimpleValue)prop.Value).Type;
if (type == NHibernateUtil.BinaryBlob)
{
hasLob = true;
}
}
}
if ( !hasLob && !clazz.IsInherited)
{
configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
}
}
foreach (Mapping.Collection coll in configuration.CollectionMappings)
{
configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
}
}
#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
return true;
}
|
| |||
/// <summary>
/// Removes the tables used in this TestCase.
/// </summary>
/// <remarks>
/// If the tables are not cleaned up sometimes SchemaExport runs into
/// Sql errors because it can't drop tables because of the FKs. This
/// will occur if the TestCase does not have the same hbm.xml files
/// included as a previous one.
/// </remarks>
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
DropSchema();
Cleanup();
}
protected virtual void OnSetUp()
{
}
/// <summary>
/// Set up the test. This method is not overridable, but it calls
/// <see cref="OnSetUp" /> which is.
/// </summary>
[SetUp]
public void SetUp()
{
OnSetUp();
}
protected virtual void OnTearDown()
{
}
/// <summary>
/// Checks that the test case cleans up after itself. This method
/// is not overridable, but it calls <see cref="OnTearDown" /> which is.
/// </summary>
[TearDown]
public void TearDown()
{
OnTearDown();
bool wasClosed = CheckSessionWasClosed();
bool wasCleaned = CheckDatabaseWasCleaned();
bool wereConnectionsClosed = CheckConnectionsWereClosed();
bool fail = !wasClosed || !wasCleaned || !wereConnectionsClosed;
if (fail)
{
Assert.Fail( [[#variable58400de0]]);
}
}
private bool CheckSessionWasClosed()
{
if (lastOpenedSession != null && lastOpenedSession.IsOpen)
{
log.Error("Test case didn't close a session, closing");
lastOpenedSession.Close();
return false;
}
return true;
}
private bool CheckDatabaseWasCleaned()
{
if (sessions.GetAllClassMetadata().Count == 0)
{
// Return early in the case of no mappings, also avoiding
// a warning when executing the HQL below.
return true;
}
bool empty;
using (ISession s = sessions.OpenSession())
{
IList objects = s.CreateQuery("from System.Object o").List();
empty = objects.Count == 0;
}
if ( !empty)
{
log.Error("Test case didn't clean up the database after itself, re-creating the schema");
DropSchema();
CreateSchema();
}
return empty;
}
private bool CheckConnectionsWereClosed()
{
if (connectionProvider == null || !connectionProvider.HasOpenConnections)
{
return true;
}
log.Error("Test case didn't close all open connections, closing");
connectionProvider.CloseAllConnections();
return false;
}
private void Configure()
{
cfg = new Configuration();
if (TestConfigurationHelper.hibernateConfigFile != null)
cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
Assembly assembly = Assembly.Load(MappingsAssembly);
foreach (string file in Mappings)
{
cfg.AddResource(MappingsAssembly + "." + file, assembly);
}
Configure(cfg);
ApplyCacheSettings(cfg);
}
[[#variable58400e80]]void CreateSchema()
{
new SchemaExport(cfg).Create(OutputDdl, true);
}
private void DropSchema()
{
new SchemaExport(cfg).Drop(OutputDdl, true);
}
protected virtual void BuildSessionFactory()
{
sessions = (ISessionFactoryImplementor)cfg.BuildSessionFactory();
connectionProvider = sessions.ConnectionProvider as DebugConnectionProvider;
}
private void Cleanup()
{
[[#variable58400640]]
sessions = null;
connectionProvider = null;
lastOpenedSession = null;
cfg = null;
}
public int ExecuteStatement(string sql)
{
if (cfg == null)
{
cfg = new Configuration();
}
using (IConnectionProvider prov = ConnectionProviderFactory.NewConnectionProvider(cfg.Properties))
{
IDbConnection conn = prov.GetConnection();
try
{
using (IDbTransaction tran = conn.BeginTransaction())
using (IDbCommand comm = conn.CreateCommand())
{
comm.CommandText = sql;
comm.Transaction = tran;
comm.CommandType = CommandType.Text;
int result = comm.ExecuteNonQuery();
tran.Commit();
return result;
}
}
finally
{
prov.CloseConnection(conn);
}
}
}
protected ISessionFactoryImplementor Sfi
{
get
{
return sessions;
}
}
protected virtual ISession OpenSession()
{
lastOpenedSession = sessions.OpenSession();
return lastOpenedSession;
}
protected virtual ISession OpenSession(IInterceptor sessionLocalInterceptor)
{
lastOpenedSession = sessions.OpenSession(sessionLocalInterceptor);
return lastOpenedSession;
}
protected void ApplyCacheSettings(Configuration configuration)
{
if (CacheConcurrencyStrategy == null)
{
return;
}
foreach (PersistentClass clazz in configuration.ClassMappings)
{
bool hasLob = false;
foreach (Property prop in clazz.PropertyClosureIterator)
{
if (prop.Value.IsSimpleValue)
{
IType type = ((SimpleValue)prop.Value).Type;
if (type == NHibernateUtil.BinaryBlob)
{
hasLob = true;
}
}
}
if ( !hasLob && !clazz.IsInherited)
{
configuration.SetCacheConcurrencyStrategy(clazz.EntityName, CacheConcurrencyStrategy);
}
}
foreach (Mapping.Collection coll in configuration.CollectionMappings)
{
configuration.SetCollectionCacheConcurrencyStrategy(coll.Role, CacheConcurrencyStrategy);
}
}
#region Properties overridable by subclasses
protected virtual bool AppliesTo(Dialect.Dialect dialect)
{
return true;
}
|
| CloneAbstraction |
| Parameter Index | Clone Instance | Parameter Name | Value |
|---|---|---|---|
| 1 | 1 | [[#58400de0]] | "Test didn't clean up after itself. session closed: " + wasClosed + " database cleaned: " + wasCleaned + " connection closed: " + wereConnectionsClosed |
| 1 | 2 | [[#58400de0]] | "Test didn't clean up after itself" |
| 1 | 3 | [[#58400de0]] | "Test didn't clean up after itself" |
| 1 | 4 | [[#58400de0]] | "Test didn't clean up after itself" |
| 2 | 1 | [[#58400e80]] | protected virtual |
| 2 | 2 | [[#58400e80]] | private |
| 2 | 3 | [[#58400e80]] | private |
| 2 | 4 | [[#58400e80]] | private |
| 3 | 1 | [[#58400640]] | if (sessions != null)
{
sessions.Close();
} |
| 3 | 2 | [[#58400640]] | sessions.Close(); |
| 3 | 3 | [[#58400640]] | sessions.Close(); |
| 3 | 4 | [[#58400640]] | sessions.Close(); |