Hibernate - 意外令牌:在更新时

时间:2014-01-14 11:14:49

标签: hibernate

我收到此错误,我无法确定查询中是否有任何错误。

错误是:

ERROR: line 1:8: unexpected token: in line 1:8: unexpected token: in

at org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:232).......</code>

I am trying to update a table by HQL, following is that code:

Query query = session.createQuery("update Order set paymentStatusId = :pid where id = :id");
    query.setParameter("pid", paymentStatusId).setParameter("id", orderId);
query.executeUpdate();

My POJO is below:

at org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:232).......</code>

1 个答案:

答案 0 :(得分:0)

订单是HQL的保留字。您可以尝试更改实体的名称或将实体名称括在括号中(未测试): http://www.javaplex.com/blog/hibernate-how-to-use-databases-reserved-keywords-in-hql-and-pojos/