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注解,要四个注解一起使用。

原因分析

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

相关推荐
Fantasydg7 小时前
MyBatis学习
java·学习·mybatis
百***37488 小时前
【mybatis】基本操作:详解Spring通过注解和XML的方式来操作mybatis
xml·spring·mybatis
多多*15 小时前
一个有 IP 的服务端监听了某个端口,那么他的 TCP 最大链接数是多少
java·开发语言·网络·网络协议·tcp/ip·缓存·mybatis
book多得1 天前
Redis 大 Key 问题:识别、危害与最优处理方案
java·redis·mybatis
q***18061 天前
十八,Spring Boot 整合 MyBatis-Plus 的详细配置
spring boot·后端·mybatis
⑩-1 天前
苍穹外卖Day(1)
java·数据库·spring boot·spring·java-ee·mybatis
朝新_1 天前
【统一功能处理】从入门到源码:拦截器学习指南(含适配器模式深度解读)
数据库·后端·mybatis·适配器模式·javaee
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ2 天前
MyBatis Plus中执行原生SQL语句方法
python·sql·mybatis
R.lin2 天前
MyBatis 专题深度细化解析
oracle·面试·mybatis
JH30732 天前
MyBatis多表联查返回List仅一条数据?主键冲突BUG排查与解决
bug·mybatis