Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16669

Unable to bind a null value for UUID column with PostgreSQL

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 4.3.14, 5.0.4
    • Fix Version/s: 4.3.15, 5.0.5
    • Component/s: Data:JDBC
    • Labels:
    • Last commented by a User:
      true

      Description

      PostgreSQL database defines the type UUID (this type does not exist in java.sql.Types).

      I want to use this kind of PreparedStatement:

      SELECT ... WHERE :VAL IS NOT NULL AND :VAL = <my_uuid_column>
      

      And I want to bind a null value for VAL.
      In this specific case, PostgreSQL JDBC driver requires the data type to be specified. And since the UUID data type does not exist in java.sql.Types, we must specify the type name as well, by calling PreparedStatement.setNull(_, java.sql.Types.OTHER, "uuid").
      With plain old java (Connection and PreparedStatement), this works fine.

      Using NamedParameterJdbcTemplate (and providing the "data type" and "data type name" in a MapSqlParameterSource), I'm not able to make it work.
      Under the hood, StatementCreatorUtils.setNull(_, _, type, typeName) delegates to PreparedStatement.setNull(_, type) (with no type name) when type is Types.OTHER.

      Shouldn't it call PreparedStatement.setNull(_, type, typeName) when typeName is provided (non null) instead?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              Rémi Rémi Aubel
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 23 weeks, 6 days ago