class Car {
String carname
}
class Factory {
Car car
String factoryname
}
如何查看Factory
,factoryname == "Kia"
的对象carname == "newmodel"
是否存在?
答案 0 :(得分:2)
您可以使用 createCriteria()方法和别名。
def cName = 'newmodel'
def fName = 'Kia'
def objects = Factory.createCriteria().count() {
createAlias('car', 'c'),
eq('c.carname', cName)
eq('factoryname', fName)
}
boolean isThere = objects