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

BeanPropertyRowMapper's support for direct column name matches is missing in DataClassRowMapper #29187

Closed
madorb opened this issue Sep 21, 2022 · 5 comments
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx)

Comments

@madorb
Copy link

madorb commented Sep 21, 2022

This is a follow-on to closed ticket (that I'm unable to reopen) which I believe did not fully address the problem.

After the update the BeanPropertyRowMapper's behavior still does not match the documentation from BeanPropertyRowMapper which states:

The names are matched either directly or by transforming a name separating the parts with underscores to the same name using "camel" case.

The "directly" part of the mapping does not occur. Instead it only attempts to match fully lower-cased values.

Given data class:

data class MyClass(
    @Id
    val someId: Long?,
    val fooValue String?,
    val barValue: String?,
    val updateTimestamp: LocalDateTime?
)

and query:

SELECT someId, fooValue, barValue, updateTimestamp FROM ...

the fields are not mapped.

Mapping happens successfully if either the query is changed to:

SELECT someId as some_id, fooValue as foo_value, barValue as bar_value, updateTimestamp as update_timestamp FROM ...

OR the data class is changed to:

data class MyClass(
    @Id
    val someid: Long?,
    val foovalue String?,
    val barvalue: String?,
    val updatetimestamp: LocalDateTime?
)

It seems either the documentation or the behavior of this class should be changed.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 21, 2022
@rstoyanchev rstoyanchev added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Jan 24, 2023
@sbrannen
Copy link
Member

sbrannen commented Feb 3, 2023

@madorb, what databases (and database drivers) did you test this against?

In addition, are you using a connection pool, and if so which one(s)?

I ask, because I believe the behavior of java.sql.ResultSet.findColumn(String) may be dependent on your exact setup.


If you could provide a minimal example application which demonstrates the problem, that would really help us in diagnosing the issue.

@sbrannen sbrannen added the status: waiting-for-feedback We need additional information before we can continue label Feb 3, 2023
@madorb
Copy link
Author

madorb commented Feb 6, 2023

This was SQL server, i haven't touched this project for a while, but if i can find the time i'll try to get a minimal example

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 6, 2023
@sbrannen
Copy link
Member

sbrannen commented Feb 7, 2023

Thanks for the reply, @madorb.

This was SQL server,

Based on a quick glance at the implementation of the JDBC driver for SQL server, it appears that column name lookups are performed as exact matches and then case-insensitive as a fallback.

In light of that, it is a bit unexpected that foovalue would not return a positive match for fooValue; however, we really need a reproducer to analyze exactly what it going on.

i haven't touched this project for a while, but if i can find the time i'll try to get a minimal example

That would be great.


the fields are not mapped.

As a side note, what exactly do you mean by that?

Was there an actual error -- for example, in the form of an SQLException?

Or did the DataClassRowMapper complete its mapping without actually mapping values to the constructor arguments in your data class?

@sbrannen sbrannen added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Feb 7, 2023
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 14, 2023
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 21, 2023
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)
Projects
None yet
Development

No branches or pull requests

4 participants