Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 冬眠和枣_Hibernate_Timestamp_Date - Fatal编程技术网

Hibernate 冬眠和枣

Hibernate 冬眠和枣,hibernate,timestamp,date,Hibernate,Timestamp,Date,我想用hibernate获取开始日期和结束日期之间的记录 id startDate endDate 15 2011-01-05 05:05:10 2011-05-01 09:05:10 37 2010-03-01 05:06:10 2010-06-01 09:07:10 49 2005-01-05 03:03:03 2005-05-01 08:08:08 我想在提供startDat

我想用hibernate获取开始日期和结束日期之间的记录

id     startDate                 endDate
15     2011-01-05 05:05:10   2011-05-01 09:05:10 
37     2010-03-01 05:06:10   2010-06-01 09:07:10
49     2005-01-05 03:03:03   2005-05-01 08:08:08                  
我想在提供startDate=2011-01-05 05:05:10和endDate=2011-05-01 09:05:10时检索15

如果提供startDate=2010-03-01 05:06:10和endDate=2010-06-01 09:07:10,我想检索37


有人能告诉我如何使用hibernate吗?我尝试使用between子句,但不起作用

您尝试使用什么标准?如果startDate和endDate都需要匹配才能返回行,则可以尝试使用以下限制:

Restrictions.and(Restrictions.eq("startDate",startDateValue),Restrictions.eq("endDate", endDateValue))