Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate 2.1.0.4000 doesn't seem to like batch insert

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>
like image 266
Jeff Avatar asked Dec 22 '22 10:12

Jeff


1 Answers

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.

like image 118
mookid8000 Avatar answered Jan 06 '23 14:01

mookid8000