对于数据库(如MySQL,SQLServer)支持auto-generated key field的情况
在 mapper.xml 里 添加 useGeneratedKeys="true" keyProperty="id"
比如:
<insert id="insert" parameterType="cn.**.dao.实体" useGeneratedKeys="true" keyProperty="id">
insert into place_ad .......
</insert>
重点是 返回的主键会放到实体对象身上