How would I go about converting Grails where syntax comparing two properties, for example,
where { prize > entryFee }
Into Grails CriteriaBuilder syntax comparing the values of two columns?
Something like,
def c = Tournament.createCriteria()
def results = c {
gt 'prize', tournament.entryFee
}
There are *Property
nodes you can use in the criteria for comparing two properties.
In your case, you'd want something like:
def c = Tournament.createCriteria()
def results = c {
gtProperty 'prize', 'entryFee'
}
There are also geProperty
, eqProperty
, neProperty
, ltProperty
and leProperty
for greater than equal, equal, not equal, less than, and less than equal, respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With