休眠 HQL 计数非重复性不起作用?
我有以下类:
class User {
hasMany = [ratings: Rating]
}
class Item {
hasMany = [ratings: Rating]
}
class Rating {
belongsTo = [user: User, item: Item]
}
我想计算对某个项目进行评级的不同用户。
以下情况不起作用:
select count(distinct(r.user)) from Rating as r
where r.item=:item
group by r.user
如何修改 HQL 查询才能使其正常工作?