Skip to content

Instantly share code, notes, and snippets.

@ddelponte
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddelponte/382f907886457045aa8d to your computer and use it in GitHub Desktop.
Save ddelponte/382f907886457045aa8d to your computer and use it in GitHub Desktop.
Have criteria projections return a map
import org.hibernate.criterion.CriteriaSpecification
BlogEntry.withCriteria {
maxResults 5
resultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP)
projections {
count('id', 'total')
groupProperty('author', 'author')
}
}
// And another example
def importedDate = AwesomeDomain.withCriteria(uniqueResult: true) {
eq "propertyName1", someValue
eq "propertyName2", someValue
projections {
property "propertyName1", "propertyName1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment