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

原因分析

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

相关推荐
sensenlin913 天前
Mybatis中SQL全大写或全小写影响执行性能吗
数据库·sql·mybatis
BXCQ_xuan3 天前
软件工程实践四:MyBatis-Plus 教程(连接、分页、查询)
spring boot·mysql·json·mybatis
wuyunhang1234563 天前
Redis----缓存策略和注意事项
redis·缓存·mybatis
lunz_fly19923 天前
【源码解读之 Mybatis】【基础篇】-- 第2篇:配置系统深度解析
mybatis
森林-3 天前
MyBatis 从入门到精通(第一篇)—— 框架基础与环境搭建
java·tomcat·mybatis
森林-3 天前
MyBatis 从入门到精通(第三篇)—— 动态 SQL、关联查询与查询缓存
sql·缓存·mybatis
java干货3 天前
MyBatis 的“魔法”:Mapper 接口是如何找到并执行 SQL 的?
数据库·sql·mybatis
嬉牛4 天前
项目日志输出配置总结(多数据源MyBatis+Logback)
mybatis·logback
哈喽姥爷5 天前
Spring Boot--yml配置信息书写和获取
java·数据库·spring boot·mybatis
奔跑你个Run6 天前
mybatis plus 使用wrapper输出SQL
mybatis