如何使用其他操作

时间:2016-05-18 19:47:13

标签: hibernate hql

我需要使用更新HQL查询来计算金额,但我找不到正确的方法。 Hibernate给了我:

  

java.lang.IllegalArgumentException:要遍历的节点不能为空

这是我的代码:

 String upd = "update Clients client set client.balance=client.balance + ? " +
   "where client.idClient = " + ob.getIdClient();
Query qry = session.createQuery(upd);
qry.setInteger(0, ob.getBalance());
int res = qry.executeUpdate();
  

2016-05-18 17:08:27,183 ERROR - 第1:8行:意外的令牌:by   2016-05-18 17:08:27,213错误 - 第1:8行:意外的令牌:by   第1:8行:意外的令牌:by       在org.hibernate.hql.internal.antlr.HqlBaseParser.updateStatement(HqlBaseParser.java:239)       在org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:169)       在org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:295)       在org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)       在org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)       在org.hibernate.engine.query.spi.HQLQueryPlan。(HQLQueryPlan.java:131)       在org.hibernate.engine.query.spi.HQLQueryPlan。(HQLQueryPlan.java:93)       在org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)       at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)       在org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)       在org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1836)       在by.telnet.dao.DaoClients.updateBalance(DaoClients.java:30)       在by.telnet.services.command.ClientCommand.updateBalance(ClientCommand.java:111)       在by.telnet.command.Command.pay(Command.java:140)       在by.telnet.controllers.MainServlet.switcher(MainServlet.java:82)       在by.telnet.controllers.MainServlet.doPost(MainServlet.java:24)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:648)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:729)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)       在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)       在org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:672)       在org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun(AprEndpoint.java:2508)       在org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:2497)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)       在java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案