【遇到问题】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.; 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对象中的构造函数,或者把你需要取出来的字段单独给弄成一个构造函数

发布了20 篇原创文章 · 获赞 1 · 访问量 555

猜你喜欢

转载自blog.csdn.net/weixin_42295814/article/details/104069671