自动获取主键只能用于插入和更新
<!--
useGeneratedKeys:启动获取数据库自动生成的主键
keyProperty:把获取到的主键注入给对象的哪个属性
keyColumn:从哪个列获取主键
-->
<!--插入-->
<insert id="insertEmp" useGeneratedKeys="true" keyProperty="id" keyColumn="id" >
insert into
t_employee (name,age,birthday,salary)
values (#{name},#{age},#{birthday},#{salary})
</insert>
<!--更新-->
<update id="updateEmp" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
update t_employee
set
name=#{name},
age=#{age},
birthday=#{birthday},
salary=#{salary}
where id=#{id};
</update>