NHibernate:批量大小是否有 10 个项目的限制?

发布于 2024-08-07 00:32:36 字数 1421 浏览 11 评论 0原文

我在 NHibernate(SQL Server 2000,如果有的话)方面遇到了问题。

即使我指定 500,NHibernate 也使用等于 10 的批量大小(但如果我指定小于 10 的大小,比如 3 - 它使用 3),

<bag name="RiskTypes" table="CalculationQuery" lazy="false" batch-size="50">
  <key column="CalculationID"></key>
  <many-to-many class="RiskType" column="RiskType"></many-to-many>
</bag>

我正在加载 11 个项目,并在 NProf 中看到它执行两个查询:

SELECT risktypes0_.CalculationID as Calculat1_1_,
       risktypes0_.RiskType      as RiskType1_,
       risktype1_.RiskTypeID     as RiskTypeID5_0_,
       risktype1_.RiskTypeName   as RiskType2_5_0_
FROM   CalculationQuery risktypes0_
       left outer join RiskType risktype1_
         on risktypes0_.RiskType = risktype1_.RiskTypeID
WHERE  risktypes0_.CalculationID in (373 /* @p0 */,363 /* @p1 */,364 /* @p2 */,365 /* @p3 */,
                                     366 /* @p4 */,367 /* @p5 */,368 /* @p6 */,369 /* @p7 */,
                                     370 /* @p8 */,371 /* @p9 */)
SELECT risktypes0_.CalculationID as Calculat1_1_,
       risktypes0_.RiskType      as RiskType1_,
       risktype1_.RiskTypeID     as RiskTypeID5_0_,
       risktype1_.RiskTypeName   as RiskType2_5_0_
FROM   CalculationQuery risktypes0_
       left outer join RiskType risktype1_
         on risktypes0_.RiskType = risktype1_.RiskTypeID
WHERE  risktypes0_.CalculationID = 372 /* @p0 */

I am having a problem with NHibernate (SQL Server 2000, if it matters).

It seems like NHibernate uses batch-size equal to 10 even if I specify 500 (but if I specify size less than 10, say 3 - it uses 3)

<bag name="RiskTypes" table="CalculationQuery" lazy="false" batch-size="50">
  <key column="CalculationID"></key>
  <many-to-many class="RiskType" column="RiskType"></many-to-many>
</bag>

I am loading 11 items and see in NHProf that it executes two queries:

SELECT risktypes0_.CalculationID as Calculat1_1_,
       risktypes0_.RiskType      as RiskType1_,
       risktype1_.RiskTypeID     as RiskTypeID5_0_,
       risktype1_.RiskTypeName   as RiskType2_5_0_
FROM   CalculationQuery risktypes0_
       left outer join RiskType risktype1_
         on risktypes0_.RiskType = risktype1_.RiskTypeID
WHERE  risktypes0_.CalculationID in (373 /* @p0 */,363 /* @p1 */,364 /* @p2 */,365 /* @p3 */,
                                     366 /* @p4 */,367 /* @p5 */,368 /* @p6 */,369 /* @p7 */,
                                     370 /* @p8 */,371 /* @p9 */)
SELECT risktypes0_.CalculationID as Calculat1_1_,
       risktypes0_.RiskType      as RiskType1_,
       risktype1_.RiskTypeID     as RiskTypeID5_0_,
       risktype1_.RiskTypeName   as RiskType2_5_0_
FROM   CalculationQuery risktypes0_
       left outer join RiskType risktype1_
         on risktypes0_.RiskType = risktype1_.RiskTypeID
WHERE  risktypes0_.CalculationID = 372 /* @p0 */

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文