我正在尝试计算hql查询的行数。我收到了TypeOfPermission列不存在的警告。这让我觉得奇怪,因为之前的查询确实有效。下面的行给了我2行(正如预期的那样)
from ClientIdentity c left join fetch c.Permissions p where p.TypeOfPermission = :permissionType;
但是,使用以下计数查询时,查询将失败,因为现在不再识别列TypeOfPermission。
countQuery = "select count(*) from ClientIdentity c left join fetch c.Permissions p where p.TypeOfPermission = :permissionType";
long count = countQuery.UniqueResult<long>();
答案 0 :(得分:0)
你改变了:
c.Permissions to Permissions
答案 1 :(得分:0)
使用“Count(*)”时,不需要“fetch”。
countQuery = "select count(*) from ClientIdentity c left join c.Permissions p where p.TypeOfPermission = :permissionType";
long count = countQuery.UniqueResult<long>();