2017年5月2日

mybatis 之 mybatis整合spring

摘要: a) 新建java项目 b) 导入jar包,特别需要注意导入mybatis 和 spring 的整合包 d) 编写vo: e) 编写dao接口 f) 编写mapper映射文件 g) 编写dao的实现类 h) 编写service接口及其实现类 i) 编写spring的配置文件 j) 测试 不需要使用m 阅读全文

posted @ 2017-05-02 16:35 forever_2h 阅读(200) 评论(0) 推荐(0) 编辑

mybatis 之 mybatis缓存

摘要: mybatis同样有一级缓存和二级缓存。 一级缓存指在session的范围中同样的statement的id只会查询一次。 @Test public void testFindById(){ List list = new ArrayList(); list.add(1); list.add(3); List users= ... 阅读全文

posted @ 2017-05-02 15:59 forever_2h 阅读(126) 评论(0) 推荐(0) 编辑

mybatis 之 mybatis的映射

摘要: Vo类: 映射文件: 测试: 阅读全文

posted @ 2017-05-02 15:48 forever_2h 阅读(223) 评论(0) 推荐(0) 编辑

mybatis 之 占位符#{} 和 ${}

摘要: 测试: 自定义类型作为参数,自定义类中需要为为属性提供get方法,如果没有提供get方法,那么会根据占位符中的名称去反射获取值,如果占位符中的名称和属性不一致,那么报ReflectionException。 测试: Map作为参数类型,key和占位符中的名称一致即可,如果名称不一致那么将会把null 阅读全文

posted @ 2017-05-02 15:37 forever_2h 阅读(10938) 评论(0) 推荐(0) 编辑

mybatis 之 分页及模糊查询

摘要: 映射文件: 测试代码: 映射文件: 测试代码: 映射文件: 测试代码: 注意:通常情况下使用 Map 传参来实现分页 测试代码: 测试代码: 注意:通常使用第二种方式实现模糊查询: 阅读全文

posted @ 2017-05-02 14:49 forever_2h 阅读(4267) 评论(0) 推荐(0) 编辑

mybatis 之 mybatis中查询

摘要: 映射文件: 测试 阅读全文

posted @ 2017-05-02 14:28 forever_2h 阅读(186) 评论(0) 推荐(0) 编辑

mybatis 之 配置详解

摘要: mybatis.cfg.xml --> ... 阅读全文

posted @ 2017-05-02 14:06 forever_2h 阅读(127) 评论(0) 推荐(0) 编辑

mybatis 之 实现单表的增删改查操作

摘要: Mybatis 实现单表的crud操作,只需要添加对应的 sql 映射即可。 insert into t_role(name) values(#{name}) delete from t_role where id=#{id} update t_... 阅读全文

posted @ 2017-05-02 11:36 forever_2h 阅读(197) 评论(0) 推荐(0) 编辑

mybatis 之 简介,开发详细步骤

摘要: ibatis 最早再Apache 下开源。 现在在github上开源。 新建java项目 导入jar包: mybatis-3.2.7.jar mysql-connector-java-5.1.20-bin.jar mybatis-3.2.7.jar mysql-connector-java-5.1. 阅读全文

posted @ 2017-05-02 11:27 forever_2h 阅读(240) 评论(0) 推荐(0) 编辑

导航