插入时返回主键(Oracle)

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 "})

 

posted @ 2018-01-23 19:48  BINGJJFLY  阅读(427)  评论(0编辑  收藏  举报