java~springboot~ibatis Invalid bound statement (not found)原因

事实起因

最近在ORM上使用了ibatis,感觉挺繁琐的,没有jpa来的直接,但项目非要用也没有办法,最近在进行开发过程中出现了一个问题Invalid bound statement (not found)意思是说,你的xml映射和你的mapper方法不一致,这种不一致大叔总结几点,如果你出现了这种问题可以按着下面几后进行排查。

可能出现的原因
  1. xml输入参数类型不匹配,你可以改成parameterType="map"试试
  2. xml返回参数类型问题,resultType="你的类型",不要写成resultMap="你的类型"
  3. 返回的DTO与返回结果集名称不匹配,这时你要对照类型的属性,去为sql设置别名
  4. yml文件里对ibatis配置有问题
    如下面代码:
@Getter
@Setter
public class BusinessCustomerDTO {
private Long id;
private String customerName;
private String contactPerson;
private Integer freeDays;
private String city;
private String province;
private String source;
private LocalDateTime enterDays;
private String leadingPerson;
}

对应的mapper代码:

  <select id="getBusinessCustomers" parameterType="java.util.Map" resultType="cn.pilipa.customer.management.dto.BusinessCustomerDTO">
        select a.id,
        a.customer_name as customerName,
        a.city_code as city,
        a.province_code as province,
        a.customer_source as source,
        b.enter_storage_time as enterDays,
        b.current_salesperson as leadingPerson,
        c.contact_person as contactPerson from customer_base_info a
        inner join customer_business_info b on a.id=b.customer_id
        left join customer_contact_person  c on c.customer_id=a.id
        where c.is_main_contact=1
    </select>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值