【遇到问题】mybatis之坑我一天,mybatis映射错位
报错信息如下:Error attempting to get column ‘node_type’ from result set.Cause: java.sql.SQLException: Bad format for BigDecimal ‘Light’ in column 3.; Bad format for BigDecimal ‘Light’ in column 3.; nes...
报错信息如下:
Error attempting to get column ‘node_type’ from result set. Cause: java.sql.SQLException: Bad format for BigDecimal ‘Light’ in column 3.
; Bad format for BigDecimal ‘Light’ in column 3.; nested exception is java.sql.SQLException: Bad format for BigDecimal ‘Light’ in column 3.
org.springframework.dao.TransientDataAccessResourceException: Error attempting to get column ‘node_type’ from result set. Cause: java.sql.SQLException: Bad format for BigDecimal ‘Light’ in column 3.
; Bad format for BigDecimal ‘Light’ in column 3.; nested exception is java.sql.SQLException: Bad format for BigDecimal ‘Light’ in column 3.
上面的报错信息说,我的光照这个字段值对应着的属性为BigDecimal,这是什么灵异事件??
第一次遇到这个问题,不知道为什么就搞定了,但是也花了我好几个小时。第二次就是刚刚。
检查了所有地方的字段,无论顺序、类型都毫无问题。
最后我使用下面图片选中的这个功能,发现取出来的内容完全没有问题!!!只是映射出来的时候出现了问题。。。。。。。。。。。然后就发现是昨天在实体类里面加了一个构造函数。。。。这个构造函数没有包含select查找的全部属性,所以可能就出现了映射错位的现象。。。
解决问题:
删掉被映射的pojo对象中的构造函数,或者把你需要取出来的字段单独给弄成一个构造函数

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)