标签:type bat ast select 适用于 主键 记录 返回值 mybatis
mybatis 中 insertSelective(example) 语句默认返回并不是 插入记录的主键。
我们可以考虑插入记录主键不直接作为 函数的返回值, 而是体现在改变函数参数 "example", 使其主键等于插入记录的主键。
在insertSelective xml定义中,加入以下代码:
<selectKey resultType="Integer" keyProperty="id" >
SELECT last_insert_id() as id;
</selectKey>
这样就完成了对与参数改变。
注: 该方法只适用于 mysql 数据库!
标签:type bat ast select 适用于 主键 记录 返回值 mybatis
原文地址:http://www.cnblogs.com/yxmfighting/p/7092614.html