zoukankan      html  css  js  c++  java
  • mybatis+mysql返回插入的主键,参数只是提供部分参数

    mybatis+mysql返回插入的主键,参数只是提供部分参数

      <insert id="insertByChannelIdOpenid"  useGeneratedKeys="true" keyProperty="id"  parameterType="com.model.StatisticSaler" >
          insert into statistic_saler(city_id,shop_id,saler_id,type,openid,time)
          select city_id,shop_id,saler_id,#{type,jdbcType=VARCHAR},#{openid,jdbcType=VARCHAR},now() 
          from channel s where s.id = #{id,jdbcType=INTEGER}
      </insert>

    输入的参数只是提供部分参数,在插入的过程中使用了其他的数据库表;

    mybatis这个insert语句返回的就是影响的记录条数;

    而作为参数的那个对象,会由于使用了

     useGeneratedKeys="true" keyProperty="id"
    而获得新建记录的id;

  • 相关阅读:
    sql_LIKE
    sql_TOP
    oracle_存储过程
    注释@
    request.getAttribute()和request.getParameter()区别
    遍历map
    ORACLE
    JSP
    生成导入模板_设置列宽及标题_解析xml
    解析Excel_Poi
  • 原文地址:https://www.cnblogs.com/stono/p/6613678.html
Copyright © 2011-2022 走看看