Null value while doing createcriteria

225 Views Asked by At
def c = Employee.createCriteria()
return c.list {
  } as Set;

The above code is returning me all the objects of the table.

But when I am trying to filter it like, I am getting null values :

def c = Employee.createCriteria()
    return c.list {
    'eq'('id', 604931)
} as Set;

(or)

def c = Employee.createCriteria()
    return c.list {
    'between'('updatededOn', startDate, endDate)
} as Set;

What I exactly want is to retrieve all the rows from the Employee table where updated_on is between startDate and endDate. startDate and endDate are Date objects.

Thanks

1

There are 1 best solutions below

1
On

This should do it:

def employees = Employee.withCriteria {
    between('updatededOn', startDate, endDate)
}