錯誤排查:Caused by: org.apache.ibatis.exceptions.PersistenceException
阿新 • • 發佈:2020-12-15
技術標籤:java筆記分享mysqlspring bootmybatis
錯誤提示:
[aad8bbfc419f1d20]Caused by: org.apache.ibatis.exceptions.PersistenceException:
[aad8bbfc419f1d20]### Error querying database. Cause: java.lang.NullPointerException: target is null for method size
[aad8bbfc419f1d20]### Cause: java.lang.NullPointerException: target is null for method size
排查:
空指標肯定是某個屬性沒繫結上
<select id="findRepertoryDayTotal" resultType="int">
select
count(*)
from cluster_sams.app_sams_cloud_item_inventory_days_d
<where>
<!-- 時間為空, 預設日期 -->
< if test="(repertoryDateStart == null or repertoryDateStart == '') or (repertoryDateEnd == null or repertoryDateEnd == '')">
and event_date between yesterday() and today()
</if>
<!-- 時間不為空, 庫存日期 -->
<if test="(repertoryDateStart != null and repertoryDateStart != ' ') and (repertoryDateEnd != null and repertoryDateEnd != '')">
and event_date between #{repertoryDateStart} and #{repertoryDateEnd}
</if>
<!-- 商品號 -->
<if test="itemNumber != null and itemNumber.size() != 0">
and item_nbr in
<foreach collection="itemNumber" item="item" open="(" close=")" separator="," index="index">
#{item}
</foreach>
</if>
<!-- 城市 -->
<if test="cities != null and cities.size() != 0">
and storage_city_cn in
<foreach collection="cities" item="city" open="(" close=")" separator="," index="index">
#{city}
</foreach>
</if>
<!-- 母店 -->
<if test="stores != null and stores.size() != 0">
and store_id in
<foreach collection="stores" item="storeId" open="(" close=")" separator="," index="index">
#{storeId}
</foreach>
</if>
<!-- 雲倉 -->
<if test="positions != null and position.size() != 0">
and position in
<foreach collection="position" item="pos" open="(" close=")" separator="," index="index">
#{pos}
</foreach>
</if>
<!-- 分割槽 -->
<if test="divisions != null and divisions.size() != 0">
and division in
<foreach collection="divisions" item="div" open="(" close=")" separator="," index="index">
#{div}
</foreach>
</if>
<!-- 類別 -->
<if test="category != null and category.size() != 0">
and category in
<foreach collection="category" item="cate" open="(" close=")" separator="," index="index">
#{cate}
</foreach>
</if>
</where>
</select>
排查了一下 postions漏了一個s
解決
仔細排查一下,是不是某個屬性,寫錯了或者某個條件寫錯了,導致無法獲取繫結屬性。