• 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>
    
  • 相关阅读:
    关于协同过滤技术
    一些数据上的概念
    Simple HBase query bridge
    leveraging
    Ajax.NET
    怎样实现给DEDE的栏目增加栏目图片(2)
    怎样实现给DEDE的栏目增加栏目图片(1)
    更改dede网站地图模板样式
    sublime如何实现函数折叠
    一步一步CCNA之五:交换机vlan配置
  • 原文地址:https://www.cnblogs.com/lori/p/9674936.html
Copyright © 2020-2023  润新知