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

原因分析

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

相关推荐
2601_949815331 小时前
Spring Boot中集成MyBatis操作数据库详细教程
数据库·spring boot·mybatis
星晨雪海1 小时前
若依框架原有页面功能进行了点位管理改造之列表查询(4)
数据库·sql·mybatis
mldlds3 小时前
Spring Boot 集成 MyBatis 全面讲解
spring boot·后端·mybatis
那个失眠的夜4 小时前
Spring整合Mybatis实现用户的CRUD
java·spring·mybatis
zjjsctcdl5 小时前
Spring Boot 整合 MyBatis 与 PostgreSQL 实战指南
spring boot·postgresql·mybatis
zmsofts18 小时前
java面试必问13:MyBatis 一级缓存、二级缓存:从原理到脏数据,一篇讲透
java·面试·mybatis
MegaDataFlowers1 天前
使用SpringBoot+MyBatis+MySQL完成后端的数据库增删改查(CRUD)操作
数据库·spring boot·mybatis
一只大袋鼠1 天前
MyBatis 特性(三):缓存、延迟加载、注解开发
java·数据库·笔记·sql·缓存·mybatis
木易 士心1 天前
MyBatis Plus 核心功能与用法
java·后端·mybatis
一只大袋鼠1 天前
MyBatis 进阶实战(四): 连接池、动态 SQL、多表关联(一对多 / 多对一 / 多对多)
java·开发语言·数据库·sql·mysql·mybatis