Just a quick gotcha for grails criterias when you want to count the results from a query where there is a join involved. If you use
count = criteria.count {
projections {
rowCount()
}
query()
}
You'll get a count for each of the joins, you might think that you could use
count = criteria.count {
projections {
countDistinct('id')
}
query()
}
But that still doesn't work - you have to use
count = criteria.get {
projections {
countDistinct('id')
}
query()
}
Hmmm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment