-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: MS Access and batch inserts
PostPosted: Thu Aug 26, 2010 6:41 am 
Newbie

Joined: Thu Aug 26, 2010 6:28 am
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.