错误提示:
[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
解决
仔细排查一下,是不是某个属性,写错了或者某个条件写错了,导致无法获取绑定属性。
本文记录了一次由于属性绑定错误引发的`org.apache.ibatis.exceptions.PersistenceException`问题。通过错误提示和排查过程,发现是属性名`postions`缺少了字母`s`导致的空指针异常。解决方案是细致检查所有属性名和条件表达式,确保正确无误。
1678

被折叠的 条评论
为什么被折叠?



