-
Notifications
You must be signed in to change notification settings - Fork 377
DATAJDBC-341 - Map NULL values in EntityRowMapper for columns not being fetched in the query (fixed tests) #201
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
Conversation
| * | ||
| * @author Jens Schauder | ||
| */ | ||
| class ResultSetWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, we use a PropertyValueProvider to wrap the actual source.
| for (int i = 1; i <= columnCount; i++) { | ||
|
|
||
| String label = metaData.getColumnLabel(i).toLowerCase(); | ||
| Integer previous = index.put(label, i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per JDBC spec: Encountering a column label more than once, then the first label is used. I'd suggest a case-insensitive Set<String> (see LinkedCaseInsensitiveMap) to check for column names.
…ng fetched in the query. Original pull request: #170.
Turns out this was a little more involved than expected. This modifies the implementation to not use exceptions for flow control. Properties that get set via setter, wither or field access get not invoked for missing columns. When properties get referenced in constructors a missing column results in an exception. As a side effect we now access the `ResultSet` by index. Depending on how the driver is implemented this might improve the performance a little.
ResultSetWrapper now uses the first column when multiple columns with the same effective name exist. It employs a LinkedCaseInsensitiveMap for storing the mapping columnnames to indexes.
Introduced two differen PropertyValueProvider implementations in order to encapsulate the two variants how ResultSets get accessed.
19c4271 to
fa98642
Compare
Turns out this was a little more involved than expected. This modifies the implementation to not use exceptions for flow control. Properties that get set via setter, wither or field access get not invoked for missing columns. When properties get referenced in constructors a missing column results in an exception. As a side effect we now access the `ResultSet` by index. Depending on how the driver is implemented this might improve the performance a little. Original pull request: #201.
Remove SpecialColumnValue in favor of JdbcPropertyValueProvider.hasProperty(…). Rename ResultSetWrapper to ResultSetAccessor. Replace ResultSetAccessor usage in JdbcConverter with ResultSet to avoid visibility issues. Original pull request: #201.
|
That's merged and polished now. |
While reviewing #170 I realised various more cases and ended up doing more changes than the original PR. Therefore I'd like to get another review of the changes.
Issue: https://jira.spring.io/browse/DATAJDBC-341