Skip to content

Improve JdbcClient to align BatchSpec with StatementSpec - #37307

Open
quaff wants to merge 1 commit into
spring-projects:mainfrom
quaff:patch-154
Open

quaff wants to merge 1 commit into
spring-projects:mainfrom
quaff:patch-154

Conversation

@quaff

@quaff quaff commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Add missing methods:

  1. param(int jdbcIndex, @Nullable Object value)
  2. param(int jdbcIndex, @Nullable Object value, int sqlType)
  3. param(String name, @Nullable Object value, int sqlType)

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Sep 20, 2026
@sbrannen sbrannen self-assigned this Sep 20, 2026
@sbrannen sbrannen added the in: data Issues in data modules (jdbc, orm, oxm, tx) label Sep 20, 2026
@sbrannen sbrannen added this to the 7.1.x milestone Sep 20, 2026
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Sep 20, 2026

@sbrannen sbrannen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions and the PR.

I've requested a small fix.

Comment on lines +364 to +366
for (int i = 0; i <= jdbcIndex - this.currentIndexedParams.size(); i++) {
this.currentIndexedParams.add(null);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iterating based on the current size() and adding to the list within the loop will lead to errors.

Perhaps you can take inspiration from DefaultStatementSpec.param(int, Object)'s handling of indexedParams?

return this;
}

private static void addIndexedParam(List<@Nullable Object> indexedParams, int jdbcIndex, @Nullable Object value) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbrannen I make this util method as static to avoid misusing this.indexedParams, is it recommended?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, making it static is a good call, but please move addIndexedParam() and validateIndexedParamValue() below statementCreatorForIndexedParamsWithKeys().

Add missing methods:
1. `param(int jdbcIndex, @nullable Object value)`
2. `param(int jdbcIndex, @nullable Object value, int sqlType)`
3. `param(String name, @nullable Object value, int sqlType)`

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
return this;
}

private static void addIndexedParam(List<@Nullable Object> indexedParams, int jdbcIndex, @Nullable Object value) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, making it static is a good call, but please move addIndexedParam() and validateIndexedParamValue() below statementCreatorForIndexedParamsWithKeys().

@sbrannen sbrannen added the status: waiting-for-feedback We need additional information before we can continue label Sep 21, 2026
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: waiting-for-feedback We need additional information before we can continue type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants