Dec 142009
 

If you would like to do anything more than idEq when using criteria with id’s you may run into some trouble.

At first look this should return every instance with an ID greater than 1:

def domainClassList = DomainClass.withCriteria { gt("id", 1) }

But you’d currently be greeted with “java.lang.ClassCastException: java.lang.Integer”

The work around is easy:

def domainClassList = DomainClass.withCriteria { gt("id", 1L) }

This of course assumes the default of java.lang.Long for the id type.

Gavin Kromhout:


Thank you for visiting.
Do look around.
Do leave a comment.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)