Skip to content

Commit 4d9e67d

Browse files
Cleanup
- Remove changes now unrelated. - Remove not supported parameters for System.Data.Oracle.
1 parent cedaecb commit 4d9e67d

10 files changed

+36
-123
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
using NUnit.Framework.Interfaces;
1515
using System.Text;
1616
using NHibernate.Driver;
17-
using NHibernate.SqlCommand;
18-
using NHibernate.SqlTypes;
1917

2018
namespace NHibernate.Test
2119
{
@@ -293,17 +291,15 @@ protected virtual void DropSchema()
293291

294292
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi)
295293
{
296-
switch (sfi?.ConnectionProvider.Driver)
294+
if (sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
297295
{
298296
// Firebird will pool each connection created during the test and will marked as used any table
299297
// referenced by queries. It will at best delays those tables drop until connections are actually
300298
// closed, or immediately fail dropping them.
301299
// This results in other tests failing when they try to create tables with same name.
302300
// By clearing the connection pool the tables will get dropped. This is done by the following code.
303301
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
304-
case FirebirdClientDriver fbDriver:
305-
fbDriver.ClearPool(null);
306-
break;
302+
fbDriver.ClearPool(null);
307303
}
308304

309305
export.Drop(useStdOut, true);

src/NHibernate.sln.DotSettings

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
2+
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/ALIGNMENT_TAB_FILL_STYLE/@EntryValue">USE_SPACES</s:String>
33
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
44
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_ARGUMENT/@EntryValue">True</s:Boolean>
55
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue">True</s:Boolean>
66
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_PARAMETER/@EntryValue">True</s:Boolean>
77
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_INTERNAL_MODIFIER/@EntryValue">True</s:Boolean>
88
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_PRIVATE_MODIFIER/@EntryValue">True</s:Boolean>
99
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
10-
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
11-
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
1210
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
13-
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
1411
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
1512
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_DECLARATION_LPAR/@EntryValue">True</s:Boolean>
1613
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean>
@@ -23,14 +20,9 @@
2320
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
2421
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
2522
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
26-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
27-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
28-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
2923
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
30-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
3124
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
3225
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
33-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EFormat_002ESettingsUpgrade_002EAlignmentTabFillStyleMigration/@EntryIndexedValue">True</s:Boolean>
3426
<s:Boolean x:Key="/Default/Environment/UnitTesting/SeparateAppDomainPerAssembly/@EntryValue">True</s:Boolean>
3527
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=0BE95D01E0F2244E97F5FEFAD1EB1A63/@KeyIndexDefined">True</s:Boolean>
3628
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=0BE95D01E0F2244E97F5FEFAD1EB1A63/Comment/@EntryValue">NUnit Assert.NotNull</s:String>
@@ -411,4 +403,4 @@
411403
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=EDE6DA5BB1FD144F81E051772A257749/ReplaceComment/@EntryValue">Update to fluent syntax.</s:String>
412404
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=EDE6DA5BB1FD144F81E051772A257749/ReplacePattern/@EntryValue">Assert.That($greater$, Is.GreaterThanOrEqualTo($lesser$));</s:String>
413405
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=EDE6DA5BB1FD144F81E051772A257749/SearchPattern/@EntryValue">Assert.GreaterOrEqual($greater$, $lesser$);</s:String>
414-
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=EDE6DA5BB1FD144F81E051772A257749/Severity/@EntryValue">HINT</s:String></wpf:ResourceDictionary>
406+
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=EDE6DA5BB1FD144F81E051772A257749/Severity/@EntryValue">HINT</s:String></wpf:ResourceDictionary>

src/NHibernate/Driver/FirebirdClientDriver.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Data;
34
using System.Data.Common;
45
using System.Linq;
6+
using System.Reflection;
57
using System.Text.RegularExpressions;
68
using NHibernate.Dialect;
79
using NHibernate.SqlCommand;
@@ -126,16 +128,39 @@ private string GetFbTypeForParam(SqlType sqlType)
126128
return _fbDialect.GetCastTypeName(sqlType);
127129
}
128130

131+
private static volatile MethodInfo _clearPool;
132+
private static volatile MethodInfo _clearAllPools;
133+
129134
/// <summary>
130135
/// Clears the connection pool.
131136
/// </summary>
132137
/// <param name="connectionString">The connection string of connections for which to clear the pool.
133138
/// <c>null</c> for clearing them all.</param>
134139
public void ClearPool(string connectionString)
135140
{
136-
// Do not move in a base class common to different connection types, or it may not clear
137-
// expected pool.
138-
PoolHelper<FirebirdClientDriver>.ClearPool(this, connectionString);
141+
// In case of concurrent threads, may initialize many times. We do not care.
142+
// Members are volatile for avoiding it gets used while its constructor is not yet ended.
143+
if (_clearPool == null || _clearAllPools == null)
144+
{
145+
using (var clearConnection = CreateConnection())
146+
{
147+
var connectionType = clearConnection.GetType();
148+
_clearPool = connectionType.GetMethod("ClearPool") ?? throw new InvalidOperationException("Unable to resolve ClearPool method.");
149+
_clearAllPools = connectionType.GetMethod("ClearAllPools") ?? throw new InvalidOperationException("Unable to resolve ClearAllPools method.");
150+
}
151+
}
152+
153+
if (connectionString != null)
154+
{
155+
using (var clearConnection = CreateConnection())
156+
{
157+
clearConnection.ConnectionString = connectionString;
158+
_clearPool.Invoke(null, new object[] {clearConnection});
159+
}
160+
return;
161+
}
162+
163+
_clearAllPools.Invoke(null, Array.Empty<object>());
139164
}
140165

141166
/// <summary>

src/NHibernate/Driver/OracleClientDriver.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,5 @@ protected override void OnBeforePrepare(DbCommand command)
5959
" does not support CallableStatement syntax (stored procedures)." +
6060
" Consider using OracleDataClientDriver instead.");
6161
}
62-
63-
/// <summary>
64-
/// Clears the connection pool.
65-
/// </summary>
66-
/// <param name="connectionString">The connection string of connections for which to clear the pool.
67-
/// <c>null</c> for clearing them all.</param>
68-
public void ClearPool(string connectionString)
69-
{
70-
// Do not move in a base class common to different connection types, or it may not clear
71-
// expected pool.
72-
PoolHelper<OracleClientDriver>.ClearPool(this, connectionString);
73-
}
7462
}
7563
}

