Skip to content

Add JDBC SqlValue classes for arrays [SPR-16904] #21443

Closed
@spring-projects-issues

Description

@spring-projects-issues

Philippe Marschall opened SPR-16904 and commented

We are looking at converting some of our inlist usage to SQL arrays. We were a bit surprised that using arrays with JdbcTemplate requires implementing a custom SqlValue.

We propose introducing two classes.

  • An abstract base class that binds and frees the array but that leaves creating the array to a concrete subclass.
  • A concrete subclass that creates the array using Connection.createArrayOf(String, Object[])

The reason for this is that users might want to or may even have to use vendor extensions for creating arrays. We know of two such vendor extensions that might be interesting:

  • Oracle requires using a vendor method to create an array as Oracle does not support anonymous arrays.
  • PostgreS offers a vendor method for creating arrays from arrays of primitive arrays, therefore eliminating the need for boxing.

We do not propose to include subclasses for them.

Potentially, for convenience reasons java.util.Collection types could also be supported, for now we decided against this.


Affects: 5.0 GA

Referenced from: pull request #1850

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions