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

原因分析

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

相关推荐
计算机学姐5 小时前
基于SpringBoot的美妆销售系统【个性化推荐算法+数据可视化统计+库存预警+物流信息】
java·vue.js·spring boot·后端·mysql·信息可视化·mybatis
while(1){yan}7 小时前
Mybatis动态SQL
数据库·spring boot·sql·spring·java-ee·mybatis
雨中飘荡的记忆8 小时前
MyBatis设计模式之装饰器、模版方法、策略模式
mybatis
hssfscv11 小时前
Javaweb学习笔记——JDBC和Mybatis
笔记·学习·mybatis
cike_y11 小时前
Spring整合Mybatis:dao层
java·开发语言·数据库·spring·mybatis
雨中飘荡的记忆12 小时前
MyBatis设计模式之构建者、工厂、代理模式
mybatis
while(1){yan}21 小时前
Mybatis基础(详解)
spring boot·spring·java-ee·mybatis
多多*1 天前
2026年1月3日八股记录
java·开发语言·windows·tcp/ip·mybatis
草原印象1 天前
Spring、SpringMVC、Mybatis框架整合实战视频课程
java·spring·mybatis
雨中飘荡的记忆1 天前
MyBatis映射器模块详解
mybatis