hibernategrailsgrails-ormcreatecriteria

Grails - how to use "OR" in CreateCriteria


I have this Criteria:

def myList =  BAS.createCriteria().list () {
  projections { distinct ( "id" ) 
      property("date")
      property("id")
  }

  carList{ 
      eq("login",login)    
          }

  ccList{
      eq("cmd",false)
        }


  order("date","desc")
}

I want to add also null as a criteria for "cmd". Is there an OR to be used in my case?

Thanks


Solution

  • Yes, there is an OR that you can use in this case.

    ccList {
      or {
        eq("cmd", false)
        isNull("cmd")
      }
    }
    

    The documentation has this and other options outlined. Further information is also found throughout the rest of the documentation.