
MyBatis
thoughtfly
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
mybatis与spring3.1整合
因spring3发布时mybatis还没有出正式版本,所以spring没有整合最新的mybatis.不过社区倒是开发了一个中间件。 需要的jar包 mybatis-3.0.6.jar mybatis-spring-1.0.2.jar 要点: 1.在spring中配置mybatis工厂类 2.在dao层使用spring注入的的工具bean对数据进行操作 整合时,...原创 2012-04-15 10:58:28 · 165 阅读 · 0 评论 -
Mybatis3快速上手应用示例
基本步骤: 加入jar包 定义dao接口 定义配置文件 实现dao接口 快速示例 环境 mysql数据库,已经表user,内有字段id,name,mark,其中id为主键,并且是自动递增类型 CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varcha...2012-04-16 15:24:31 · 115 阅读 · 0 评论 -
MyBatis核心SqlSessionFactory的创建
SqlSessionFactory是每个MyBatis应用的核心 其实现方式有两种,使用配置文件或使用JAVA编码。 1.配置文件实现 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" ...2012-04-16 15:41:43 · 216 阅读 · 0 评论 -
Mybatis3插入语句映射
模版示例 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace=&q原创 2012-04-16 17:35:18 · 140 阅读 · 0 评论 -
Mybatis3更新和删除语句映射
更新删除相对简单点,只要属性和类型对应即可。 模板 <update id="updateAuthor" parameterType="domain.blog.Author"> update Author set username = #{username}, password = #{password}, email = #{email}, ...原创 2012-04-16 17:35:29 · 144 阅读 · 0 评论 -
Mybatis3查询语句映射
查询语句是相对复杂的一项了 基本的查询属性模板 <select id=”selectPerson” parameterType=”int” parameterMap=”deprecated” resultType=”hashmap” resultMap=”personResultMap” flushCache=”false” ...原创 2012-04-16 17:35:38 · 179 阅读 · 0 评论 -
Mybatis3结果集映射
模板 <resultMap id="userResultMap" type="User"> <id property="id" column="user_id" /> <result property="username" column="user_name" /> <原创 2012-04-17 10:18:10 · 138 阅读 · 0 评论 -
Mybatis3缓存设置
开启缓存 默认情况下,缓存没有开启。要开启缓存,在SQL的映射文件中加入 <cache/> 其作用为 映射语句文件中的所有 select 语句将会被缓存。 映射语句文件中的所有 insert,update 和 delete 语句会刷新缓存。 缓存会使用 Least Recently Used(LRU,最近最少使用的)算法来收回。 ...原创 2012-04-17 10:18:17 · 110 阅读 · 0 评论