0
全部,nhibernate - 运行计数加入时生成的SQL不正确
我使用的是Nhibernate 3.3,asp.net 2.0。
的HQL以下错误地翻译为SQL只有当我运行了数查询,换句话说,我跑2个查询:
1)首先查询查询结果
2)相同的查询,但更改选择列,以选择计数(*)
看来我的连接已经消失,但我需要它们进行过滤! 你认为'fetch'这个关键字是否搞砸了?我在技术上不需要在查询中执行count()时需要“获取”,但需要第一个查询。
HQL运行前:
select count(legal.id) from OtherRPlan_ p
inner join fetch p.IssuedBy
left join fetch p.Region
left join fetch p.LegalDescList legal
where p.Status = true and p.Region.Id = :region
从HQL生成的SQL:
select count(legaldescl3_.entity_id) as col_0_0_
from Other_Rplans otherrplan0_
where otherrplan0_.status=1 and [email protected]