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