mybatis 返回 插入主键id
<insert id="createOrder" parameterType="map"> <selectKey resultType="long" order="BEFORE" keyProperty="id"> select seq_id.nextval from dual </selectKey> insert into t_order( order_id, order_code, order_price, order_address, order_tel, order_status) values ( #{id}, #{order_code,jdbcType=VARCHAR}, #{order_price,jdbcType=NUMERIC}, #{order_address,jdbcType=VARCHAR}, #{order_tel,jdbcType=VARCHAR},0) </insert>
dao
public int createOrder(Map params){ return this.template.insert("Order.createOrder",params); } service @Transactional public void addOrder(Map ordeerParam){ dao.createOrder(ordeerParam); String orderId = ordeerParam.get("id").toString(); }