我有一个名为 Application 的域类,如下所示:
class Application {
static hasOne = [resumption:Resumption, employee:Employee]
//Employee employee
Date startDate
Date endDate
Integer amountOfDays
String leaveRecommended
String leaveNotRecommended
Date supervisorDate
String toString(){
return "Application for ${employee.lastName}, ${employee.firstName}"
}
}
def applicationlist(){
if(!params.max){
params.max = 10
}
def query
def criteria = Application.createCriteria()
def results
query = { eq("employee_id", Long.parseLong("1")) }
results = criteria.list(params, query)
render(view:"employeeapplicationlist", model:[applicationlist:results])
}
最佳答案
标准 DSL 中的关联具有以下形式
Application.withCriteria{
employee{
eq 'id', 1
}
}
def employee = Employee.proxy(1)
Application.findAllByEmployee( employee )
https://stackoverflow.com/questions/9765013/