注意:id的类型必须与实体User的id字段类型一致
Oracle、达梦
sql
<insert id="insert" parameterType="com.xwy.entity.User">
<selectKey order="BEFORE" keyColumn="id" keyProperty="id" resultType="int">
select seq_user_id.nextVal from dual
</selectKey>
insert into user ( id,name) values (#{id},#{name})
</insert>
MySQL
sql
<insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.xwy.entity.User">
insert into user ( id,name) values (#{id},#{name})
</insert>