Skip to content

Commit aca8e39

Browse files
Set the generic batcher as default batcher for drivers benefiting of it.
1 parent e228b2b commit aca8e39

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
namespace NHibernate.AdoNet
22
{
33
/// <summary>
4-
/// Provide the class of <see cref="IBatcherFactory"/> according to the configuration
5-
/// and the capabilities of the driver.
4+
/// Provides a default <see cref="IBatcherFactory"/> class.
65
/// </summary>
76
/// <remarks>
8-
/// By default, .Net doesn't have any batching capabilities, drivers that does have
9-
/// batching support.
10-
/// The BatcherFactory trough session-factory configuration section.
11-
/// This interface was added in NHibernate for backdraw compatibility to have the ability
12-
/// to specify a default <see cref="IBatcherFactory"/> for a specific <see cref="Driver.IDriver"/>.
7+
/// This interface allows to specify a default <see cref="IBatcherFactory"/> for a specific
8+
/// <see cref="Driver.IDriver"/>. The configuration setting <see cref="NHibernate.Cfg.Environment.BatchStrategy"/>
9+
/// takes precedence over <c>BatcherFactoryClass</c>.
1310
/// </remarks>
1411
public interface IEmbeddedBatcherFactoryProvider
1512
{
13+
/// <summary>
14+
/// The <see cref="IBatcherFactory"/> class type.
15+
/// </summary>
1616
System.Type BatcherFactoryClass { get;}
1717
}
18-
}
18+
}

src/NHibernate/Driver/NpgsqlDriver.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Data;
22
using System.Data.Common;
3+
using NHibernate.AdoNet;
34

45
namespace NHibernate.Driver
56
{
@@ -24,7 +25,7 @@ namespace NHibernate.Driver
2425
/// <a href="http://pgfoundry.org/projects/npgsql">http://pgfoundry.org/projects/npgsql</a>.
2526
/// </p>
2627
/// </remarks>
27-
public class NpgsqlDriver : ReflectionBasedDriver
28+
public class NpgsqlDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
2829
{
2930
/// <summary>
3031
/// Initializes a new instance of the <see cref="NpgsqlDriver"/> class.
@@ -92,5 +93,7 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
9293
public override bool RequiresTimeSpanForTime => (DriverVersion?.Major ?? 3) >= 3;
9394

9495
public override bool HasDelayedDistributedTransactionCompletion => true;
96+
97+
System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass => typeof(GenericBatchingBatcherFactory);
9598
}
9699
}

src/NHibernate/Driver/SqlClientDriver.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using System.Collections.Generic;
33
using System.Data;
44
using System.Data.Common;
5+
#if NETFX
56
using System.Data.SqlClient;
7+
#endif
68
using NHibernate.AdoNet;
79
using NHibernate.Engine;
810
using NHibernate.SqlTypes;
@@ -16,7 +18,7 @@ public class SqlClientDriver
1618
#if NETFX
1719
: DriverBase, IEmbeddedBatcherFactoryProvider
1820
#else
19-
: ReflectionBasedDriver
21+
: ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
2022
#endif
2123
{
2224
public const int MaxSizeForAnsiClob = 2147483647; // int.MaxValue
@@ -50,6 +52,8 @@ public SqlClientDriver()
5052
: base("System.Data.SqlClient", "System.Data.SqlClient.SqlConnection", "System.Data.SqlClient.SqlCommand")
5153
{
5254
}
55+
56+
System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass => typeof(GenericBatchingBatcherFactory);
5357
#else
5458
/// <summary>
5559
/// Creates an uninitialized <see cref="DbConnection" /> object for

0 commit comments

Comments
 (0)