Skip to content

Discrepancy between sql parsing in SimpleJdbcTemplate and NamedParameterJdbcTemplate when doing batchUpdates [SPR-5162] #9835

Closed
@spring-projects-issues

Description

@spring-projects-issues

Steve Ungerer opened SPR-5162 and commented

NamedParameterJdbcTemplate provides a protected method getParsedSql to obtain a ParsedSql object. This allows for custom sql modification prior to being passed off to the internal NamedParameterUtils class which offers no callbacks.

SimpleJdbcTemplate delegates to NamedParameterJdbcOperations (default being NamedParameterJdbcTemplate) for all methods using named parameters except for the batchUpdate methods. These methods use the private method doExecuteBatchUpdateWithNamedParameters which directly invokes NamedParameterUtils.

Thus, in order to handle custom sql modification for batchUpdates, SimpleJdbcTemplate must be overridden to not only use a custom subclass for the NamedParameterJdbcOperations but to invoke the custom logic in the applicable batchUpdate methods.

It would be nice to add batchUpdate to NamedParameterJdbcTemplate (as requested in #8007) and then delegate to this from SimpleJdbcTemplate. In this way, all sql parsing would be routed through an overridable getParsedSql.


Affects: 2.0.8, 2.5 final, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    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