2
http://jira.grails.org/browse/GRAILS-2803由於缺少對sqlProjection的支持。它作爲一個重複被封閉,據說在Grails v1.2中被修復。但是,「重複」問題涉及到sqlRestriction,我不認爲sqlProjection至少已經在Grails v1.3.2中實現。解決標準構建器中缺少sqlProjection支持的問題?
是否有任何解決方法在critera中使用sqlprojection?例如,
def results = Report.createCriteria() list {
projections {
sum('correctResponses')
sum('allResponses')
sqlProjection("(sum(correct_responses)/sum(all_responses))", ["grade"] as String[], [Hibernate.INTEGER] as Type[])
groupProperty('name')
}
and {
if (startDate)
ge("date", startDate)
if (endDate)
lt("date", endDate + 1) //add one day so search is inclusive of end date
'in' ("id", ids)
}
order(orderColumn ?: 'name', orderDirection ?: 'asc')
}