标签:
方法1:
<insert id="insert" parameterType="Person" useGeneratedKeys="true" keyProperty="id"> insert into person(name,pswd) values(#{name},#{pswd}) </insert>
注:需要Person.getId()
方法二:
<insert id="insert" parameterType="Person"> <selectKey keyProperty="id" resultType="long"> select LAST_INSERT_ID() </selectKey> insert into person(name,pswd) values(#{name},#{pswd}) </insert>
标签:
原文地址:http://my.oschina.net/ydsakyclguozi/blog/517078