mybatis执行insert语句后,返回当前插入数据主键的方法 keyProperty区分大小写
mybatis执行insert语句后,返回当前插入数据主键的方法 keyProperty区分大小写
代码语言:javascript代码运行次数:0运行复制#这样查询没有返回主键值
<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;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2022-08-30,如有侵权请联系 cloudcommunity@tencent 删除对象接口数据mybatisinsert发布者:admin,转转请注明出处:http://www.yc00.com/web/1754983628a5224021.html
评论列表(0条)