mybatis 插入时返回刚插入记录的主键值 (Oracle作为数据库)
程序员文章站
2022-06-07 23:49:13
...
<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>