Appendix B. GORM query reference

As you saw in the main chapters, Grails gives you plenty of options when it comes to querying. Of those, in this appendix, we focus on Where and Criteria queries, which are closely related. We detail the syntax for both options and also show you how the criteria map between the two. This will allow you to convert between Where and Criteria queries. For example, you may find the query you need in an online blog post in Criteria query form, whereas you may want to use Where queries exclusively in your code.

B.1. Where queries

You can invoke Where queries in several different ways:

def result = <domainClass>.where { <criteria> }.list() def result = <domainClass>.where { <criteria> }.get() def result = <domainClass>.where ...

Get Grails in Action, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.