gpt4 book ai didi

java - 查询执行请求异常

转载 作者:行者123 更新时间:2023-11-29 23:19:53 25 4
gpt4 key购买 nike

我尝试借助文件表的外键更新文档表中的记录,但出现 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;
}
}
}

@错误日志

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)

最佳答案

您调用Document doc = (Document)queryObject.list().get(0);

更新查询不允许什么。

关于java - 查询执行请求异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27418535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com