读书人

ssh 查询语句 hql 错误

发布时间: 2012-02-04 15:43:08 作者: rapoo

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

读书人网 >Java Web开发

热点推荐