我遇到NHibernate的问题(SQL Server 2000,如果重要的话)。
似乎NHibernate使用等于10的批量大小,即使我指定500(但如果我指定大小小于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个项目并在NHProf中看到它执行两个查询:
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 */
答案 0 :(得分:1)
很抱歉,如果这对你来说太晚了,但可能对其他人有用:我发现另一个帖子(Batch Update in NHibernate)提到了一个nhibernate cfg参数来定义批量大小