NHibernate的2.1.0.4000似乎并不喜欢批量插入 [英] NHibernate 2.1.0.4000 doesn't seem to like batch insert
问题描述
我的项目之一使用NHibernate 2.1.0.4000。我已经将 adonet.batch_size 为 100 在CFG文件,但是我还是看到INSERT语句被视为单个语句。更新似乎很好地工作。这是怎么回事?
更新:
难道是因为我选择身份的主键生成器?
< ID名称=ID列=ID未保存值=0类型=的Int32>
<生成器类=身份>< /发电机>
< / ID>
我不知道该特定版本的NHibernate的任何问题。
使用本地您
作为ID生成你的实体?因为这将迫使每次插入单独发生,选择回生成的ID。这是因为数据库需要产生的每个ID。这也可以解释为什么配料似乎的更新工作。
如果可能的话,你应该切换到如在希洛
策略,甚至的GUID
如果你不关心(容易)读取的ID。
法比奥有汉有趣的帖子这里关于这个话题。
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>
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.
这篇关于NHibernate的2.1.0.4000似乎并不喜欢批量插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!