
mybatis
程序员阿坤
不解?不解。不解!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
mybatis include标签和foreach标签的使用
1、Mybatis中mapper.xml文件中sql标签和Include标签的使用: <sql>用来封装SQL语句, <include>来调用,例如: <sql id="select"> SELECT * FROM `body_index` </sql> <select id="find" resultType="*&q转载 2017-09-26 13:41:22 · 1315 阅读 · 0 评论 -
mybatis 模糊查询的三种写法
select * from user where name like ‘%#{username}%’,这样写是会报错的。 解决办法: ① 参数中直接加入%% param.setUsername("%CD%"); param.setPassword("%11%"); <select id="selectPersons" resultType="person" p...转载 2017-09-26 14:56:20 · 1000 阅读 · 0 评论 -
MyBatis在DAO层定义接口返回类型泛型无效
今天很偶然的因为一次粗心而发现的一个mybatis问题,这里就写出来与大家分享一下。DAO层定义了一个接口,返回String集合,用于获取最热门的搜索信息。mapper.xml文件接口返回的类型却是search对象。调用接口,返回的是search对象集合,没有报错,泛型没起到作用。仔细一想,泛型是在编译阶段将我们的返回值类型匹配到一具体类型,而DAO层的接口却没有具体的返回值信息,所以在编译阶段它...原创 2018-05-03 22:55:07 · 4296 阅读 · 3 评论 -
mybatis if判断integer类型注意点
今天在写mapper文件时遇到integer类型参数时判断不为空,如下<if test="status != null and status != ''"> SQL。。。</if>当status=0时,if语句没有执行。究其原因,原来mybatis默认将integer=0的参数等于‘’空串。...原创 2018-06-05 21:54:19 · 5872 阅读 · 0 评论