查询执行请求异常

时间:2014-12-11 08:40:13

标签: java mysql

我正在尝试使用文件表的外键帮助更新文档表中的记录,但它会给出QueryExecutionRequestException的错误。如何通过外键更新文档中的记录?

@ DAO代码

public void forwardTo(File ob, Person selectedP, long pid)
    {
        log.debug("Document forwarding ");
        try {
            System.out.println("in dao");
            System.out.println(ob.getFileRefNo());
            String queryString = "update Document d set d.onDeskOfPerson=:onDeskOfPerson, d.person=:person where d.file=:file";
            System.out.println("after update query");
            Query queryObject = getSession().createQuery(queryString);
            queryObject.setParameter("onDeskOfPerson", selectedP.getLogin());
            queryObject.setParameter("person", selectedP);
            queryObject.setParameter("file", ob);
            Document doc = (Document)queryObject.list().get(0);
            getSession().merge(doc);
            System.out.println("after merge");
            int result=queryObject.executeUpdate();
            System.out.println("Rows affected="+result);
            log.debug("save successful");


        } catch (RuntimeException re) {
            log.error("find all failed", re);
            throw re;
        }
    }
}

@error log

Dec 11, 2014 1:29:48 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [update com.model.filling.Document d set d.onDeskOfPerson=:onDeskOfPerson, d.person=:person where d.file=:file]
javax.el.ELException: org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [update com.model.filling.Document d set d.onDeskOfPerson=:onDeskOfPerson, d.person=:person where d.file=:file]
    at org.apache.el.parser.AstValue.invoke(AstValue.java:291)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [update com.model.filling.Document d set d.onDeskOfPerson=:onDeskOfPerson, d.person=:person where d.file=:file]
    at org.hibernate.hql.ast.QueryTranslatorImpl.errorIfDML(QueryTranslatorImpl.java:297)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:346)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at com.dao.filling.DocumentDAO.forwardTo(DocumentDAO.java:259)
    at com.service.filling.FillingDataManager.forawrdDoc(FillingDataManager.java:158)
    at com.controller.Controller.forwardDoc(Controller.java:207)
    at com.managedBean.Filling.FileMB.forward(FileMB.java:298)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
    ... 27 more

Dec 11, 2014 1:29:48 PM com.sun.faces.context.AjaxExceptionHandlerImpl handlePartialResponseError
SEVERE: org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations [update com.model.filling.Document d set d.onDeskOfPerson=:onDeskOfPerson, d.person=:person where d.file=:file]
    at org.hibernate.hql.ast.QueryTranslatorImpl.errorIfDML(QueryTranslatorImpl.java:297)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:346)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at com.dao.filling.DocumentDAO.forwardTo(DocumentDAO.java:259)
    at com.service.filling.FillingDataManager.forawrdDoc(FillingDataManager.java:158)
    at com.controller.Controller.forwardDoc(Controller.java:207)
    at com.managedBean.Filling.FileMB.forward(FileMB.java:298)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
    at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
    at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:813)
    at javax.faces.component.UICommand.broadcast(UICommand.java:300)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

1 个答案:

答案 0 :(得分:0)

您致电Document doc = (Document)queryObject.list().get(0);

更新查询不允许的内容。