2
我想查找在特定日期处于活动状态的所有事件实体。例如:查找Hibernate实体,其日期介于可以为null的开始日期和结束日期之间
from Event where startDate <= :specifiedDate and endDate > :specifiedDate
然而,Event.startDate
和Event.endDate
可以null
。 A null
值表示没有开始或结束日期(过去的开始是无限的,或者将来的结束是无限的)。
因此,if Event.startDate = null and Event.endDate = 2011-05-01
,那么对于小于2011-05-01的所有指定日期值,应该返回该事件。
也if Event.startDate = 2011-03-01 and Event.endDate = null
,那么该事件应返回所有指定的日期值大于或等于2011-03-01。
最后,if Event.startDate = null and Event.endDate = null
,那么应该返回任何指定日期的事件。
这可能使用Hibernate和MySQL后端?
感谢,看起来像它的工作! – Tauren