Comparing two columns in Grails criteria builder?

How do I switch to a Grails transform where the syntax compares two properties, for example

where { prize > entryFee }

In Grails CriteriaBuilder syntax comparing values ​​of two columns?

Sort of,

def c = Tournament.createCriteria()
def results = c {
   gt 'prize', tournament.entryFee
}
+4
source share
1 answer

There are nodes *Propertythat you can use in the criteria to compare two properties.

In your case, you need something like:

def c = Tournament.createCriteria()
def results = c {
    gtProperty 'prize', 'entryFee'
}

There are geProperty, eqProperty, neProperty, ltPropertyand lePropertyfor more than an equal, equal, not equal, less and less equal, respectively.

+6
source

Source: https://habr.com/ru/post/1531239/


All Articles