错误排查:Caused by: org.apache.ibatis.exceptions.PersistenceException

本文记录了一次由于属性绑定错误引发的`org.apache.ibatis.exceptions.PersistenceException`问题。通过错误提示和排查过程,发现是属性名`postions`缺少了字母`s`导致的空指针异常。解决方案是细致检查所有属性名和条件表达式,确保正确无误。

错误提示:

[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

解决

仔细排查一下,是不是某个属性,写错了或者某个条件写错了,导致无法获取绑定属性。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值