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

ResultMap由于重复映射产生的全小写property,高版本映射到PO类失败 #3437

Open
sayhi-captain opened this issue Mar 20, 2025 · 3 comments

Comments

@sayhi-captain
Copy link

问题复现

<resultMap id="BaseResultMap" type="com.xxx.Student">
    <id column="student_id", jdbcType="BIGINT" property="studentId">
    <result column="student_name", jdbcType="VARCHAR" property="studentName">
</resultMap>

<select id="query" resultMap="BaseResultMap">
    select 
    student_id as studentId,
    student_name as studentName
    from student where deleted = 0
</select>
@Data
public class Student {
    private Long studentId;
    private String studentName;
}

pom版本

老项目
mybatis: 3.4.1

查询出的column:studentidstudentname,查询正常映射到Student

新项目
mybatis: 3.5.7

查询出的column:studentidstudentname,查询映射到Student,属性均为空

问题代码定位:
高版本jar包
Image

低版本无问题jar包

Image

@harawata
Copy link
Member

Hello @sayhi-captain ,

Please create a small demo project like these with assertions.

@sayhi-captain
Copy link
Author

sayhi-captain commented Mar 21, 2025

Hello @sayhi-captain ,

Please create a small demo project like these with assertions.

demo project link: https://github.com/sayhi-captain/mybatis-issues/tree/master/gh-123

@harawata
Copy link
Member

Thanks for the demo, @sayhi-captain .

The class User has two properties userId and userName.
And these properties are explicitly mapped in the result map, so auto-mapping is not applied to these properties.
This is the right behavior.

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