程序如下:
whereSQL="and t.deptid=000029"
public List listJxglType(String whereSQL) {
String hql = " from XtJxglType t where 1=1 "+whereSQL;
if(whereSQL==null|| "".equals(whereSQL))
hql = " from XtJxglType t ";
List list = xtJxglZykhDAO.find(hql);
return list;
}
public List find(String hql) {
Assert.hasLength(hql);
return getHibernateTemplate().find(hql);-------这里报错抛出异常!!!
} 后台错误信息: <ERROR>(ErrorCounter.java:33) - line 1:70: unexpected token: 9 前台页面错误信息: 错误提示 出现未知异常!org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 9 near line 1, column 70 [ from com.nbw.jxgl.domain.XtJxglType t where 1=1 and t.deptid=000029]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9 near line 1, column 70 [ from com.nbw.jxgl.domain.XtJxglType t where 1=1 and t.deptid=000029]
大家帮忙看下吧,提个建议,看到底是哪里有问题!谢了!
whereSQL="and t.deptid=000029"
public List listJxglType(String whereSQL) {
String hql = " from XtJxglType t where 1=1 "+whereSQL;
if(whereSQL==null|| "".equals(whereSQL))
hql = " from XtJxglType t ";
List list = xtJxglZykhDAO.find(hql);
return list;
}
public List find(String hql) {
Assert.hasLength(hql);
return getHibernateTemplate().find(hql);-------这里报错抛出异常!!!
} 后台错误信息: <ERROR>(ErrorCounter.java:33) - line 1:70: unexpected token: 9 前台页面错误信息: 错误提示 出现未知异常!org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 9 near line 1, column 70 [ from com.nbw.jxgl.domain.XtJxglType t where 1=1 and t.deptid=000029]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9 near line 1, column 70 [ from com.nbw.jxgl.domain.XtJxglType t where 1=1 and t.deptid=000029]
大家帮忙看下吧,提个建议,看到底是哪里有问题!谢了!
if(whereSQL==null|| "".equals(whereSQL))
hql = " from XtJxglType t ";
List list = xtJxglZykhDAO.find(hql);
不能在action中 组织或判断hql语句,
要直接去实体类里去组织或判断hql语句