日期:2014-05-16  浏览次数:20555 次

mybatis 插入时返回刚插入记录的主键值 (Oracle作为数据库)
<insert id="insert" parameterType="cn.***.beans.LogObject" >  
    <selectKey resultType="java.lang.Integer" order="BEFORE" keyProperty="id">  
        SELECT LOGS_SEQ.nextval AS ID FROM DUAL  
    </selectKey>  
    INSERT INTO S_T_LOGS (  
        ID,   
        USER_ID,   
        USER_NAME,   
        USER_IP,   
        OPERATION_TIME,  
        DESCRIPTION,   
        RESOURCE_ID)   
    VALUES (  
        #{id},   
        #{userId},   
        #{userName},   
        #{userIp},   
        #{operationTime},  
        #{description},   
        #{resourceId})  
</insert>