Last active
August 29, 2015 14:01
-
-
Save ddelponte/382f907886457045aa8d to your computer and use it in GitHub Desktop.
Have criteria projections return a map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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