调试过程中出现的异常一:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: Dec near line 1, column 74 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:Sat Dec 01 00:00:00 CST 2007 and model.medPurchaseDate<=:Thu Dec 13 00:00:00 CST 2007]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: Dec near line 1, column 74 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:Sat Dec 01 00:00:00 CST 2007 and model.medPurchaseDate<=:Thu Dec 13 00:00:00 CST 2007]
调试过程中出现的异常二:
org.springframework.orm.hibernate3.HibernateQueryException: expecting IDENT, found ''2007-12-01'' near line 1, column 70 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:'2007-12-01' and model.medPurchaseDate<=:'2007-12-13']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found ''2007-12-01'' near line 1, column 70 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:'2007-12-01' and model.medPurchaseDate<=:'2007-12-13']
请各位根据我的问题,参考所出现的异常,帮帮忙!
在线等......
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: Dec near line 1, column 74 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:Sat Dec 01 00:00:00 CST 2007 and model.medPurchaseDate<=:Thu Dec 13 00:00:00 CST 2007]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: Dec near line 1, column 74 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:Sat Dec 01 00:00:00 CST 2007 and model.medPurchaseDate<=:Thu Dec 13 00:00:00 CST 2007]
调试过程中出现的异常二:
org.springframework.orm.hibernate3.HibernateQueryException: expecting IDENT, found ''2007-12-01'' near line 1, column 70 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:'2007-12-01' and model.medPurchaseDate<=:'2007-12-13']; nested exception is org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found ''2007-12-01'' near line 1, column 70 [from com.hnyb.beans.Medicines as model where model.medPurchaseDate>=:'2007-12-01' and model.medPurchaseDate<=:'2007-12-13']
请各位根据我的问题,参考所出现的异常,帮帮忙!
在线等......
解决方案 »
- hibernate session和thread绑定问题
- hibernate 自关联 多对多关系
- 关于EJB3.0远程调用的问题
- 求这几道题的答案,再次谢谢大家了!!!很着急,谢谢了!!!!!!!!!!!!!!
- jdom包里面都是什么东西?都有用吗?
- 初学 spring + hibernate ,头大了,有几个小问题帮忙,谢谢大家
- MyEclipse 9 引包后没有Refernced Libraries选项,这是怎么回事
- 散分小高潮。
- 帮忙
- 如何快速的进行list<object> 中的对象和数据库中的记录进行比对list来自于excel文件的解析(其中含有多人,没人对应多条数据)求解
- JSP问题 等待中
- struts多模块中的url显示问题
public class SearchMebBuysReportAction extends ActionSupport
{
private static final long serialVersionUID = 1813751387942060177L;
/*
private String hql = "from ? as a where a.qdrq< =:qdrq2 and a.qdrq >= :qdrq1";
String qdrq1;
String qdrq2;
query.setString("qdrq1",qdrq1);
query.setString("qdrq2",qdrq2);
*/
private String dateFrom;
private String dateTo;
private List meds;
public String execute()
{
meds = new ArrayList();
MedicinesDAO md = (MedicinesDAO)InitSpring.getInstance("MedicinesDAO");
meds = md.findByPurchaseDate(dateFrom, dateTo);
System.out.println("=========================");
System.out.println(meds.size());
System.out.println(meds);
System.out.println("=========================");
return SUCCESS;
}
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
public void setDateFrom(Date dateFrom)
{
//dateFrom.toString();
this.dateFrom = df.format(dateFrom);
} public void setDateTo(Date dateTo)
{
this.dateTo = df.format(dateTo);
}
}
DAO的关于查询的代码
public List findByPurchaseDate(String start,String end)
{
log.debug("finding Medicines instance between: " + start
+ ", and: " + end);
try
{
String queryString = "from Medicines as model where model.medPurchaseDate>=:'"
+start+ "' and model.medPurchaseDate<=:'"+end+"'";
return getHibernateTemplate().find(queryString);
}
catch(RuntimeException re)
{
log.error("find by property name failed", re);
throw re;
}
}
你看你的冒号是不是多余的?
"from Medicines as model where model.medPurchaseDate> = to_date('" + start + "','yyyy-mm-dd') and model.medPurchaseDate <= to_date('"+end+"','yyyy-mm-dd')";