Mybatis如何获取生成的主键值?

提问者:帅平 问题分类:面试刷题
Mybatis如何获取生成的主键值?
1 个回答
有你我就幸福
有你我就幸福
新增标签中添加:keyProperty=" ID " 即可,示例如下:
<insert id="insert" useGeneratedKeys="true" keyProperty="userId" >
        insert into user(user_name, user_password, create_time)
        values(#{userName}, #{userPassword} , #{createTime, jdbcType=TIMESTAMP})
</insert>
发布于:1周前 (04-21) IP属地:四川省
我来回答