4
class Course {
String name
static hasMany = [categories: Category]
}
类别域类
class Category {
String name
}
所以这里课程可以有多个类别。
现在我想找到所有具有类别id为例如4
我试着写HQL查询课程:
def courseList = Course.findAll("from Course as c where c.categories.id in (4)")
它给出了一个错误。
如何编写正确的HQL或正确的withCriteria查询?
那是一个笔误或者是你真的想使用的hasMany和属于关联的同一侧?只是看起来不正确。如果一门课程有许多类别,则它不能属于一个类别。 – uchamp
@ uchamp:这是类型错误,更新了我的问题.. – Hussy