mybatis执行insert语句后,返回当前插入数据主键的方法 keyProperty区分大小写
代码语言:javascript复制#这样查询没有返回主键值
<insert id="addLog" useGeneratedKeys="true" keyProperty="id" parameterType="com.LogEntity">
#正确的写法
<insert id="addLog" useGeneratedKeys="true" keyProperty="ID" parameterType="com.LogEntity">
INSERT INTO `email_log` (
`content_md5`
)
VALUES
(
#{contentMd5}
)
</insert>
#接口
public interface LogMapper {
int addLog(LogEntity logEntity);
}
#实体类
#model对象是大写ID
public class LogEntity {
/**
* ID
*/
private Integer ID;
private String contentMd5;
}