嵌套异常为org.hibernate.queryparameterexception:找不到命名参数[limit]

9bfwbjaz  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(440)

关闭。这个问题需要细节或清晰。它目前不接受答案。
**想改进这个问题吗?**通过编辑这个帖子来添加细节并澄清问题。

上个月关门了。
改进这个问题

public java.util.Collection findEstablishmentProfessionalsByUsernameEstId(
            java.lang.String espUseUsername, java.lang.Integer espEstId, Integer limit) throws GenericBusinessException {
        try {

            ArrayList paramList = new ArrayList();
            List valueList = new ArrayList();

            paramList.add(new String("espEstId"));
            valueList.add(espEstId);

            paramList.add(new String("espUseUsername"));
            valueList.add(espUseUsername);

            String queryString = "from "
                    + EstablishmentProfessionalsBean.class.getName()
                    + " e where e.espEstId = :espEstId and e.espRecordStatus='approved' and e.espUseUsername=:espUseUsername and e.espShow=1";
            // Add a an order by on all primary keys to assure reproducable
            // results.

            queryString += " order by e.espSurname ASC,e.espInitials ASC,e.espExtClinicName ASC";
            if(limit != null && limit.intValue() > 0){
                paramList.add(new String("limit"));
                valueList.add(limit);
            }       
            String params [] = (String []) paramList.toArray (new String [paramList.size ()]);
            List list = hibernateTemplate.findByNamedParam(queryString,params, valueList.toArray());
            return list;
        } catch (DataAccessException e) {
            log.error("DataAccessException", e);
            throw new GenericBusinessException(e);
        } finally {
            log.debug("finished findEstablishmentProfessionalsByUsernameEstId((java.lang.String espUseUsername, java.lang.Integer espEstId, Integer limit)");
        }
    }

following are the stack trace

