ssm不执行sql,不报错且程序接着运行

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_40369944/article/details/83626064

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'programa.pId != null'. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "pId")

------------------------------------------------------

SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@68a32861] was not registered for synchronization because synchronization is not active

------------------------------------------------------

Caused by: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'programa.pId != null'. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "pId")

最开始删除的方法没有try不知道错在哪里也没抛异常

 动态拼接的时候最开始用的只是根据programa.pId做条件删除,所有本身Article对象的aId属性是为空的,删除的时候没有问题。

<if test="aId != null ">and a_id=#{aId} </if>
<if test="programa.pId != null" > and p_id=#{programa.pId} </if>

当我根据aId来删除的时候,条件还是↓↓↓↓

<if test="aId != null ">and a_id=#{aId} </if>
<if test="programa.pId != null" > and p_id=#{programa.pId} </if>

到这里的时候就怎么也不执行删除的sql,代码还是接着运行,发现是因为没有判断对象属性不为空

一次泪奔的总结┭┮﹏┭┮

猜你喜欢

转载自blog.csdn.net/qq_40369944/article/details/83626064