mybatis-plus之使用lombok的@Builder注解之后的坑

背景

使用mysql-plus操作oracle,查询结果返回list对象集合。这个类使用lombok的@Data@Builder注解修饰。

然后再将结果集转为list集合时就报错,错误大概如下:

org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'SN' from result set. Cause: java.sql.SQLException: 无法转换为内部表示; uncategorized SQLException; SQL state [99999]; error code [17059]; 无法转换为内部表示; nested exception is java.sql.SQLException: 无法转换为内部表示

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
通过猜想可能由于默认的构造函数没有导致上述问题,于是手动添加注解@NoArgsConstructor,结果报错,没办法,再加上注解 @AllArgsConstructor , OK了。再测试,结果集转list集合也OK了。

总结:

java 复制代码
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor

如果有@Builder注解,要四个注解一起使用。

原因分析

有人已经分析好了,去查看

相关推荐
小邓睡不饱耶15 小时前
Spring Boot 3 + MyBatis-Plus 高性能持久层开发实战:从入门到调优
spring boot·后端·mybatis
番茄去哪了18 小时前
苍穹外卖day07---Redis缓存优化与购物车功能实现
java·数据库·ide·spring boot·spring·maven·mybatis
亓才孓18 小时前
【MyBatis Plus】Wrapper接口
java·开发语言·数据库·spring boot·mybatis
想不明白的过度思考者1 天前
Spring Boot 实战:MyBatis 操作数据库(上)
java·数据库·spring boot·mysql·mybatis
vx-Biye_Design1 天前
servlet家政公司管理系统-计算机毕业设计源码01438
java·vue.js·spring·servlet·tomcat·maven·mybatis
树码小子2 天前
图书管理系统(5)强制登陆(后端实现)
spring boot·mybatis·图书管理系统
indexsunny2 天前
互联网大厂Java面试实录:Spring Boot与微服务在电商场景中的应用
java·jvm·spring boot·微服务·面试·mybatis·电商
亓才孓2 天前
【Exception】CONDITIONS EVALUATION REPORT条件评估报告
java·开发语言·mybatis
树码小子3 天前
图书管理系统(2)图书列表接口
spring boot·mybatis·图书管理系统
tuokuac3 天前
MyBatis-Plus调用getEntity()触发异常
java·mybatis