oracle主键是不能像mysql一样自动管理的,需要自己手动管理,先生成,再插入。
<selectKey keyProperty="id" resultType="String" order="BEFORE"> SELECT SEQ_GWFROZEN.nextval AS ID FROM DUAL </selectKey> <insert id="haha" parameterType="com.xx" > insert into xx <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" > ID, </if> <if test="orderId != null" > ORDER_ID, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" > #{id,jdbcType=VARCHAR}, </if> <if test="orderId != null" > #{orderId,jdbcType=VARCHAR}, </if> </trim> </insert>