src/NHibernate/Driver/OracleDataClientDriver.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,5 @@ public OracleDataClientDriver()
1515
: base("Oracle.DataAccess")
1616
{
1717
}
18-
19-
/// <summary>
20-
/// Clears the connection pool.
21-
/// </summary>
22-
/// <param name="connectionString">The connection string of connections for which to clear the pool.
23-
/// <c>null</c> for clearing them all.</param>
24-
public void ClearPool(string connectionString)
25-
{
26-
// Do not move in a base class common to different connection types, or it may not clear
27-
// expected pool.
28-
PoolHelper<OracleDataClientDriver>.ClearPool(this, connectionString);
29-
}
3018
}
3119
}

src/NHibernate/Driver/OracleDataClientDriverBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Data;
44
using System.Data.Common;
5+
using System.Reflection;
56
using NHibernate.AdoNet;
67
using NHibernate.Engine.Query;
78
using NHibernate.SqlTypes;

src/NHibernate/Driver/OracleManagedDataClientDriver.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,5 @@ public OracleManagedDataClientDriver()
1717
}
1818

1919
public override bool HasDelayedDistributedTransactionCompletion => true;
20-
21-
/// <summary>
22-
/// Clears the connection pool.
23-
/// </summary>
24-
/// <param name="connectionString">The connection string of connections for which to clear the pool.
25-
/// <c>null</c> for clearing them all.</param>
26-
public void ClearPool(string connectionString)
27-
{
28-
// Do not move in a base class common to different connection types, or it may not clear
29-
// expected pool.
30-
PoolHelper<OracleManagedDataClientDriver>.ClearPool(this, connectionString);
31-
}
3220
}
3321
}
Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Data.Common;
3-
using System.Linq.Expressions;
4-
using System.Reflection;
53
using NHibernate.Util;
64

