2017-05-03 23 views
0

該錯誤只有當我在的DetachedCriteria使用 '' 之間的關聯的內部發生準則:錯誤的DetachedCriteria使用 '之間'

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

回答

0

的 '之間' 似乎並不時,我有 '構建' 內的另一個塊的工作(如在我的情況下「執行」塊)。

於是我就用該溶液(以 '戈' 和 '樂' '之間' 改變):

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