MyBatis:The expression 'list' evaluated to a null value

完整错误信息:

严重: Servlet.service() for servlet [springmvc] in context with path [/xinghe-platform-web] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: The expression ‘list‘ evaluated to a null value.] with root cause
org.apache.ibatis.builder.BuilderException: The expression ‘list‘ evaluated to a null value.
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateIterable(ExpressionEvaluator.java:40)
    at org.apache.ibatis.scripting.xmltags.ForEachSqlNode.apply(ForEachSqlNode.java:54)
    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.GeneratedMethodAccessor67.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
    at com.xinghe.frame.mybatis.FlushCacheInterceptor.intercept(FlushCacheInterceptor.java:61)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)
    at com.sun.proxy.$Proxy24.query(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
    at com.xinghe.frame.mybatis.OffsetLimitInterceptor.intercept(OffsetLimitInterceptor.java:55)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:60)
    at com.sun.proxy.$Proxy24.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.GeneratedMethodAccessor71.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
    at com.sun.proxy.$Proxy17.selectList(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
    at com.xinghe.platform.dao.ResScoreDao.getByResourceLocalId(ResScoreDao.java:43)
    at com.xinghe.platform.service.ResScoreManager.getByResourceLocalId(ResScoreManager.java:41)
    at com.xinghe.platform.service.ResScoreManager$$FastClassBySpringCGLIB$$68ba2513.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at com.xinghe.platform.service.ResScoreManager$$EnhancerBySpringCGLIB$$9b94cd4.getByResourceLocalId(<generated>)
    at com.xinghe.platform.action.ResResourcePublic.getScore(ResResourcePublic.java:433)
    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.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.auth.filter.AuthorizationFilter.doFilterInternal(AuthorizationFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.auth.filter.AuthenticationFilter.doFilterInternal(AuthenticationFilter.java:115)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at com.xinghe.activate.filter.ActivateFilter.doFilterInternal(ActivateFilter.java:52)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    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:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

**环境:**Java项目,SpringMVC+MyBatis框架,

此错误的源码位置:

看到 MyBatisSystemException ,首先想到的是错误可能发生在ResScoreMapper.xml 文件中,但Dao层直接与Mapper.xml文件相关联,查看错误信息可以看到以下信息:

com.xinghe.platform.dao.ResScoreDao.getByResourceLocalId(ResScoreDao.java:43)

我遇到的这个错误就发生在这里!

错误原因:

说起错误原因,这里犯了一个小儿科的错误,从别的Dao文件中复制过来的代码,方法名改了,selectOne 中调用的Mapper中的命令空间及方法名忘记改了,所以导致此错误;

修正后如下:

由于 selectOne SQL返回多条记录时会出异常,所以这里改用:selectList 。

版权声明:本文为博主原创文章,未经博主允许不得转载。

MyBatis:The expression 'list' evaluated to a null value

时间: 2024-10-05 16:06:56

MyBatis:The expression 'list' evaluated to a null value的相关文章

mybatis之The expression &#39;oredCriteria&#39; evaluated to a null value的解决方法

<if test="example!= null"> <include refid="Example_Where_Clause" /> </if> 原因:执行过程中,显示在使用example的时候,里面的criteria为null:将上面的XML用下面替换 <if test="_parameter != null" > <include refid="Update_By_Exampl

使用MyBatis查询int类型字段,返回NULL值时报异常的解决方法

当配置mybatis返回int类型时 select id="getUserIdByName" parameterType="string" resultType="int"> SELECT id FROM user WHERE userName = #{userName} </select> 会报错如下: org.springframework.web.util.NestedServletException: Request p

MyBatis通过map传入多个参数

需求: 需要通过map传入一个list和一个String类型的参数,而且没有封装成Javabean 实现 service层 // 根据roomId查询所有的roomQtId public int queryRoomQtIdByRoomId(ArrayList<Long> roomIdList, String meetingId) { List<Long> roomQtIdlist = hotelRoomDao2.queryRoomQtIdByRoomId(roomIdList);

深入了解MyBatis参数

相信很多人可能都遇到过下面这些异常: "Parameter 'xxx' not found. Available parameters are [...]" "Could not get property 'xxx' from xxxClass. Cause: "The expression 'xxx' evaluated to a null value." "Error evaluating expression 'xxx'. Return v

(转载)深入了解MyBatis参数

原文地址:http://blog.csdn.net/isea533/article/details/44002219 深入了解MyBatis参数 相信很多人可能都遇到过下面这些异常: "Parameter 'xxx' not found. Available parameters are [...]" "Could not get property 'xxx' from xxxClass. Cause: "The expression 'xxx' evaluated

逆向工程文件example完美结合使用PageHelper分页插件及分页不成功原因

原生的mybatis需要手写sql语句,项目数据库表多了之后,可以让你写sql语句写到手软,于是mybatis官方提供了mybatis-generator:mybatis逆向工程代码生成工具,用于简化mybatis单表操作. 在PageHelper3.几的版本的时候,使用它对逆向工程生成的查询方法进行分页时出现失效的情况,而PageHelper4开始,亲测能够与mybatis逆向工程生成的方法完美兼容,今天就和大家分享spring+springmvc+mybatis+PageHelper的项目遇

mybatis学习 -每天一记 mybatis insert null 报错

mybatis 插入数据,model的属性存在null,插入报错 在使用mybatis 进行insert时,如果字段值存在null的情况,会出现插入失败的情况,解决方案: 如果使用spring boot: @Bean ConfigurationCustomizer mybatisConfigurationCustomizer() { return new ConfigurationCustomizer() { @Override public void customize(org.apache.

mybatis 与 xml

mybatis的两大重要组件:配置和映射文件,都是可以通过xml配置的(新版本新增了注解的方式配置Mapper),下面来解析下mybatis是怎么做的 其中,关于配置文件解析的主要是在这个类XMLConfigBuilder里面的parseConfiguration方法,XMLConfigBuilder在初始化的时候会新建一个XPathParser对象用于XML配置文件的解析 public XMLConfigBuilder(InputStream inputStream, String envir

Expression 表达式

在使用EF使用Linq查询时,有些复杂的查询条件不能直接写Lambda表达式简单的拼装条件. 如 查询条件是有一组 like条件拼装,这时就要用到Expression表达式,下面直接上代码 public List<City> GetCitys(string[] areaCodes) { var type = typeof(City); var pe = Expression.Parameter(type); var property = type.GetProperty("AreaC