Plugins You can find out about all the publicly available Grails plugins.

gorm native finders

  • Authors: null
1 vote
compile "org.grails.plugins:gorm-native-finders:0.2"

 Documentation  Source  Issues


This plugin allows Grails developers to query domain objects using native Groovy closures.


grails install-plugin gorm-native-finders




The plugin allows Grails developers to query domain objects using native Groovy closures.


Book.findAll{ book ->"%dawkins%") && book.state == Book.ACTIVE }

Book.count{ book ->"%Dawkins%") && book.releaseDate.year() > 2009 }

How the plugin works

Using an AST Transformation, the AST Tree for the closure is retained in the generated class. Later , this AST tree is used in runtime to generate the HQL query.

How to use the plugin

as usual:

grails install-plugin gorm-native-finders

What currently works

Only hibernate datasource is supported.
  • mathematical operators: +, -, *, /
  • binary comparison operators: =, >=, <=, <>, !=, like
  • logical operations &&, ||, !
  • Parentheses ( ) that indicates grouping
  • second(...), minute(...), hour(...), day(...), month(...), and year(...)
  • Any function or operator defined by EJB-QL 3.0: substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()
  • str() for converting numeric or temporal values to a readable string
  • Only hibernate datasource is supported.

What is still missing (and hopefully will be added in upcoming releases)

  • Support for multiple datasources
  • spring-data-mapping integration
  • Pagination and sorting
  • improve compilation error reporting.

Version and Compatibility

the plugin is tested with Grails 1.3 and Grails 2

releases notes


  • add support for HQL functions ( substring(), trim(), lower(), day() … etc )
  • add count method e.g. Account.count{ account -> account.branch == "London" && account.state == 1 }
  • add support for implicit joins e.g. find { Account account -> = 123456 }
  • initial release