mybatis下 mysql、oracle插入数据返回id

mysql

<insert id="insertOne" parameterType="com.jsxy.wzy.pojo.StudentInfo">
    <selectKey keyProperty="stuId" order="AFTER" resultType="int">
        select LAST_INSERT_ID()
    selectKey>
    INSERT into tbl_student(stu_name,stu_sex,stu_message) VALUES(#{stuName},#{stuSex},#{stuMessage})
insert>


oracle

<insert id="insertOne" parameterType="com.jsxy.wzy.pojo.StudentInfo">
    <selectKey keyProperty="stuId" order="BEFORE" resultType="int">
        select 序列.nextval() from dual
    selectKey>
    INSERT into tbl_student(stu_id,stu_name,stu_sex,stu_message) VALUES(#{stuId},#{stuName},#{stuSex},#{stuMessage})
insert>


你可能感兴趣的:(数据库操作,mybatis,mysql,oracle)