useGeneratedKeys="true" keyProperty="id" 无效,id无法回显原因 一、背景二、代码三、失效原因四、解决办法五、通用mapper处理办法 一、背景 某
某些情况下,需要回显id给前端,或者后端业务逻辑处理时需要根据插入数据的id进行业务处理,记回显失效原因
// mapperint save(@Param("vo") AgentPoint agentPoint); <insert id="save" parameterType="cn.api.entity.AgentPoint" useGeneratedKeys="true" keyProperty="id"> INSERT INTO agentpoint ( empCode, name ) values ( #{vo.empCode}, #{vo.name} ) </insert> mapper层加了@Param(“vo”)的情况,无法回显id
删除 @Param(“vo”) 代码,去掉" vo. "
// mapperint save(AgentPoint agentPoint); <insert id="save" parameterType="cn.api.entity.AgentPoint" useGeneratedKeys="true" keyProperty="id"> INSERT INTO agentpoint ( empCode, name ) values ( #{empCode}, #{name} ) </insert> 调用如下方法
int insertUseGeneratedKeys(T record); 回显后,可通过对象的.getId() 方法获取id
以上仅供参考
来源地址:https://blog.csdn.net/Yuhei001/article/details/128480886
--结束END--
本文标题: useGeneratedKeys=“true“ keyProperty=“id“ 无效,id无法回显原因
本文链接: https://www.lsjlt.com/news/391440.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0