• nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'hospitalid' in 'class java.lang.Long'


    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'hospitalid' in 'class java.lang.Long'
    	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
    	at com.sun.proxy.$Proxy26.selectList(Unknown Source)
    	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
    	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
    	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
    	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
    	at com.sun.proxy.$Proxy27.selectAllHospital(Unknown Source)
    	at com.zhicall.ihospital.service.impl.BasicServiceAgencyServiceImpl.selectAllHospital(BasicServiceAgencyServiceImpl.java:22)
    	at com.zhicall.ihospital.controller.HospitalDepartmentDoctorController.selectHospitalList(HospitalDepartmentDoctorController.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
    	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
    	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)
    	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)
    	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:933)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:867)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:951)
    	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:853)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:827)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at com.zhicall.ihospital.filter.HttpOptionsFilter.doFilter(HttpOptionsFilter.java:31)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'hospitalid' in 'class java.lang.Long'
    	at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380)
    	at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170)
    	at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152)
    	at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48)
    	at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)
    	at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97)
    	at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116)
    	at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    	at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
    	at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    	at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)
    	at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    	at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    	at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    	at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    	at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    	at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    	at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    	at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)
    	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    	at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
    	at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
    	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
    	at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:401)
    	at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:374)
    	at com.github.pagehelper.PageHelper.intercept(PageHelper.java:254)
    	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)
    	at com.sun.proxy.$Proxy42.query(Unknown Source)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
    	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    	... 44 more
    

      本想着从前端传入一个Long类型的id来查询一个列表,结果报了这个错,在网上看到了两种方法,用的第一种解决的

      第一种:用"_parameter"代替当前参数

    <select id="selectSubjectByPId"  parameterType="java.lang.Integer" resultType="java.util.Map">
            select subjectId,subjectName 
            from ts_subject 
            where subjectParentId= 0 
            <if test="_parameter != null">
                and subjectId = #{_parameter,jdbcType=INTEGER}
            </if>
    </select>

      第二种:解决方案很简单,在java代码中使用@Param 标签指定传入参数名称即可;

    public String queryMethodName(@Param(value="varName") Long varName);
  • 相关阅读:
    php生成excel
    gearmand
    开启Nginx的目录文件列表功能
    zend框架学习
    引用方法形成树
    智能指针实现
    图文例解C++类的多重继承与虚拟继承
    CC++定位崩溃代码行的方法
    C++函数重定义、重载、重写
    勤奋吧,一天一点,努力提高基本技能。
  • 原文地址:https://www.cnblogs.com/huashuohehe/p/8819275.html
Copyright © 2020-2023  润新知