java~springboot~ibatis Invalid bound statement (not found)缘由

事实原由

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

可能出现的缘由

  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代码:sql

<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>
相关文章
相关标签/搜索