我有一个这样的域
Employee {
Address address
String name
String title
}
Run Code Online (Sandbox Code Playgroud)
和另一个域
Address {
String country
String locality
String city
}
Run Code Online (Sandbox Code Playgroud)
现在我想找到给定城市的所有员工,我试过
def employees = Employee.where {
address {
city == params.city
}
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,我怎么能做到这一点
小智 4
你可以像下面这样写
List<Employee> employees=Employee.createCriteria().list{
'address'{
eq('city',params.city)
}
}
Run Code Online (Sandbox Code Playgroud)
注意:当eq('city',city)使用(相同参数名)时,将不起作用。
| 归档时间: |
|
| 查看次数: |
3120 次 |
| 最近记录: |