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

原因分析

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

相关推荐
❀͜͡傀儡师1 天前
基于mybatis-plus进行加解密 Spring Boot Starter
spring boot·oracle·mybatis
csdn2015_1 天前
mybatisplus自动生成id
java·mybatis
xEurCjvwu2 天前
台达PLC与C#串口通信实现实时同步读写监控功能:配置地址以XML文件为基础动态生成控件
mybatis
LSL666_2 天前
6 持久化
redis·mybatis·持久化·aof·rdb
哈库纳玛塔塔2 天前
AI 时代,使用 dbVisitor 读写向量化数据
数据库·人工智能·mybatis
!chen2 天前
基于 Spring Boot 3.5.x + Sa-Token + MyBatis 企业级文件管理系统
spring boot·后端·mybatis
csdn2015_2 天前
mybatisplus 获得新增id
java·开发语言·mybatis
无尽的沉默2 天前
SpringBoot整合MyBatis-plus
spring boot·后端·mybatis
PD我是你的真爱粉2 天前
Redis持久化、内存管理、慢查询与发布订阅
redis·python·mybatis
zc.z3 天前
高并发在线考试系统稳定性保障方案
mybatis·高并发