2012-03-15 135 views
0

我想要得到的开始日期和使用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     

我想以检索15条规定的startDate = 2011-01-05 5时05分10秒日期和结束日期时= 2011-05-01 9时05分10秒

我想以检索37提供的startDate = 2010-03-01 5点06分10秒和结束日期= 2010-06-01 9时07分10秒

任何人都可以告诉我如何使用休眠?我尝试使用之间的条款,但没有奏效。

回答

0

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

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

非常感谢! – 2012-03-16 11:33:16

+0

没问题!你能接受答案,以便你的问题被标记为已回答吗? – 2012-03-16 16:07:50