75
namespace NHibernate.Driver
@@ -72,69 +70,5 @@ public override DbCommand CreateCommand()
7270
{
7371
return connectionCommandProvider.CreateCommand();
7472
}
75-
76-
/// <summary>
77-
/// Helper for clearing connection pools used by a reflection driver. Assumes the connection has a parameter-less
78-
/// <c>ClearAllPools</c> method and a <c>ClearPool</c> method taking as argument a connection.
79-
/// </summary>
80-
/// <typeparam name="T">The driver type for which the pool has to be cleared. This driver type must
81-
/// always use the same connection type.</typeparam>
82-
/// <remarks>Having <c>ClearAllPools</c> and <c>ClearPool</c> is a common pattern. <c>SqlConnection</c>,
83-
/// <c>OracleConnection</c> (managed, un-managed and from <c>System.Data</c>), <c>FirebirdConnection</c>
84-
/// <c>NpgsqlConnection</c>, <c>MySqlConnection</c> and <c>SQLiteConnection</c> have them.
85-
/// (<c>SqlCeConnection</c>, <c>OdbcConnection</c> and <c>OleDbConnection</c> lack them.)</remarks>
86-
protected static class PoolHelper<T> where T : IDriver
87-
{
88-
// Static field in generic class => one field per concrete type used. This is exactly what
89-
// we need here, do not move the generic argument to the method. Otherwise it will cache the
90-
// delegate of the first driver type used, and reuse it for other driver types, which
91-
// would fail.
92-
private static volatile System.Action<DbConnection> _clearPool;
93-
private static volatile System.Action _clearAllPools;
94-
95-
/// <summary>
96-
/// Clears the connection pool.
97-
/// </summary>
98-
/// <param name="driver">The driver for which the connection pool has to be cleared.</param>
99-
/// <param name="connectionString">The connection string of connections for which to clear the pool.
100-
/// <c>null</c> for clearing them all.</param>
101-
public static void ClearPool(T driver, string connectionString)
102-
{
103-
// In case of concurrent threads, may initialize many times. We do not care.
104-
// Members are volatile for avoiding they get used while their constructor is not yet ended.
105-
if (_clearPool == null || _clearAllPools == null)
106-
{
107-
using (var clearConnection = driver.CreateConnection())
108-
{
109-
var connectionType = clearConnection.GetType();
110-
111-
var clearPoolMethodInfo = GetMethod(connectionType, "ClearPool");
112-
var parameter = Expression.Parameter(typeof(DbConnection));
113-
var methodCall = Expression.Call(clearPoolMethodInfo, Expression.Convert(parameter, connectionType));
114-
_clearPool = Expression.Lambda<Action<DbConnection>>(methodCall, parameter).Compile();
115-
116-
var clearAllPoolsMethodInfo = GetMethod(connectionType, "ClearAllPools");
117-
_clearAllPools = (System.Action) Delegate.CreateDelegate(typeof(System.Action), clearAllPoolsMethodInfo);
118-
}
119-
}
120-
121-
if (connectionString != null)
122-
{
123-
using (var clearConnection = driver.CreateConnection())
124-
{
125-
clearConnection.ConnectionString = connectionString;
126-
_clearPool(clearConnection);
127-
}
128-
return;
129-
}
130-
131-
_clearAllPools();
132-
}
133-
134-
private static MethodInfo GetMethod(System.Type type, string methodName)
135-
{
136-
return type.GetMethod(methodName) ?? throw new InvalidOperationException($"Unable to resolve {type.Name}.{methodName} method.");
137-
}
138-
}
13973
}
14074
}

src/NHibernate/Mapping/PersistentClass.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,8 @@ public void PrepareTemporaryTables(IMapping mapping, Dialect.Dialect dialect)
11231123
if (dialect.SupportsTemporaryTables)
11241124
{
11251125
temporaryIdTableName = dialect.GenerateTemporaryTableName(Table.Name);
1126-
Table table = new Table(temporaryIdTableName);
1126+
Table table = new Table();
1127+
table.Name = temporaryIdTableName;
11271128
foreach (Column column in Table.PrimaryKey.ColumnIterator)
11281129
{
11291130
table.AddColumn((Column)column.Clone());

teamcity.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<target name="setup-teamcity-oracle">
117117
<property name="nhibernate.connection.driver_class" value="NHibernate.Driver.OracleClientDriver" />
118118
<property name="nhibernate.dialect" value="NHibernate.Dialect.Oracle10gDialect" />
119-
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=XE;Metadata Pooling=false;Self Tuning=false;" />
119+
<property name="nhibernate.connection.connection_string" value="User ID=nhibernate;Password=nhibernate;Data Source=XE" />
120120
<property name="NHibernate.Test.IgnoreFail" value="true" />
121121
<property name="teamcity.last.result" value="${root.dir}/lib/teamcity/oracle/NHibernate.Test.last-results.xml" />
122122
</target>

0 commit comments

Comments
 (0)