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>
posted @   张占岭  阅读(2867)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
历史上的今天:
2012-09-19 基础才是重中之重~你是否真正在用MVC路由功能~再续
2012-09-19 基础才是重中之重~你是否真正在用MVC路由功能~续
点击右上角即可分享
微信分享提示