zoukankan      html  css  js  c++  java
  • MyBatis映射文件

    简单查询

    insert添加

     insert可以使用数据库支持的自动生成主键策略,设置useGeneratedKeys=”true”,然后把keyProperty 设成对应的列,就搞定了。比如说上面的StudentEntity 使用auto-generated 为id 列生成主键.
     还可以使用selectKey元素。下面例子,使用mysql数据库nextval('student')为自定义函数,用来生成一个key。

    update修改

    Sql元素用来定义一个可以复用的SQL 语句段,供其它语句调用。比如:

    resultType和resultMap的区别

    1、resultType

    返回单个实例

    <select id="selectUser" parameterType="int" resultType="User">

    select * from user where id = #{id}

    </select>
    返回List集合

    <select id="selectUserAll" resultType="User" > <!-- resultMap="userMap" -->
    select * from user
    </select>

    2、resultMap

    简单查询:

    <resultMap type="User" id="userMap">
    <id column="id" property="id"/>
    <result column="name" property="name"/>
    </resultMap>
    column:数据库中列名称,property:类中属性名称

     

    resultMap:适合使用返回值是自定义实体类的情况

    resultType:适合使用返回值得数据类型是非自定义的,即jdk的提供的类型

    resultMap : 

    映射实体类的数据类型

    resultMap的唯一标识

    column: 库表的字段名

    property: 实体类里的属性名

  • 相关阅读:
    map & reduce
    Generator
    切片
    函数参数
    Dict & Set
    list,tuple
    selenium鼠标和键盘操作
    selenium元素定位以及点击事件
    css定位
    xpath
  • 原文地址:https://www.cnblogs.com/wyl123/p/7678710.html
Copyright © 2011-2022 走看看