Grails Domain Query
Criteria queries are a type safe advanced way to query that uses a groovy builder to construct potentially complex queries.
Grails domain query. The basic syntax is. Readonly true if returned objects should not be automatically dirty. Sort the property name to sort by.
Offset the offset from the first result to list from. Use where criteria since grails 2 0 def results person findall lastname simpson def results person findall sort. Max the maximum number to list.
Controllers might create a model or may process them. Ignorecase whether to ignore the case when sorting. The executequery method allows the execution of arbitrary hql queries.
The list method on named queries supports the same attributes as the static list method added to domain. Named queries support the criteria builder syntax. Fetch the fetch policy for the object s associations as a map.
Refer to the user guide section on criteria for usage instructions. Grails will then examine the method name you use and generate an appropriate implementation including the corresponding database query. Package example grails import grails gorm services query import grails gorm services service import grails gorm services join import grails gorm transactions transactional import groovy util logging slf4j interface ipersondataservice person findbyname string name integer findpersonage string name number count join addresses 1.
Gsp is responsible for how to display the model to the user. For example if i want to find all the board games with an average play duration between 30 and 90 minutes it might look like this. Hql queries can return domain class instances or arrays of specified data when the query selects individual fields or calculated values.