Comparing two columns in a Grails criteria builder?

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
}

Answers


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.


Need Your Help

EncodeDecodeMux - Samsung Devices - Tested on S6 Edge and S5

android samsung-mobile codec mediacodec mediamuxer

Reference: https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/ExtractDecodeEditEncodeMuxTest.java

passing jquery ui autocomplete selection into variable

jquery variables select user-interface autocomplete

I have a JQuery function to change the color of a button while adding or removing a href attribute to it. It works perfectly if I initiate it with blur like