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>
上一篇:scikit-learn 决策树 分类问题


下一篇:数据挖掘之聚类算法Apriori总结