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

原因分析

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

相关推荐
代码的余温2 小时前
MyBatis集成Logback日志全攻略
java·tomcat·mybatis·logback
sniper_fandc9 小时前
SpringBoot系列—MyBatis(xml使用)
java·spring boot·mybatis
Charlie__ZS10 小时前
若依框架去掉Redis
java·redis·mybatis
N维世界2 天前
Mybatis-XML映射文件
xml·java·mybatis
慧一居士2 天前
MyBatis-Plus的完整使用示例,完整使用示例手册
mybatis
艺杯羹3 天前
MyBatis之核心对象与工作流程及SqlSession操作
java·mybatis
天天摸鱼的java工程师3 天前
MyBatis Plus 的实用技巧:从业务场景到代码实现
java·后端·mybatis
wuxuanok3 天前
Web后端开发-Mybatis
java·开发语言·笔记·学习·mybatis
netyeaxi3 天前
Java:使用spring-boot + mybatis如何打印SQL日志?
java·spring·mybatis
小七mod3 天前
【MyBatis】MyBatis与Spring和Spring Boot整合原理
spring boot·spring·mybatis