内容简介:最近在ORM上使用了ibatis,感觉挺繁琐的,没有jpa来的直接,但项目非要用也没有办法,最近在进行开发过程中出现了一个问题对应的mapper代码:
事实起因
最近在ORM上使用了ibatis,感觉挺繁琐的,没有jpa来的直接,但项目非要用也没有办法,最近在进行开发过程中出现了一个问题 Invalid bound statement (not found)
意思是说,你的xml映射和你的mapper方法不一致,这种不一致大叔总结几点,如果你出现了这种问题可以按着下面几后进行排查。
可能出现的原因
-
xml输入参数类型不匹配,你可以改成
parameterType="map"
试试 - xml返回参数类型问题,resultType="你的类型",不要写成resultMap="你的类型"
- 返回的DTO与返回结果集名称不匹配,这时你要对照类型的属性,去为 sql 设置别名
-
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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
我的第一本编程书
[日]平山尚 / 张沈宇 / 人民邮电出版社 / 2016-7 / 79.00元
写这本书之前,作者一直在摸索一种最有利于入门者学编程的方法,并应用到教学当中。经过两年的教学实践,他确信他的方法是有效的,于是便有了这本书。这本书面向的是完全没有接触过编程的读者。作者将门槛设置得非常低,读者不需要懂得变量、函数这些名词(这些名词在书中也不会出现),不需要会英语,完全不需要查阅其他书籍,只需要小学算术水平即可。这本书给初学者非常平缓的学习曲线,有利于为之后的进阶学习打下坚实的基础。一起来看看 《我的第一本编程书》 这本书的介绍吧!