Is it possible to implement bulk inserting with JetDriver, NHibernate(2.1.2) and MSAccess? I do the following:
1. Call
Code:
JetDriverConfiguration.Standard.AdoNetBatchSize(100)
(I use FluentNHibernate) when configuring sesion factory
2. Set
Code:
Id((x => x.Id)).Column("ID").GeneratedBy.Assigned();
and assign id's of the entities via code so Hibernate doesn't need to get id from DB for each insert
3. Open stateless session when saving entities to DB:
Code:
public static void BulkSaveValues<T>(IList<T> values)
{
using (var sess = HibernateHelper.GetStatelessSession())
{
using (var transaction = sess.BeginTransaction())
{
try
{
foreach (var val in values)
{
sess.Insert(val);
}
transaction.Commit();
}
catch (Exception e)
{
LoggerHelper.Logger.Error("Error saving data", e);
}
}
}
}
So am I doing something wrong or is it impossible to use batch inserts in given conditions?