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

DataClassRowMapper doesn't pass generic field information to type conversion #26881

Closed
belovaf opened this issue Apr 30, 2021 · 0 comments
Closed
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@belovaf
Copy link

belovaf commented Apr 30, 2021

DataClassRowMapper doesn't pass generic field information to internal TypeConverter:

args[i] = tc.convertIfNecessary(getColumnValue(rs, rs.findColumn(name), type), type);

As a result any field like this List<MyEnumType> values will be populated with String values (heap pollution).

This problem can be solved by replacing the code above with something like this:

args[i] = tc.convertIfNecessary(
    getColumnValue(rs, rs.findColumn(name), type),
    type,
    MethodParameter.forParameter(mappedConstructor.getParameters()[0]))

mappedConstructor.getParameters() should be extracted as a field for performance reason.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 30, 2021
@jhoeller jhoeller self-assigned this Apr 30, 2021
@jhoeller jhoeller added in: data Issues in data modules (jdbc, orm, oxm, tx) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 30, 2021
@jhoeller jhoeller added this to the 5.3.7 milestone Apr 30, 2021
@jhoeller jhoeller changed the title DataClassRowMapper doesn't correctly convert generic fields DataClassRowMapper doesn't pass generic field information to type conversion May 28, 2021
@jhoeller jhoeller added type: enhancement A general enhancement and removed type: bug A general bug labels May 28, 2021
Zoran0104 pushed a commit to Zoran0104/spring-framework that referenced this issue Aug 20, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants