Why does findAllBy * fail when using three conditions in Grails / GORM?

Consider the following applications of the Grails / GORM findAllBy * dynamic search method:

def foo1 = Foo.findAllByYear(yyyy)
def foo2 = Foo.findAllByMonth(mm)
def foo3 = Foo.findAllByDay(dd)
def foo4 = Foo.findAllByYearAndMonth(yyyy, mm)
def foo5 = Foo.findAllByYearAndDay(yyyy, dd)
def foo6 = Foo.findAllByYearAndMonthAndDay(yyyy, mm, dd)

println "# foo1=${foo1.size()} foo2=${foo2.size()} foo3=${foo3.size()}"
println "# foo4=${foo4.size()} foo5=${foo5.size()} foo6=${foo6.size()}"

The first five of these dynamic search engines work as expected.

However, the sixth of them does not work with InvalidPropertyException ("There is no property found for the name [yearAndMonth] for the class [class foo]").

Question:

Why does the sixth not work? Isn't findAllBy able to handle more than two conditions? Solution / workaround?

+3
source share
2 answers

Ted , , Grails , , , , , .

...

  • , findAllByYearAndMonthAndDay(1999,2,3)
  • , findAllByYearOrMonthOrDay(1999,2,3)
  • , findAllByYearOrMonthAndDay(1999,2,3)

, ( and or s), , . , Grails JIRA, , . , .

, IntelliJ Grails .

/ - Criteria HQL.

+10

, . . findAllWhere.

+4

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


All Articles