mysql的方式:
方式一:
useGeneratedKeys="true" keyProperty="id"
方式二:
<selectKey keyProperty="studentID" resultType="String" order="AFTER">
SELECT LAST_INSERT_ID() as id
</selectKey>
Oracle的方式:
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT common_seq.CURRVAL AS VAL FROM DUAL
</selectKey>
其中<selectKey >的order 属性值 可以设成BEFORE 或者AFTER,如果设为BEFORE,那它会先选择主键,然后设置keyProperty,再执行insert语句;如果设为AFTER,它就先运行insert 语句再运行selectKey 语句