XML配置
<insert id="insertSelective" parameterType="com.jxxx.p2pp.model.UUserInfo"> <selectKey resultType="java.math.BigDecimal" order="BEFORE" keyProperty="userId"> SELECT U_USER_INFO_SEQ.Nextval as ID from DUAL </selectKey> insert into U_USER_INFO <trim prefix="(" suffix=")" suffixOverrides="," > ID, <if test="userName != null" > USER_NAME, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > #{userId}, <if test="userName != null" > #{userName}, </if> </trim> </insert>
注解配置
@SelectKey(before=false,keyProperty="id",resultType=Integer.class,statement={"select F_ORDER_SEQ.nextval from dual "})