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

Using DataClassRowMapper causes "No property found for column" debug messages in logs #28179

Closed
petergphillips opened this issue Mar 15, 2022 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement
Milestone

Comments

@petergphillips
Copy link

petergphillips commented Mar 15, 2022

Spring JDBC: 5.3.16
Spring Boot 2.6.4

We're experimenting with the new DataClassRowMapper and found that if logging is set to DEBUG level then the No property found for column debug message is output.

This is confusing as it suggests that the column / property isn't being mapped, which isn't true as it is mapped during the constructor injection instead.

Steps to reproduce:

  1. Change spring logging to be debug in the test log file.
  2. Run one of the tests - ./gradlew spring-jdbc:test --tests org.springframework.jdbc.core.KotlinDataClassRowMapperTests
  3. View the standard output from the test in spring-jdbc/build/reports/tests/test/classes/org.springframework.jdbc.core.KotlinDataClassRowMapperTests.html

e.g.

08:37:03.946 [Test worker] DEBUG o.s.j.c.JdbcTemplate - Executing SQL query [select name, age, birth_date, balance from people]
08:37:03.953 [Test worker] DEBUG o.s.j.d.DataSourceUtils - Fetching JDBC Connection from DataSource
08:37:03.973 [Test worker] DEBUG o.s.j.c.DataClassRowMapper - No property found for column 'name' mapped to field 'name'
08:37:03.973 [Test worker] DEBUG o.s.j.c.DataClassRowMapper - No property found for column 'age' mapped to field 'age'
08:37:03.974 [Test worker] DEBUG o.s.j.c.DataClassRowMapper - No property found for column 'birth_date' mapped to field 'birth_date'
08:37:03.974 [Test worker] DEBUG o.s.j.c.DataClassRowMapper - No property found for column 'balance' mapped to field 'balance'
08:37:03.975 [Test worker] DEBUG o.s.j.c.DataClassRowMapper - No property found for column 'e_mail' mapped to field 'e_mail'

The message should only be output if no property has been found / mapped.

In this case DataClassRowMapper deliberately suppresses the properties. One solution would be to keep a set of suppressed properties and then only output the message if not in the set.

Note that the log message is only output if logging is set to DEBUG, so it isn't a high severity issue.

@sbrannen sbrannen changed the title Using DataClassRowMapper causes No property found for column debug messages in logs Using DataClassRowMapper causes "No property found for column" debug messages in logs Mar 15, 2022
@sbrannen sbrannen added status: waiting-for-triage An issue we've not yet triaged or decided on in: data Issues in data modules (jdbc, orm, oxm, tx) type: enhancement A general enhancement labels Mar 15, 2022
@jhoeller jhoeller removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 15, 2022
@jhoeller jhoeller self-assigned this Mar 15, 2022
@jhoeller jhoeller added this to the 5.3.17 milestone Mar 15, 2022
@jhoeller
Copy link
Contributor

From my perspective, we could simply drop that debug log statement (or potentially downgrade it to trace level but I'd rather drop it right away). It was only really meant to help with setter method mismatches in the original bean property mapper, but given the flexible mapping strategies in a modern-day data class arrangement, such a log is indeed more confusing than helpful.

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