用于获取新添加主键(自增主键,UUid)
keyProperty:子查询的结果要映射在参数类的那个属性上
order:子查询语句在主操作前还是后执行
resultType:子查询的结果类型
<insert id="">
<selectKey keyProperty="id" order="BEFORE|AFTER" resultType="Integer">
select last_insert_id()
</selectKey>
insert into User() values()
</insert>
<insert id="">
<selectKey resultType="" order="" keyProperty="">
select UUID()
</selectKey>
insert into User() values()
</insert>
本文介绍如何在MyBatis中使用<selectKey>元素设置自增ID或UUID作为主键。通过配置keyProperty、order和resultType属性,实现主键的自动填充。适用于数据库操作中的插入操作。

1370

被折叠的 条评论
为什么被折叠?



