首页 > 其他分享 >mybatis 一对多 出现 Expected one result (or null) to be returned by selectOne() 报错问题

mybatis 一对多 出现 Expected one result (or null) to be returned by selectOne() 报错问题

时间:2022-09-04 23:22:21浏览次数:64  
标签:returned 当成 报错 result Expected null id

报错信息展示

image

报错时的mapper.xml

image

修改后的mapper.xml

image

踩坑原因分析

resultmap在映射的时候 是会把 多张表中相同的字段名当成同一个对象来看待 比如上文中的c.id和u.id resultmap在映射的时候会把两者都当成id 而不是一个当成c.id另一个当成s.id 来区分.

标签:returned,当成,报错,result,Expected,null,id
From: https://www.cnblogs.com/Black-Ice/p/16656483.html

相关文章