hibernate如何使用hql语句查询时间区间段

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/personbing/article/details/51548529


最近需要做一个根据时间段查询教师的获奖信息。

在使用hibernate的hql语句时发现使用平时的String类型进行查询总是报错查询得到以下结果

1、写出类似于 以下的hql语句 

hql = "from TeacherAward where awardState = 2  and  awardTime >= ? and awardTime <= ?  ";

2、查询时的操作语句为:

Query query = getSessionFactory().getCurrentSession().createQuery(hql);
		query.setDate(0, startTime);
		query.setDate(1,stopTime );
通过上述写法就可以实现根据时间段查询教师获奖信息。
 
 

猜你喜欢

转载自blog.csdn.net/personbing/article/details/51548529
今日推荐