Skip to content

Commit 4b33db0

Browse files
committed
Clear result cache
1 parent 121a875 commit 4b33db0

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -295,22 +295,6 @@ public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFacto
295295
{
296296
switch (sfi?.ConnectionProvider.Driver)
297297
{
298-
// Clear connection pool for Oracle to avoid problem that was manifested with https://github.com/nhibernate/nhibernate-core/pull/1517:
299-
// As it seems Oracle can cache returned types for query for given connection.
300-
// So exception can be thrown if two tests execute same query but with different types in result (like for Entity.Id int and Entity.Id Guid)
301-
case OracleClientDriver oraSysData:
302-
case OracleDataClientDriver oraUnmanaged:
303-
case OracleManagedDataClientDriver oraManaged:
304-
using (var con = sfi.ConnectionProvider.GetConnection())
305-
using (var cmd = con.CreateCommand())
306-
{
307-
cmd.CommandText = "alter system flush shared_pool;";
308-
cmd.Connection = con;
309-
cmd.ExecuteNonQuery();
310-
}
311-
312-
break;
313-
314298
// Firebird will pool each connection created during the test and will marked as used any table
315299
// referenced by queries. It will at best delays those tables drop until connections are actually
316300
// closed, or immediately fail dropping them.
@@ -332,6 +316,25 @@ protected virtual DebugSessionFactory BuildSessionFactory()
332316

333317
private void Cleanup()
334318
{
319+
switch (Sfi?.ConnectionProvider.Driver)
320+
{
321+
// Clear connection pool for Oracle to avoid problem that was manifested with https://github.com/nhibernate/nhibernate-core/pull/1517:
322+
// As it seems Oracle can cache returned types for query for given connection.
323+
// So exception can be thrown if two tests execute same query but with different types in result (like for Entity.Id int and Entity.Id Guid)
324+
case OracleClientDriver oraSysData:
325+
case OracleDataClientDriver oraUnmanaged:
326+
case OracleManagedDataClientDriver oraManaged:
327+
using (var con = Sfi.ConnectionProvider.GetConnection())
328+
using (var cmd = con.CreateCommand())
329+
{
330+
cmd.CommandText = @"BEGIN DBMS_RESULT_CACHE.FLUSH; END;";
331+
cmd.Connection = con;
332+
cmd.ExecuteNonQuery();
333+
}
334+
335+
break;
336+
}
337+
335338
Sfi?.Close();
336339
_sessionFactory = null;
337340
cfg = null;

0 commit comments

Comments
 (0)