mybatis-generator mapper文件 添加字段

根据反向工程生成的mapper.xml文件结构,描述。

ID描述
BaseResultMap除了Blob格式的map
ResultMapWithBLOBs所有列的map
Example_Where_Clause查询条件,确定某些行
Update_By_Example_Where_Clause
Base_Column_List除了blob的列集合
Blob_Column_Listblob的列集合
selectByExampleWithBLOBs查询数据,包含blob数据
selectByExample查询数据,不包含blob数据
selectByPrimaryKey根据ID选择
deleteByPrimaryKey根据ID删除
deleteByExample
insert根据entity插入,包含所有的列
insertSelective插入非null的列
countByExample
updateByExampleSelective更新非null的列
updateByExampleWithBLOBs
updateByExample
updateByPrimaryKeySelective根据id更新非null的列,包括blob
updateByPrimaryKeyWithBLOBs根据id更新所有列
updateByPrimaryKey根据id更新除了blob的所有列

表添加列的时候可能需要改动的项目:

  1. BaseResultMap(ResultMapWithBLOBs)
  2. Base_Column_List(Blob_Column_List)
  3. select 根据blob决定
  4. insert
  5. update
<?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 namespace="com.test.meta.entity.User" >
  <resultMap id="BaseResultMap" type="com.test.meta.entity.User" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="user_name" property="userName" jdbcType="VARCHAR" />
    <result column="note" property="note" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.test.meta.entity.User" extends="BaseResultMap" >
    <result column="icon" property="icon" jdbcType="LONGVARCHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, user_name, note
  </sql>
  <sql id="Blob_Column_List" >
    icon
  </sql>
  <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.finup.meta.entity.MdmBusinessSystemInfoExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from mdm_business_system_info
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.finup.meta.entity.MdmBusinessSystemInfoExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from mdm_business_system_info
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from mdm_business_system_info
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from mdm_business_system_info
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.finup.meta.entity.MdmBusinessSystemInfoExample" >
    delete from mdm_business_system_info
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.finup.meta.entity.MdmBusinessSystemInfo" >
    insert into mdm_business_system_info (id, business_system_cd, business_system_name, 
      department_id, business_line_id, status, 
      create_time, update_time, note, 
      icon)
    values (#{id,jdbcType=BIGINT}, #{businessSystemCd,jdbcType=VARCHAR}, #{businessSystemName,jdbcType=VARCHAR}, 
      #{departmentId,jdbcType=BIGINT}, #{businessLineId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{note,jdbcType=VARCHAR}, 
      #{icon,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.finup.meta.entity.MdmBusinessSystemInfo" >
    insert into mdm_business_system_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="userName != null" >
        userName,
      </if>
      <if test="note != null" >
        note,
      </if>
      <if test="icon != null" >
        icon,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=BIGINT},
      </if>
      <if test="userName != null" >
        #{userName,jdbcType=VARCHAR},
      </if>
      <if test="note != null" >
        #{note,jdbcType=VARCHAR},
      </if>
      <if test="icon != null" >
        #{icon,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.finup.meta.entity.MdmBusinessSystemInfoExample" resultType="java.lang.Integer" >
    select count(*) from mdm_business_system_info
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update mdm_business_system_info
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.userName != null" >
        user_name = #{record.userName,jdbcType=VARCHAR},
      </if>
      <if test="record.note != null" >
        note = #{record.note,jdbcType=VARCHAR},
      </if>
      <if test="record.icon != null" >
        icon = #{record.icon,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map" >
    update mdm_business_system_info
    set id = #{record.id,jdbcType=BIGINT},
      user_name = #{record.userName,jdbcType=VARCHAR},
      note = #{record.note,jdbcType=VARCHAR},
      icon = #{record.icon,jdbcType=LONGVARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update mdm_business_system_info
    set id = #{record.id,jdbcType=BIGINT},
      user_name = #{record.userName,jdbcType=VARCHAR},
      note = #{record.note,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.finup.meta.entity.MdmBusinessSystemInfo" >
    update mdm_business_system_info
    <set >
      <if test="businessSystemCd != null" >
        user_name = #{userName,jdbcType=VARCHAR},
      </if>
      <if test="note != null" >
        note = #{note,jdbcType=VARCHAR},
      </if>
      <if test="icon != null" >
        icon = #{icon,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.finup.meta.entity.MdmBusinessSystemInfo" >
    update mdm_business_system_info
    set user_name = #{userName,jdbcType=VARCHAR},
      note = #{note,jdbcType=VARCHAR},
      icon = #{icon,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.finup.meta.entity.MdmBusinessSystemInfo" >
    update mdm_business_system_info
    set user_name = #{userName,jdbcType=VARCHAR},
      note = #{note,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值