Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了


insertSelective---Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了

https://www.cnblogs.com/xingyunblog/p/6243179.html

列子:
<!-- 插入一个商品 -->
    <insert id="insertProduct" parameterType="domain.model.ProductBean" >
       <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="productId">
          SELECT LAST_INSERT_ID()
      </selectKey>
        INSERT INTO t_product(productName,productDesrcible,merchantId)values(#{productName},#{productDesrcible},#{merchantId});
    </insert>

我写的:
<insert id="insertSelective" parameterType="com.runfast.waimai.dao.model.RunfastBusinessType">
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID()
</selectKey>
insert into newrunfast.runfast_business_type


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM