1. 程式人生 > >ssm不執行sql,不報錯且程式接著執行

ssm不執行sql,不報錯且程式接著執行

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 [[email protected]] 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,程式碼還是接著執行,發現是因為沒有判斷物件屬性不為空

一次淚奔的總結┭┮﹏┭┮