获取时间段内的数据hql语句报错,怎么回事,求解答!!!

2017-3-28 15:24:21

Tue Mar 14 00:00:00 CST 2017

from AySupervise a where a.hostDate between Tue Mar 14 00:00:00 CST 2017 and Sat Mar 18 00:00:00 CST 2017 and a.personId = ? order by a.hostDate desc

第一个是hostDate时间日期格式,第二个是从页面获取到的字符串时间,我自己转化成日期格式,第三个是hql语句,下面是报的错
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: Mar near line 1, column 77 [from com.sysway.supervise.entity.AySupervise a where a.hostDate between Tue Mar 14 00:00:00 CST 2017 and Sat Mar 18 00:00:00 CST 2017 and a.personId = ? order by a.hostDate desc ]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: Mar near line 1, column 77 [from com.sysway.supervise.entity.AySupervise a where a.hostDate between Tue Mar 14 00:00:00 CST 2017 and Sat Mar 18 00:00:00 CST 2017 and a.personId = ? order by a.hostDate desc ]

1个回答

你数据库的时间字段是时间格式还是字符串格式,还有你的时间格式引的是java util 还是sql的?

lm121342074
lm121342074 数据库的时间是TIMESTAMP格式的,时间引用格式是util包下的
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问