zoukankan      html  css  js  c++  java
  • Mybatis常用标签

    mybatis常用的标签有:

    定义语句相关:insert、 delete、 update、 select

    查询结果集相关:resultMap

    控制sql动态拼接相关: if、 choose、 foreach

    格式化相关:where、 set、 trim

    关联关系相关: collection、 association

    select查询常量相关:sql、 include

    insert 标签:

    id:唯一标识

    parameterType:传入参数类型

    <insert id="xx" parameterType="java.lang.Integer">insert into ...</insert>

    delete 标签

    id:唯一标识

    parameterType:传入参数类型

    <delete id="xx" parameterType="java.lang.Integer">delete from ...</delete>

    update 标签

    id:唯一标识

    parameterType:传入参数类型

    <update id="xx" parameterType="java.lang.Integer" >update ...</update>

    selete 标签

    id:唯一标识

    parameterType:传入参数类型

    resultType: 返回值类型,当返回值为集合时,返回值类型为集合的泛型而不是集合本身

    resultMap:返回值类型,对应<resultMap>标签的id值

    <select id="xx" parameterType="java.lang.Integer" resultType="java.lang.String" > select ...</selete>

    <resultMap id="aa" type="xx.xx_entity"><id property="xx" column="xx" /> <result column="xx" property="xx" /></resultMap>

    <select id="xx" parameterType="java.lang.Integer" resultMap="aa" > select ...</selete>

    resultMap 标签

    将数据库表的字段和java对象属性对应

    <resultMap id="xx" type="xx.xx_entity"><id property="xx" column="xx" /> <result column="xx" property="xx" /></resultMap>

    property值为java对象属性,column值为数据库表的字段

    resultMap标签常用在select标签

    <resultMap id="aa" type="xx.xx_entity"><id property="xx" column="xx" /> <result column="xx" property="xx" /></resultMap>

    <select id="xx" parameterType="java.lang.Integer" resultMap="aa" > select ...</selete>

    引用:https://blog.csdn.net/qq_39623058/article/details/88779242

      https://blog.csdn.net/zhiguoliu11/article/details/82995444

      https://blog.csdn.net/qq_39623058/article/details/88779301

  • 相关阅读:
    伪类和伪元素的区别, 总结的很好, 直接看结论.
    进制闲谈
    遇到的问题&思考
    PHP中include引用导致不能再次相对引用文件的一个小问题
    ECharts饼图试玩
    不该迷茫的时候迷茫
    [5]火车票接口整理
    [4]xlongwei工具类
    [3]天行新闻
    [2]新闻
  • 原文地址:https://www.cnblogs.com/zj68/p/13019927.html
Copyright © 2011-2022 走看看