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 should log if mapRow doesn't find a PropertyDescriptor [SPR-13323] #17908

Closed
spring-projects-issues opened this issue Aug 6, 2015 · 0 comments
Assignees
Labels
in: data type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 6, 2015

Leonard Meyer opened SPR-13323 and commented

I just spent a bit of time on a rather dumb problem...

I just added a new field to my model and modified my database schema consequently, The thing is, my database column didn't have a proper name to match with the name of my field. I first though it was some problem of entity mapping from my custom BeanPropertyRowMapper but it didn't make any sense because it was all strings.
It must have been related to something else, but I had no clue what. I enabled Spring debug logs but found nothing relevant, but after some debugging I did find some columns index were skipped in the mapRow method of BeanPropertyRowMapper. It all happened here :

for (int index = 1; index <= columnCount; index++) {
  String column = JdbcUtils.lookupColumnName(rsmd, index);
  PropertyDescriptor pd = this.mappedFields.get(column.replaceAll(" ", "").toLowerCase());
  if (pd != null) {
   [...]
  }
}

Some property descriptor were null because the column name didn't match anything in mappedFields. Anyway, I was just thinking it would've been way quicker to just have something like this in the logs :

if (pd != null) {
 [...]
} else {
 logger.debug("Column {} did not match any field name for {} ", column, mappedClass.getSimpleName)
}

Can contribute if necessary.

Thanks


Affects: 4.2 GA

Issue Links:

  • #18461 BeanPropertyRowMapper should use ConversionService for date-time support

Referenced from: commits 35e1eca

1 votes, 2 watchers

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

No branches or pull requests

2 participants