方法1:code
<insert id="insert" parameterType="Person" useGeneratedKeys="true" keyProperty="id"> insert into person(name,pswd) values(#{name},#{pswd}) </insert>
注:須要Person.getId()orm
方法二:get
<insert id="insert" parameterType="Person"> <selectKey keyProperty="id" resultType="long"> select LAST_INSERT_ID() </selectKey> insert into person(name,pswd) values(#{name},#{pswd}) </insert>