Grails withCriteria,两个数据库列之间的值?

Grails withCriteria, value between two database columns?

如何测试一个值是否介于我的两个数据库列之间?

我需要做这样的事情:

between(column1, column2, 'value')

或类似这样的内容:

or{
   and {
         ge("hora_inicio", evento.hora_inicio)
         le("hora_fim", evento.hora_inicio)
      }
   and {
         ge("hora_inicio", evento.hora_fim)
         le("hora_fim", evento.hora_fim)
       }
  }

有什么想法吗?

谢谢!

没有检查两列是否在一个值之间的选项。您将不得不进行两次单独的比较。虽然您可以将一个数据库列与另一个数据库列进行比较,但它并不像您想要的那样。请参阅此处的文档:http://docs.grails.org/latest/ref/Domain%20Classes/createCriteria.html

从您的第二个示例来看,您似乎需要找到所有开始时间介于 evento.hora_inicio 和 evento.hora_fim 之间或订购时间介于 evento.hora_inicio 和 evento.hora_inicio 之间的条目evento.hora_fim.

感觉可以简化为查找所有在 evento.hora_fim 之前有 hora_inicio 并且在 evento.hora_inicio 之后有 hora_fim 的条目。那看起来像这样:

Event evento = getEventFromSomewhere()
Appointment.createCriteria().list{
    le 'hora_inicio', evento.hora_fim
    ge 'hora_fim', evento.hora_inicio
}