我使用grails 3.x.我有这些简单的域名:
class Classification {
String name
static belongsTo = [instrument: Instrument, ptf: Portfolio]
}
class Instrument {
Long internalId
String name
static hasOne = [classification: Classification]
static hasMany = [analisys: Analisys]
}
class Analisys {
Instrument instrument
int serialId
}
我试图执行此查询:
def results = Classification.createCriteria().list() {
ptf {
eq("id", 10l)
}
instrument {
analisys{
eq("serialId", 5)
}
}
instrument {
eq("name", "testName")
}
return results
}
它有效,但约束eq(" serialId",5)根本没有考虑。有什么想法吗?
感谢
我更改了这样的查询,即使不推荐使用CriteriaSpecification也可以使用
def results = Classification.createCriteria().list() {
ptf {
eq("id", 10l)
}
instrument {
eq("name", "testName")
analisys(org.hibernate.criterion.CriteriaSpecification.LEFT_JOIN){
eq("serialId", 5)
}
}
return results
}