在自动递增情况下 添加后返回主键id
<insert id="insert" parameterType="UserEntity">
insert user (email,password) values (#{email},#{pwd})
<selectKey keyProperty="id" resultType="integer" keyColumn="newId" order="AFTER">
SELECT LAST_INSERT_ID() as newId
</selectKey>
</insert>
在不是自动递增情况下 填入主键
<selectKey resultType="integer" keyColumn="newId" keyProperty="id" order="BEFORE">
SELECT (max(id)+1) as newId from 205_category
</selectKey>