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