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

原因分析

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

相关推荐
jgyzl1 天前
2026.3.11MyBatis-Plus基本使用与思考
java·数据库·mybatis
杰克尼1 天前
苍穹外卖--day10
java·数据库·spring boot·mybatis·notepad++
mcooiedo1 天前
Spring Boot与MyBatis
spring boot·后端·mybatis
只能是遇见1 天前
【SpringBoot3】Spring Boot 3.0 集成 Mybatis Plus
spring boot·后端·mybatis
MegaDataFlowers1 天前
一对多和多对一处理
mybatis
zzb15802 天前
RAG from Scratch-优化-query
java·数据库·人工智能·后端·spring·mybatis
zzb15802 天前
RAG from Scratch-优化-routing
java·前端·网络·人工智能·后端·python·mybatis
MegaDataFlowers2 天前
使用注解开发
mybatis
常利兵2 天前
Spring Boot + MyBatis,给数据穿上“隐形盔甲”
java·spring boot·mybatis
Java程序之猿3 天前
SpringBoot + camel+IBM MQ实现消息队列处理
java·spring boot·mybatis