O'Reilly logo

Grails in Action, Second Edition by Glen Smith and Peter Ledbrook

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required