Mybatis mapper.xml 配置

<!-- xml的标准格式 -->
<?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的根节点 -->
<mapper namespace="com.mayi.service.mobile.suburbtrip.db.dao.mapper.CouponActivityInfoMapper" >
  <!--
 标签cache
  -->
  <cache
  eviction="FIFO"
  flushInterval="60000"
  size="512"
  readOnly="true"/>
  <!--
 标签cache-ref
  -->
  <cache-ref namespace="com.someone.application.data.SomeMapper"/>
  <!-- parameterMap -->
  <!-- resultMap -->
  <!--
 标签sql
 sql代码段,使用时,利用标签<include refid="" />引入
 如:
   <select id="selectUsers" resultType="map">
    select <include refid="userColumns"/>
    from some_table
    where id = #{id}
   </select>
  -->
  <sql id="userColumns"> id,username,password </sql>
  <!--
 标签select
 select所拥有的参数如下:
 id="selectPerson"   该statement对应的id
 parameterType="int"  传入参数类型
 parameterMap="deprecated"  传入参数map
 resultType="hashmap"  返回参数类型
 resultMap="personResultMap"  返回参数map
 flushCache="false"  如果设为true,则会在每次语句调用的时候就会清空缓存。select 语句默认设为false
 useCache="true" 将其设置为 true, 将会导致本条语句的结果被缓存。默认值: true
 timeout="10000" 这个设置驱动程序等待数据库返回请求结果,并抛出异常时间的最大等待值。默认不设置(驱动自行处理)
 fetchSize="256" 这是暗示驱动程序每次批量返回的结果行数。默认不设置(驱动自行处理)
 statementType="PREPARED" statement,preparedstatement,callablestatement 预准备语句、可调用语句
 resultSetType="FORWARD_ONLY forward_only,scroll_sensitive,scroll_insensitive 只转发,滚动敏感,不区分大小写的滚动
 databaseId
 resultOrdered
 resultSets
  -->
  <select id="selectPerson" parameterType="int" resultType="hashmap">
 SELECT * FROM PERSON WHERE ID = #{id}
  </select>
  <!--
 标签insert 、update、delete
 标签属性如下:
 id="insertAuthor"  对应的id
 parameterType="domain.blog.Author" 
 flushCache="true"
 statementType="PREPARED"
 keyProperty=""
 keyColumn=""
 useGeneratedKeys=""
 timeout="20"
  -->
  <insert id="insertAuthor">
   insert into Author (id,username,password,email,bio)
   values (#{id},#{username},#{password},#{email},#{bio})
  </insert>
  <update id="updateAuthor">
   update Author set
  username = #{username},
  password = #{password},
  email = #{email},
  bio = #{bio}
   where id = #{id}
  </update>
  <delete id="deleteAuthor">
 delete from Author where id = #{id}
  </delete>
 
</mapper>

posted @ 2014-03-30 09:58  li.zhiliang  阅读(646)  评论(0编辑  收藏  举报