My Employee domain has an associated division, department, and position, which are all domains themselves. This relationship is coded as
class Employee
{
...
String firstName
String lastName
Position position
Division division
Department department
...
}
(note that there is no belongsTo
or hasOne
relationship) I send in the id of each of these selected from a drop-down list with
<g:select name="department" from="${Department.list()}" optionKey="id" optionValue="${{it.name}}" />
(similarly for division and position), but I am getting an error with the code querying the database
def employeeList = Employee.createCriteria().list(sort: params.sort, order: params.order)
{
and
{
ilike "firstName", "%${params.firstName}%"
ilike "lastName", "%${params.lastName}%"
}
position
{
eq "position", ${params.position}
}
department
{
eq "department", ${params.department}
}
division
{
eq "division", ${params.division}
}
}
The error I get is
No signature of method: EmployeeController.department() is applicable for argument types: (EmployeeController$_results_closure1_closure4) values: [EmployeeController$_results_closure1_closure4@f559db0]
I've tried putting in the division/department/position eq
snippets inside the and block, but that fails with the error
No signature of method: EmployeeController.and() is applicable for argument types: (EmployeeController$_results_closure1_closure4) values: [EmployeeController$_results_closure1_closure4@2f3302f3]
Any ideas what I'm doing wrong?