zoukankan      html  css  js  c++  java
  • mybatis设置添加新对象数据的时候id使用uuid类型自动写入数据库

    在mapper.xml文件中的insert中增加以下标红的代码 实现id采用自增方式写入数据库,并且写入一个uuid字符

    <insert id="insert" parameterType="ssm.item.admin.bean.Depart" useGeneratedKeys="true" keyProperty="departId">
        <selectKey keyProperty="departId" resultType="java.lang.String"
        order="BEFORE">
        select replace(uuid(),'-','') from dual
        </selectKey>
        insert into depart (depart_id, depart_name, depart_code
          )
        values (#{departId,jdbcType=VARCHAR}, #{departName,jdbcType=VARCHAR}, #{departCode,jdbcType=VARCHAR}
          )
      </insert>

    <insert id="insertSelective" parameterType="ssm.item.admin.bean.Depart" useGeneratedKeys="true" keyProperty="departId"> <selectKey keyProperty="departId" resultType="java.lang.String" order="BEFORE"> select replace(uuid(),'-','') from dual </selectKey> insert into depart <trim prefix="(" suffix=")" suffixOverrides=","> <if test="departId != null"> depart_id, </if> <if test="departName != null"> depart_name, </if> <if test="departCode != null"> depart_code, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="departId != null"> #{departId,jdbcType=VARCHAR}, </if> <if test="departName != null"> #{departName,jdbcType=VARCHAR}, </if> <if test="departCode != null"> #{departCode,jdbcType=VARCHAR}, </if> </trim> </insert>
  • 相关阅读:
    UVA11375
    uva11806(容斥原理)
    uva10325(容斥原理)
    hdu4135(容斥原理)
    CF798
    多线程
    (转载)SVN 提交操作缩写(A D M R) .
    上不了网,如何判断
    (转载)myeclipse项目名称重命名
    mysql模糊查询
  • 原文地址:https://www.cnblogs.com/panchanggui/p/14888418.html
Copyright © 2011-2022 走看看