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

原因分析

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

相关推荐
韩立学长4 小时前
【开题答辩实录分享】以《走失人口系统档案的设计与实现》为例进行答辩实录分享
mysql·mybatis·springboot
Flash Dog8 小时前
【MyBatis】——执行过程
java·mybatis
ss2733 天前
手写MyBatis第85弹:组合模式在SqlNode设计中的精妙应用
mybatis
sniper_fandc3 天前
MybatisPlus和pagehelper分页冲突—关于jsqlparser、pagehelper、MybatisPlus三者的版本兼容问题
mybatis·mybatisplus
上官浩仁4 天前
springboot3 mybatisplus 数据库操作入门与实战
spring boot·mybatis·db
weixin_419658314 天前
MyBatis 进阶
mybatis
祈祷苍天赐我java之术4 天前
Redis 热点数据与冷数据解析
java·redis·mybatis
Roye_ack5 天前
【项目实战 Day9】springboot + vue 苍穹外卖系统(用户端订单模块 + 商家端订单管理模块 完结)
java·vue.js·spring boot·后端·mybatis
人间有清欢5 天前
java数据权限过滤
java·mybatis·权限控制·数据过滤