Skip to content

Support PreparedStatementCreator in NamedParameterJdbcTemplate [SPR-13178] #17770

Closed

Description

@spring-projects-issues

Hendy Irawan opened SPR-13178 and commented

Makes it possible to do this http://stackoverflow.com/a/4656173/122441 with named parameters:

private static final String ARRAY_DATATYPE = "int4";
private static final String SQL_UPDATE = "UPDATE foo SET arr = ? WHERE d = ?";
final Integer[] existing = ...;
final DateTime dt = ...;

getJdbcTemplate().update(new PreparedStatementCreator() {
    @Override
    public PreparedStatement createPreparedStatement(final Connection con) throws SQLException {
        final PreparedStatement ret = con.prepareStatement(SQL_UPDATE);
        ret.setArray(1, con.createArrayOf(ARRAY_DATATYPE, existing));
        ret.setDate(2, new java.sql.Date(dt.getMillis()));
        return ret;
    }
});

Related to #17771, #17773


Affects: 4.1.7

2 votes, 3 watchers

Activity

  1. added
    status: waiting-for-triage
    in: data
    type: enhancement
    and removed
    type: enhancement
    on Jan 11, 2019
  2. added
    status: bulk-closed
    and removed
    status: waiting-for-triage
    on Jan 11, 2019
  3. spring-projects-issues commented on Jan 12, 2019

    @spring-projects-issues
    CollaboratorAuthor

    Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

  4. added
    status: duplicate
    and removed
    status: bulk-closed
    on Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: datastatus: duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions