当前位置: 代码迷 >> Java Web开发 >> ssh 查询语句 hql 错误
  详细解决方案

ssh 查询语句 hql 错误

热度:847   发布时间:2016-04-17 00:13:05.0
ssh 查询语句 hql 异常
Struts has detected an unhandled exception: 

Messages: unexpected token: * near line 1, column 8 [select * from trade as t where t.id=123 and t.efficient=false] 
 
File: org/hibernate/hql/ast/QuerySyntaxException.java 

是查询语句错了吗?

源代码:
public String query()
{
Session s = HibernateUtil.getSession();
Transaction t=s.beginTransaction();

String uid=application.get("r1").toString();
int a=Integer.parseInt(uid);

Query q=s.createQuery("select * from trade as t where t.id=" + a + " and t.efficient=false");
List<Trade> trades=(List<Trade>)q.list();
application.put("result", trades);

return SUCCESS;
}
我想把查询结果存放在application中 然后在jsp页面中显示出查询结果

------解决方案--------------------
hql里没有*一说
------解决方案--------------------
false 要加单引号么?
------解决方案--------------------
from trade as t where t.id=" + a + " and t.efficient=false
  相关解决方案