I tried adding bulk insertion to my application, but Batcher is still a NonBatchingBatcher with a BatchSize of size 1.
It uses C # 3, NH3RC1 and MySql 5.1
I added this to my SessionFactory
<property name="adonet.batch_size">100</property>
And my code is very similar to this
var session = SessionManager.GetStatelessSession(type);
var tx = session.BeginTransaction();
session.Insert(instance);
I use HILO generation generation for the instances in question, but not for all instances in the database. SessionFactory.OpenStatelessSession does not accept a type, so it cannot really know that it can perform batch processing of this type or ...?
After some digging in NHibernate, I found something in the SettingsFactory.CreateBatcherFactory file that might give more info
System.Type tBatcher = typeof (NonBatchingBatcherFactory);
string batcherClass = PropertiesHelper.GetString(Environment.BatchStrategy, properties, null);
if (string.IsNullOrEmpty(batcherClass))
{
if (batchSize > 0)
{
IEmbeddedBatcherFactoryProvider ebfp = connectionProvider.Driver as IEmbeddedBatcherFactoryProvider;
Can my configuration be wrong?
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="my application name">
<property name="adonet.batch_size">100</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">my connection string
</property>
<property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="hbm2ddl.keywords">none</property>
</session-factory>
</hibernate-configuration>
source