使用'之间'在DetachedCriteria中出错

时间:2017-05-03 23:57:59

标签: grails hibernate-criteria detachedcriteria

只有当我在 DetachedCriteria 中使用关联内的“ ”时才会出现错误:

错误:

  

org.hibernate.QueryException:无法解析属性:execution_alias1: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

1 个答案:

答案 0 :(得分:0)

当我在'build'中有另一个块时,'between'似乎不起作用(就像我的情况中的“execution”块一样)。

所以我使用那个解决方案(将'介于''改为'ge'和'le'):

S-1-5-18 C:\Windows\system32\config\systemprofile\AppData\Roaming
S-1-5-19 C:\Windows\ServiceProfiles\LocalService\AppData\Roaming
S-1-5-20 C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming
S-1-5-21-*-1000 C:\Users\defaultuser0\AppData\Roaming
S-1-5-21-*-1001 C:\Users\<user>\AppData\Roaming