我有一个培训领域课程
class Training {
String type
Date createdOn
Date modifiedOn
static belongsTo = [course: Course]
static hasMany = [attachments: Attachment]
}
我有课程领域课程
class Course {
String name
static hasMany = [trainings: Training, tracks: Track]
static belongsTo = Track
}
和跟踪域类
class Track {
String name
}
现在我有一个过滤器(这是 gsp 页面,它将 id 作为参数发送到控件),它根据课程和跟踪选择培训
现在说 params.courseId = 1 和 3
所以我写了查询
def query = "FROM Training AS t WHERE t.course.id IN (1,3)"
trainingList = Training.findAll(query)
这是正确的 ii 得到所需的输出。
现在,当我说我有跟踪 ID 时,params.trackId = 1,2
def query = "FROM Training AS t WHERE t.course.tracks.id IN (1,2)"
trainingList = Training.findAll(query)
这不起作用..如何在上述关联中编写正确的查询。