• 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>

  • 相关阅读:
    T-SQL over()函数在单个表中的聚合
    jQuery EasyUI DataGrid API 中文文档
    ASP.Net UpdatePanel控件(转)
    java多线程系类:基础篇:03Thread中的start()和run()的区别
    java多线程系类:基础篇:02常用的实现多线程的两种方式
    java多线程系类:基础篇:01基本概念:
    完全二叉树的概念
    007商城项目:商品列表查询-需求分析,以及Spinmvc的访问知识
    006商城项目:该项目的路径访问问题
    githup上传代码
  • 原文地址:https://www.cnblogs.com/sten/p/3633511.html
Copyright © 2020-2023  润新知