mybatis+mysql返回插入的主键,参数只是提供部分参数
时间:2021-07-01 10:21:17
帮助过:23人阅读
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;
mybatis+mysql返回插入的主键,参数只是提供部分参数
标签:pre 数据 rtb from har type com code class