【问题标题】:Error in DetachedCriteria using 'between'使用“介于”的 DetachedCriteria 中的错误
【发布时间】:2017-10-01 23:32:57
【问题描述】:

只有当我在 DetachedCriteria 中的 association 中使用“between”时才会发生该错误:

错误:

org.hibernate.QueryException: 无法解析属性:execution_alias1 of: ExecutionService

标准:

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

域类:

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 版本:3.1.8

【问题讨论】:

    标签: grails hibernate-criteria detachedcriteria


    【解决方案1】:

    当我在“构建”中有另一个块时,“中间”似乎不起作用(就像我的例子中的“执行”块)。

    所以我使用该解决方案(将“之间”更改为“ge”和“le”):

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 2020-07-03
      • 1970-01-01
      相关资源
      最近更新 更多