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

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

Closed
jinkun2014 opened this issue Aug 26, 2021 · 1 comment

Comments

@jinkun2014
Copy link

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

@harawata
Copy link
Member

harawata commented Jan 5, 2025

Hello @jinkun2014 ,

I didn't understand what you mean (images are not helpful. test case or demo project is), but this must be a duplicate of #13 .
We fixed it in version 3.5.16, but you still have to write a custom map wrapper and factory. Please see the test attached to #3076 or my answer on the Stack Overflow.

Closing as duplicate.

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

No branches or pull requests

2 participants