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

Incorrect Javadoc in [NamedParameter]JdbcOperations.queryForObject methods regarding exceptions #27559

Closed
turbanoff opened this issue Oct 14, 2021 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) status: backported An issue that has been backported to maintenance branches type: documentation A documentation task
Milestone

Comments

@turbanoff
Copy link

turbanoff commented Oct 14, 2021

Javadoc of methods:

  1. NamedParameterJdbcOperations#queryForObject(String, SqlParameterSource, RowMapper<T>)
    https://github.com/spring-projects/spring-framework/blob/main/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java#L270
  2. NamedParameterJdbcOperations#queryForObject(String, Map<String,?>, RowMapper<T>) https://github.com/spring-projects/spring-framework/blob/main/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java#L289

states that IncorrectResultSizeDataAccessException is supposed to be thrown if the query does not return exactly one row, or does not return exactly one column in that row. But actually second part, about count of columns, is incorrect. Query can return as many columns as RowMapper can handle.
Looks like copy-paste error from methods which accept Class instead of RowMapper.

Affected version - latest release 5.3.11

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 14, 2021
@sbrannen
Copy link
Member

sbrannen commented Oct 14, 2021

Good catch.

The Javadoc for all 4 queryForObject(...) methods is incorrect.

The same applies to JdbcOperations.

I'll fix that.

@sbrannen sbrannen added in: data Issues in data modules (jdbc, orm, oxm, tx) type: documentation A documentation task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 14, 2021
@sbrannen sbrannen self-assigned this Oct 14, 2021
@sbrannen sbrannen added this to the 5.3.12 milestone Oct 14, 2021
@sbrannen sbrannen changed the title Incorrect javadoc of methods NamedParameterJdbcOperations.queryForObject which aceepts RowMapper Javadoc NamedParameterJdbcOperations.queryForObject methods is incorrect regarding exceptions thrown Oct 14, 2021
@sbrannen sbrannen changed the title Javadoc NamedParameterJdbcOperations.queryForObject methods is incorrect regarding exceptions thrown Javadoc for NamedParameterJdbcOperations.queryForObject methods is incorrect regarding exceptions thrown Oct 14, 2021
@sbrannen sbrannen changed the title Javadoc for NamedParameterJdbcOperations.queryForObject methods is incorrect regarding exceptions thrown Incorrect Javadoc in [NamedParameter]JdbcOperations.queryForObject methods regarding exceptions Oct 14, 2021
@jhoeller jhoeller added the for: backport-to-5.2.x Marks an issue as a candidate for backport to 5.2.x label Oct 19, 2021
@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.2.x Marks an issue as a candidate for backport to 5.2.x labels Oct 19, 2021
jhoeller pushed a commit that referenced this issue Oct 19, 2021
This commit fixes the Javadoc in all queryForObject(...) methods in
JdbcOperations and NamedParameterJdbcOperations regarding what kinds of
exceptions are thrown under which conditions.

Closes gh-27559

(cherry picked from commit 0853baa)
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) status: backported An issue that has been backported to maintenance branches type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

4 participants