0
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

Asish
  • 409
  • 2
  • 4
  • 17

1 Answers1

0

This should do it:

def employees = Employee.withCriteria {
    between('updatededOn', startDate, endDate)
}
Dónal
  • 185,044
  • 174
  • 569
  • 824
  • Other than not casting to a `Set` (which I don't think has any effect on this), this looks equivalent to the question's example. `createCriteria().list{}` and `withCriteria` achieve the same thing, and `'between'` and `between` should have the same functionality in this context. – tylerwal Feb 13 '16 at 03:11