Hibernate Criteria Builder

Dynamic finders are great, and as you work with Grails, you will find yourself using them again and again, but they can take you only so far. For one thing, they are limited to top-level properties of the class—you cannot use dynamic finders to search relationships.

Our next search feature is to find TekEvent instances for which a logged-in user has volunteered. Volunteers for an event are in the volunteers collection, which is the result of a one-to-many relationship between TekEvent and TekUser. To search relationships, we must turn to a different tool in the Grails toolbox.

The Criteria Builder in Grails is a very powerful and flexible tool for retrieving objects. It is based on the Hibernate Criteria API, so ...

Get Grails 2: A Quick-Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.