内容简介:最近在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>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
神经网络与机器学习(原书第3版)
[加] Simon Haykin / 申富饶、徐烨、郑俊、晁静 / 机械工业出版社 / 2011-3 / 79.00元
神经网络是计算智能和机器学习的重要分支,在诸多领域都取得了很大的成功。在众多神经网络著作中,影响最为广泛的是Simon Haykin的《神经网络原理》(第3版更名为《神经网络与机器学习》)。在本书中,作者结合近年来神经网络和机器学习的最新进展,从理论和实际应用出发,全面、系统地介绍了神经网络的基本模型、方法和技术,并将神经网络和机器学习有机地结合在一起。 本书不但注重对数学分析方法和理论的探......一起来看看 《神经网络与机器学习(原书第3版)》 这本书的介绍吧!