Mybatis篇.如何获取自增的id

添加useGeneratedKeys=“true” keyProperty=“id”

//示例
<insert id="addErrorLogAsync" useGeneratedKeys="true" keyProperty="id">
   	insert into 
   	error_log
   	(
   	id,
   	server_name,
   	class_name,
	method_name,
	line_number,
   	begin_time,
   	msg
   	)
   	values
   	(
   	#{id},
   	#{serverName},
   	#{className},
   	#{methodName},
   	#{lineNumber},
   	#{beginTime},
   	#{msg}
   	)
</insert>

你可能感兴趣的:(Mybatis,获取自增id)