Skip to content

BeanPropertyRowMapper should log if mapRow doesn't find a PropertyDescriptor [SPR-13323] #17908

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 35e1eca

1 votes, 2 watchers

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions