Skip to content

The property with type Map.class not correctly assigned key-value, May be caused by reflector.findPropertyName(name) in MetaClass#buildProperty #2324

Closed
@jinkun2014

Description

@jinkun2014

MyBatis version

3.5.7

Database vendor and version

MySQL 8.0.25

Test case or example project

// User.java
public class User {
	private String id;
	private String name;
	private Integer age;
	private Map<String, Object> ext = new HashMap<>();
	private Role role;
}

// Role.java
public class Role {
	private String name;
}

// xml
<select id="select" resultType="x.y.User">
    select *,
           'role_admin' as `role.name`,
           'hello1' as `ext.hello1`,
           'hello2' as `ext.hello2`
    from user;
</select>

Steps to reproduce

@Test
public void select(){
    List<User> userList = userMapper.select();
    System.out.println(userList.size());
}

Expected result

the propery "ext" can correctly assigned with expected value like {"hello1"="hello1","hello2"="hello2"}

Actual result

{""="hello2"}

Snipaste_2021-08-25_22-56-42

Snipaste_2021-08-25_23-05-43

Snipaste_2021-08-25_23-02-45

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions