随笔分类 -  Mybatis

摘要:追问 但是,resultType 也可以返回一个对象 <select id="getUserNameByID" resultType="com.bean.User"> Select * from User where id =#id# </select> 也可以返回一个封装的对象啊 这个跟resul 阅读全文
posted @ 2017-09-05 20:12 林加欣 阅读(1540) 评论(0) 推荐(1) 编辑
摘要:使用通用Mapper,不需要再写mapper.xml配置文件,多数时候,连接口方法都不需要了,大大提高了开发效率。 通用Mapper接口大全:点这里 导入依赖: 第二部,在mybatis的全局配置文件中,注册通用mapper插件,MapperInterceptor _(plugin),详情,点这里, 阅读全文
posted @ 2017-08-20 20:46 林加欣 阅读(423) 评论(0) 推荐(0) 编辑
摘要:mybatis 中使用 sqlMap 进行 sql 查询时,经常需要动态传递参数,例如我们需要根据用户的姓名来筛选用户时,sql 如下: 上述 sql 中,我们希望 name 后的参数 "ruhua" 是动态可变的,即不同的时刻根据不同的姓名来查询用户。在 sqlMap 的 xml 文件中使用如下的 阅读全文
posted @ 2016-11-25 14:54 林加欣 阅读(3291) 评论(0) 推荐(0) 编辑
摘要:这两天项目用到ibatis,碰到and or的联合查询,语句像这样的 select * from table where xxx = "xxx" and (xx1="xx1" or xx2="xx2") baidu跟google半天只找到一个手动写xml语句的,内容地址如下: http://lyfe 阅读全文
posted @ 2016-11-24 21:40 林加欣 阅读(36109) 评论(4) 推荐(5) 编辑
摘要:1 ##Example example = new ##Example(); 2 example.setOrderByClause("字段名 ASC"); //升序排列,desc为降序排列。 3 example.setDistinct(false)//去除重复,boolean型,true为选择不重复的记录。 4 Criteria criteria = ne... 阅读全文
posted @ 2016-11-24 21:38 林加欣 阅读(2800) 评论(0) 推荐(1) 编辑
摘要:1 ##Example example = new ##Example(); 2 example.setOrderByClause("字段名 ASC"); //升序排列,desc为降序排列。 3 example.setDistinct(false)//去除重复,boolean型,true为选择不重复的记录。 4 Criteria criteria = ne... 阅读全文
posted @ 2016-11-16 12:55 林加欣 阅读(259) 评论(0) 推荐(0) 编辑
摘要:1 ##Example example = new ##Example(); 2 example.setOrderByClause("字段名 ASC"); //升序排列,desc为降序排列。 3 example.setDistinct(false)//去除重复,boolean型,true为选择不重复的记录。 4 Criteria criteria = ne... 阅读全文
posted @ 2016-11-09 00:28 林加欣 阅读(286) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示