堆栈跟踪
com.riomed.cellma.exception.genericbusinessexception:org.springframework.orm.hibernate3.hibernatequeryexception:找不到命名参数[limit];嵌套异常为org.hibernate.queryparameterexception:在com.riomed.cellma.session.cellmafacade.findestablishmentprofessionalsbyusernameestid(cellmafacade)中找不到命名参数[limit]。java:30866)位于java.base/jdk.internal.reflect.nativemethodaccessorimpl.invoke0(本机方法)java.base/jdk.internal.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl。java:62)在java.base/jdk.internal.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl。java:43)在java.base/java.lang.reflect.method.invoke(method。java:566)在org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils。java:310)位于org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation。java:182)在org.springframework.aop.framework.reflectivemethodinvocation.procedue(reflectivemethodinvocation。java:149)在org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor。java:106)在org.springframework.aop.framework.reflectivemethodinvocation.procedue(reflectivemethodinvocation。java:171)在org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy。java:204)在com.sun.proxy.$proxy321.findestablishmentprofessionalsbyusernameestid(未知来源),网址:com.riomed.cellma.cellma.util.generalweblayerutils.addajaxextracdetailsentryforqucid(generalweblayerutils)。java:4252)在com.riomed.cellma.cellma.util.assessmentssavequestionsutils.savereferralrecordforquestionanswered(assessmentssavequestionsutils。java:178)在com.riomed.cellma.actions.savequestionsresultaction.execute(保存问题结果操作)。java:239)在org.apache.struts.action.requestprocessor.processactionperform(requestprocessor。java:421)在org.apache.struts.action.requestprocessor.process(requestprocessor。java:226)位于org.apache.struts.action.actionservlet.process(actionservlet)。java:1164)在org.apache.struts.action.actionservlet.dopost(actionservlet。java:415)在javax.servlet.http.httpservlet.service(httpservlet。java:660)在javax.servlet.http.httpservlet.service(httpservlet。java:741)位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:231)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在filters.setcharacterencodingfilter.dofilter(setcharacterencodingfilter。java:167)位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter。java:53)位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)位于org.springframework.orm.hibernate3.support.opensessioninviewfilter.dofilternternal(opensessioninviewfilter)。java:198)在org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter。java:76)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.responseoverridefilter.dofilter(responseoverridefilter。java:128)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.sensitivedatacheckfilter.dofilter(sensitivedatacheckfilter。java:1944)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.csrffilter.dofilter(csrffilter。java:1726)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.xssfilter.dofilter(xssfilter。java:2301)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.patientselectioncheckfilter.dofilter(patientselectioncheckfilter。java:416)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.authorizationfilter.dofilter(authorizationfilter。java:1598)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.authenticationfilter.dofilter(authenticationfilter。java:287)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在com.riomed.cellma.filter.messagedisplayfilter.dofilter(messagedisplayfilter。java:138)在org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在org.tuckey.web.filters.urlrewrite.rulechain.handlerewrite(rulechain。java:176)在org.tuckey.web.filters.urlrewrite.rulechain.dorules(规则链。java:145)在org.tuckey.web.filters.urlrewrite.urlrewriter.processrequest(urlrewriter。java:92)在org.tuckey.web.filters.urlrewrite.urlrewritefilter.dofilter(urlrewritefilter。java:394)位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter。java:239)在net.bull.javamelody.monitoringfilter.dofilter(monitoringfilter。java:215)位于org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain)。java:193)在org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain。java:166)在org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve。java:202)在org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve。java:96)在org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase。java:526)在org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve。java:139)在org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve。java:92)在org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve。java:678)在org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve。java:74)在org.apache.catalina.connector.coyoteadapter.service(coyoteadapter。java:343)在org.apache.coyote.ajp.ajpprocessor.service(ajpprocessor。java:396)在org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight。java:65)在org.apache.coyote.abstractprotocol$connectionhandler.process(抽象协议。java:860)位于org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint)。java:1591)在org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase。java:49)在java.base/java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor。java:1128)在java.base/java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor。java:628)在org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread。java:61)在java.base/java.lang.thread.run(thread。java:834)原因:org.springframework.orm.hibernate3.hibernatequeryexception:找不到命名参数[limit];嵌套异常为org.hibernate.queryparameterexception:未能在org.springframework.orm.hibernate3.sessionfactoryutils.converthibernateaccessexception(sessionfactoryutils)中找到命名参数[limit]。java:642)在org.springframework.orm.hibernate3.hibernateaccessor.converthibernateaccessexception(hibernateaccessor。java:412)在org.springframework.orm.hibernate3.hibernatetemplate.doexecute(hibernatetemplate。java:424)在org.springframework.orm.hibernate3.hibernatetemplate.executewithnativesession(hibernatetemplate。java:374)在org.springframework.orm.hibernate3.hibernatetemplate.findbynamedparam(hibernatetemplate。java:943)在com.riomed.cellma.session.cellmafacade.findestablishmentprofessionalsbyusernameestid(cellmafacade。java:30862) ... 83其他原因:org.hibernate.queryparameterexception:在org.hibernate.engine.query.parametermetadata.getnamedparameterdescriptor(parametermetadata)中找不到命名参数[limit]。java:75)在org.hibernate.engine.query.parametermetadata.getnamedparameterexpectedtype(parametermetadata)中。java:81)在org.hibernate.impl.abstractqueryimpl.determinetype(abstractqueryimpl。java:413)在org.hibernate.impl.abstractqueryimpl.setparameter(abstractqueryimpl。java:383)在org.springframework.orm.hibernate3.hibernatetemplate.applynamedparametertoquery(hibernatetemplate。java:1253)在org.springframework.orm.hibernate3.hibernatetemplate$31.doinhibernate(hibernatetemplate。java:949)在org.springframework.orm.hibernate3.hibernatetemplate.doexecute(hibernatetemplate。java:419) ... 86个以上

u1ehiz5o

u1ehiz5o1#

在您的查询中:

e where e.espEstId = :espEstId and e.espRecordStatus='approved'
and e.espUseUsername=:espUseUsername and e.espShow=1

您有以下命名参数:
:espestid
:espuseusername
要替换namedparameter吗 limit 因为在你的代码里你写的是这样的:

paramList.add(new String("limit"));
valueList.add(limit);

但你的生活没有限制

相关问题