0

The error only happens when I use the 'between' inside of an association in a DetachedCriteria:

Error:

org.hibernate.QueryException: could not resolve property: execution_alias1 of: ExecutionService

Criteria:

new DetachedCriteria(Service).build {
    execution {
        between('date', new Date() -1, new Date())
    }
}.list()

Domain Classes:

class Service{

   static hasOne = [execution: ExecutionService]

   static constraints = {
      execution nullable: true
   }
}

class ExecutionService {

   Date date
   static belongsTo = [servico: Servico]

   static constraints = {
      date nullable: true
      servico nullable: true
   }
}

OBS: Grails version: 3.1.8

Victor Soares
  • 757
  • 1
  • 8
  • 34

1 Answers1

0

The 'between' doesn't seem to work when I have another block inside the 'build' (like the "execution" block in my case).

So I use that solution (changing 'between' to 'ge' and 'le'):

new DetachedCriteria(Service).build {
    execution {
        ge 'date', new Date() -1
        le 'date', new Date()
    }
}.list()
Victor Soares
  • 757
  • 1
  • 8
  • 34