我有以下课程:
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 查询才能使其工作?