我有一个培训领域课程
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
}
我想根据轨道选择培训。
现在说我得到了track id,我想根据Track id检索训练
我试过这样的查询
def query = "FROM Training AS t WHERE t.course.tracks.id IN (1,2)"
trainingList = Training.findAll(query)
它给
illegal attempt to dereference collection
错误..因为我做不到t.course.tracks.id
如果我有跟踪 ID(比如 1、2),请帮助我编写正确的 hql 查询以获得培训