Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@TableField注解的typeHandler类型处理器泛型失效 #163

Closed
superxiao opened this issue Aug 5, 2024 · 4 comments
Closed

@TableField注解的typeHandler类型处理器泛型失效 #163

superxiao opened this issue Aug 5, 2024 · 4 comments

Comments

@superxiao
Copy link

superxiao commented Aug 5, 2024

当前使用版本(必填,否则不予处理)

1.4.13

该问题是如何引起的?(确定最新版也有问题再提!!!)

#127 已经修复了这个问题,但是在mybatis plus后续更新后修复应该是失效了。

重现步骤(如果有就写完整)

创建一个List<A>类型field,A是一个用Jackson标注过的pojo类型。field带有mybatis plus的JacksonTypeHandler的标注(该handler目前只支持postgres读,不支持写)。数据库对应posgres json或者jsonb类型,内容是包含json object的列表(e.g. [{"prop": 1}, {"prop": 2}], prop是A的field name)。通过selectJoinList之类方法把json map到List<A>.

报错信息

会创建List<TreeMap>而不是List<A>

原因是

https://github.com/yulichang/mybatis-plus-join/blob/master/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/segments/SelectCache.java#L95
这里
this.typeHandlerClass = tableFieldInfo.getTypeHandler();
可能要改成
this.typeHandlerClass = tableFieldInfo.getResultMapping().getTypeHandler();

前者不带有效泛型,后者带有效泛型

@qichhhhh
Copy link

qichhhhh commented Aug 5, 2024

同样遇到该问题了,selectJoinList 之后 DTO 中定义的字段 List<XXX> 被反序列化成了 List<JSONObject>

@qichhhhh
Copy link

@yulichang 很好复现,麻烦看一下

@yulichang
Copy link
Owner

@yulichang 很好复现,麻烦看一下

好的

@superxiao
Copy link
Author

我刚发现getResultMapping这个方法是protected, 这不知道怎么修呢。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants