Caused by: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "mil_id")

今天在使用mybatis处理数据库的时候,突然抛出了上述异常,让我感到很惊讶,因为在处理save的时候,在Mybatis的配置文件中,我根本就没有使用到ognl表达式,系统怎么会抛出上述异常。而且之前也是这么使用的,也没见抛出上述异常。然后查看操作数据库的Mybatis的配置文件,倒是找到了几个错误,但是都不是引起这个异常的原因。然后,再仔细查看这个配置文件,突然之间,发现了,在该配置文件:

<!-- save -->
<insert id="save">
    insert into qa_sampling(s_id ,
                            s_mil_id ,
                            s_samplingPackage ,
                            s_samplingWeight ,
                            s_samplingPerson_id ,
                            s_samplingCardFill ,
                            s_samplingDate ,
                            s_createTime)
                     values(#{s_id} ,
                            ${s_mil.mil_id} ,
                            #{s_samplingPackage} ,
                            #{s_samplingWeight} ,
                            #{s_samplingPerson.u_id} ,
                            #{s_samplingCardFill} ,
                            #{s_samplingDate} ,
                            #{s_createTime})
</insert>

${s_mil.mil_id} , 这一处,居然是使用$,难怪系统将其作为表达式进行解析,将其修改成”#”之后,一切OK,上述异常成功解决。现,贴出正确的写法:

<!-- save -->
<insert id="save">
    insert into qa_sampling(s_id ,
                            s_mil_id ,
                            s_samplingPackage ,
                            s_samplingWeight ,
                            s_samplingPerson_id ,
                            s_samplingCardFill ,
                            s_samplingDate ,
                            s_createTime)
                     values(#{s_id} ,
                            #{s_mil.mil_id} ,
                            #{s_samplingPackage} ,
                            #{s_samplingWeight} ,
                            #{s_samplingPerson.u_id} ,
                            #{s_samplingCardFill} ,
                            #{s_samplingDate} ,
                            #{s_createTime})
</insert>
时间: 2024-10-13 11:29:34

Caused by: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "mil_id")的相关文章

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;zoneId&#39; in &#39;class java.lang.String&#39;

本文为博主原创,未经允许不得而转载: 异常展示: dao层定义的接口为: public int getClientTotal(); 在mybatis中的sql为: <select id="getClientTotal" parameterType="String" resultType="Integer"> SELECT COUNT(*) AS oldNum FROM tbl__client_info <where> &l

Spring Boot:Caused by: org.apache.ibatis.binding.BindingException: Parameter &#39;deptId&#39; not found.

1. 错误信息描述 在使用Spring Boot + Mybaits从前台向后台提交数据时,控制台报出该错误信息 2. 报错原因 在dao接口中,该方法拥有两个参数,Mybaits无法区分这两个参数 3. 解决方法 在dao方法中为这两个参数分别标注Mybaits的@Param注解,对这两个参数加以区分 List<ManagerSelectResult>selectToday(@Param("deptId") Integer deptId, @Param("off

springboot项目下的Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

今天遇到mybatis-puls的报错Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 排查方法如下: 1.mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)? 2.mapper.xml的命名空间(namespace)是否跟mapper接口的包名一致? 3.接口的方法名,与xml中的一条sql标签的id一致 4.配置

mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. with invalid types () or values (). Cause: java.lang.NoSuchMethodException: ...&lt;init&gt;()

此类错误需要在无参构造器中调用父类 public Test(){ super(); }

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;parentId&#39; in &#39;class java.lang.String&#39;

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333) at org.apache.ibatis.reflection.Meta

org.apache.ibatis.binding.BindingException: Parameter &#39;start&#39; not found. Available parameters are [1, 0, param1, param2]

DEBUG 2018-05-30 08:43:26,091 org.springframework.jdbc.datasource.DataSourceTransactionManager: Rolling back JDBC transaction on Connection [[email protected]]DEBUG 2018-05-30 08:43:26,091 org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization:

org.apache.ibatis.builder.IncompleteElementException: Could not find result map java.util.HashMap

这样的配置有问题吗? <select id="getFreightCollectManagementList" resultMap="java.util.HashMap" parameterType="com.rms.providers.dto.AccountingPayableDto"> 有的, 出现mybatis 错误: 2018-08-13 15:28:35 -13867 [http-nio-80-exec-10] DEBUG

org.apache.ibatis.exceptions.TooManyResultsException

在查阅测试环境业务日志中的ERROR级别的日志时,发现了有一个Mybatis相关的异常错误org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 13. 一.分析:详细堆栈信息打印如下 2018-09-30 17:30:17.548 ERROR 14146 --- [DubboServerHandler

【异常及源码分析】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping

一.异常出现的场景 1)异常出现的SQL @Select("SELECT\n" + " id,discount_type ,min_charge, ${cardFee} AS actualDiscountPrice , discount_price AS discountPrice ,status ,name \n" + "FROM\n" + "\tuser_coupon \n" + "WHERE\n" +