zoukankan      html  css  js  c++  java
  • MyBatis XML配置

    MyBatis XML映射文件

    Mapper XML 文件

    • cache – 给定命名空间的缓存配置。
    • cache-ref – 其他命名空间缓存配置的引用。
    • resultMap – 是最复杂也是最强大的元素,用来描述如何从数据库结果集中来加载对象。
    • sql – 可被其他语句引用的可重用语句块。
    • insert – 映射插入语句
    • update – 映射更新语句
    • delete – 映射删除语句
    • select – 映射查询语句

    select

    <select id="selectPerson" parameterType="int" resultType="hashmap">
      SELECT * FROM PERSON WHERE ID = #{id}
    </select>  

    这个语句被称作 selectPerson,接受一个 int(或 Integer)类型的参数,并返回一个 HashMap 类型的对象,其中的键是列名,值便是结果行中的对应值。

    insert

    <insert
      id="insertAuthor"
      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>

    <insert id="insertAuthor" useGeneratedKeys="true" keyProperty="id"> insert into Author (username,password,email,bio) values (#{username},#{password},#{email},#{bio}) </insert>

    update

    <update
      id="updateAuthor"
      parameterType="domain.blog.Author"
      flushCache="true"
      statementType="PREPARED"
      timeout="20">

    <update id="updateAuthor"> update Author set username = #{username}, password = #{password}, email = #{email}, bio = #{bio} where id = #{id} </update>

    delete

    <delete
      id="deleteAuthor"
      parameterType="domain.blog.Author"
      flushCache="true"
      statementType="PREPARED"
      timeout="20">

    <delete id="deleteAuthor"> delete from Author where id = #{id} </delete>
  • 相关阅读:
    搭建MHA问题汇总
    NOIP2009 靶形数独
    get_mysql_conn_info.py
    NOIP 2005 篝火晚会
    MySQL启动关闭添加到 /etc/init.d/mysqld
    noip2002 矩形覆盖
    get_slave_status.py
    [JSOI2008]魔兽地图
    MySQL数据导出导入任务脚本
    8.30 牛客OI赛制测试赛1 F题 子序列
  • 原文地址:https://www.cnblogs.com/0710whh/p/12269948.html
Copyright © 2011-2022 走看看