I am using HibernateCriteriaBuilder
api to write my Criteria Queries. I want to know if inside Criteria
we can have conditional logic, such as an if
statement?
For example:
OnemonthList=it.createCriteria().list {
if (res_id!='all'){
eq('graresource',resourceInstance)
}
between('currentdate', fromDate, toDate)
projections {
trans {
countDistinct('id')
}
groupProperty('currentdate')
}
}
Is this valid?