views:

780

answers:

1

I am using NHibernate 2.1.0.4000 in one of the projects. I have set adonet.batch_size to 100 in the cfg file however I still see that insert statement is treated as single statement. Update seems to work fine. What's going on?

Updated: Is it because I've chosen identity as the primary key generator?

<id name="Id" column="Id" unsaved-value="0" type="Int32">
  <generator class ="identity"></generator>
</id>
+4  A: 

I don't know of any issues with that particular NHibernate version.

Are your using native as the ID generator for your entities? Because this will force every insert to happen alone, selecting back the generated ID. This is because the database needs to generate every ID. This would also explain why batching seems to work on updates.

If possible, you should switch to e.g. the hilo strategy, or even guid if you don't care about (easily) readable IDs.

Fabio has han interesting post here regarding this topic.

mookid8000
Yes I am using SQL Server 2005 identity (generated int) as primary key. This explains why. thank you.
Jeffrey C
I am working with existing database so it's not quite possible to change the id.
Jeffrey C