MyBatis绑定Mapper接口参数到Mapper映射文件sql语句参数

时间:2019-10-16 12:01:06   收藏:0   阅读:267

一、设置paramterType

1.类型为基本类型

a.代码示例

映射文件:

<select id="findShopCartInfoById" parameterType="int"
    resultType="ShopCart">
    select*
    from shopcart
    where shopcartid = #{id}
</select>

Mapper接口:

ShopCart findShopCartInfoById(int id);

测试代码:

ShopCartMapper scm = sqlSession.getMapper(ShopCartMapper.class);
ShopCart shopCart = scm.findShopCartInfoById(14);

 

2.类型为对象类

原文:https://www.cnblogs.com/YeHuan/p/11684590.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!