简体   繁体   English

NHibernate HiLo ID生成器正在按插入的行对数据库执行往返

[英]NHibernate HiLo ID generator is performing a round-trip to the database per-row inserted

When I configure my application to use HiLo Id generation, I see one round-trip per row inserted in the database. 当我将应用程序配置为使用HiLo Id生成时,在数据库中每行插入一次往返。 All the documentation I've read has indicated that I should see far fewer round-trips. 我阅读的所有文档都表明往返次数应该少得多。

My objects are all generally configured (fluently) as such: 我的对象通常都(有效地)配置为:

Id(t=>t.Id).GeneratedBy.HiLo("MyObject_Identity","MaxId","1000"); Id(t => t.Id).GeneratedBy.HiLo(“ MyObject_Identity”,“ MaxId”,“ 1000”);

Additionally my batch size is set to 75 on the connection. 另外,我的批量大小在连接上设置为75。

I know I'm probably doing something relatively stupid. 我知道我可能在做一些相对愚蠢的事情。

Do you mean you are seeing a round trip for each insert to go get a new high value for the ID? 您的意思是说您看到每个插入的往返行程都获得了ID的新高值吗? If so are you using a new instance of the SessionFactory on each operation? 如果是这样,您是否在每个操作上使用SessionFactory的新实例? The SessionFactory is responsible for managing the retrieval of the high value. SessionFactory负责管理高价值的检索。 Typically you should only have one SessionFactory per application instance (via singleton or IoC container). 通常,每个应用程序实例(通过单例或IoC容器)只应具有一个SessionFactory。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM