mybatis useGeneratedKey与keyProperty


insert into mmall_order_item (id, user_id, order_no,
product_name, product_id, product_image,
current_unit_prices, quality, table_price,
create_time, update_time)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{orderNo,jdbcType=BIGINT},
#{productName,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{productImage,jdbcType=VARCHAR},
#{currentUnitPrices,jdbcType=DECIMAL}, #{quality,jdbcType=INTEGER}, #{tablePrice,jdbcType=DECIMAL},
now(), now())

将userGeneratedKey值至为true,keyProperty="主键",即可获得插入后的主键id

转载于:https://www.cnblogs.com/Dar-/p/9077350.html

你可能感兴趣的:(mybatis useGeneratedKey与keyProperty)