Problema com Criteria, Associação e Between
03/05/2017 18:37
new DetachedCriteria(Requisicao).build {
servico {
execucao {
between('dataExecucao', new Date().parse("dd/MM/yyyy", '01/01/2000'), new Date())
}
}
}.list()
class Requisicao {
static hasOne = [servico:Servico]
static constraints = {
servico nullable: false
}
}
class Servico {
static belongsTo = [requisicao: Requisicao]
static hasOne = [execucao: ExecucaoServico]
static constraints = {
requisicao nullable: false
execucao nullable: true
}
}
class ExecucaoServico {
Date dataExecucao
String texto
static belongsTo = [servico: Servico]
static constraints = {
dataExecucao nullable: true
texto nullable: true
servico nullable: true
}
}?
new DetachedCriteria(Requisicao).build {
servico {
execucao {
ge 'dataExecucao', new Date().parse("dd/MM/yyyy", '01/01/2000')
le 'dataExecucao', new Date()
}
}
}.list()
Para se registrar, clique aqui.