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

[错误报告]: 无法反序列化 JSONB 实体对象 #205

Closed
3 tasks done
starudream opened this issue Sep 30, 2024 · 1 comment
Closed
3 tasks done

[错误报告]: 无法反序列化 JSONB 实体对象 #205

starudream opened this issue Sep 30, 2024 · 1 comment

Comments

@starudream
Copy link

确认

  • 我的版本是最新版本, 我的版本号与 version 相同, 并且项目里无依赖冲突
  • 我已经在 issue 中搜索过, 确认问题没有被提出过
  • 我已经修改标题, 将标题中的 描述 替换为遇到的问题

当前程序版本

1.5.0

问题描述

问题代码:https://github.com/starudream/mybatis-plus-join-demo

简化代码:

@Data
@Accessors(chain = true)
@TableName(value = "users", autoResultMap = true)
public class User {

    private String id;

    private String name;

    @Data
    @Accessors(chain = true)
    public static class Profile {
        private String avatar;
    }

    @TableField(typeHandler = JacksonTypeHandler.class)
    private Profile profile;

}
        List<User> users = userMapper.selectJoinList(
            User.class,
            JoinWrappers
                .lambda(User.class)
                .selectAll(User.class)
        );

无法反序列化字段 profile

1.4.13 版本没问题, 1.5.0 会报错

可能关联的 issue #163

详细堆栈日志

### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
### The error may exist in com/example/demo/mapper/UserMapper.java (best guess)
### The error may involve com.example.demo.mapper.UserMapper.selectJoinList
### The error occurred while handling results
### SQL: SELECT     t.id,t.name,t.role_id,t.extend,t.profile   FROM users  t
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
org.mybatis.spring.MyBatisSystemException: 
### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
### The error may exist in com/example/demo/mapper/UserMapper.java (best guess)
### The error may involve com.example.demo.mapper.UserMapper.selectJoinList
### The error occurred while handling results
### SQL: SELECT     t.id,t.name,t.role_id,t.extend,t.profile   FROM users  t
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:99)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:347)
	at jdk.proxy3/jdk.proxy3.$Proxy74.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:164)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
	at jdk.proxy3/jdk.proxy3.$Proxy79.selectJoinList(Unknown Source)
	at com.example.demo.mapper.UserMapperTest.test(UserMapperTest.java:38)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:181)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:61)
	at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:119)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:512)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:418)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:366)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:337)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:310)
	at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:202)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:66)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:80)
	at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:65)
	at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:336)
	at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:110)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:90)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:61)
	at com.github.yulichang.interceptor.MPJInterceptor.intercept(MPJInterceptor.java:88)
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
	at jdk.proxy3/jdk.proxy3.$Proxy134.query(Unknown Source)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333)
	... 11 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:107)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.apache.ibatis.reflection.invoker.MethodInvoker.invoke(MethodInvoker.java:44)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:175)
	... 38 more


Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
org.apache.ibatis.reflection.ReflectionException: Could not set property 'profile' of 'class com.example.demo.model.User' with value '{avatar=avatar}' Cause: java.lang.IllegalArgumentException: argument type mismatch
	at app//org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:181)
	at app//org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:61)
	at app//org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:119)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:512)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:418)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:366)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:337)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:310)
	at app//org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:202)
	at app//org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:66)
	at app//org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:80)
	at app//org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:65)
	at app//org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:336)
	at app//org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158)
	at app//org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:110)
	at app//org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:90)
	at java.base@21.0.4/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base@21.0.4/java.lang.reflect.Method.invoke(Method.java:580)
	at app//org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:61)
	at app//com.github.yulichang.interceptor.MPJInterceptor.intercept(MPJInterceptor.java:88)
	at app//org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
	at app/jdk.proxy3/jdk.proxy3.$Proxy134.query(Unknown Source)
	at app//org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154)
	at app//org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
	at app//org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142)
	at java.base@21.0.4/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base@21.0.4/java.lang.reflect.Method.invoke(Method.java:580)
	at app//org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333)
	at app/jdk.proxy3/jdk.proxy3.$Proxy74.selectList(Unknown Source)
	at app//org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
	at app//com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:164)
	at app//com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
	at app//com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:152)
	at app//com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
	at app/jdk.proxy3/jdk.proxy3.$Proxy79.selectJoinList(Unknown Source)
	at app//com.example.demo.mapper.UserMapperTest.test(UserMapperTest.java:38)
	at java.base@21.0.4/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base@21.0.4/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base@21.0.4/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:107)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.apache.ibatis.reflection.invoker.MethodInvoker.invoke(MethodInvoker.java:44)
	at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:175)
	... 38 more
@yulichang
Copy link
Owner

好的 下个版本修复

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

2 participants