Announcement Announcement Module
Collapse
No announcement yet.
Null query parameters using MapSqlParameterSource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Null query parameters using MapSqlParameterSource

    Hi,

    I'm using SimpleJdbcQuery and MapSqlParameterSource in the folowing way:

    Code:
            MapSqlParameterSource parameterSource = new MapSqlParameterSource();
            parameterSource.addValue("typeId", typeId, Types.BIGINT);
    
            List<Long> ids = _jdbcTemplate.query(_selectIdByParameters, new EntityIdRowMapper(), parameterSource);
    When typeId ( which is a Long ) is null, then the query looks in the following way:

    Code:
    SELECT id FROM XXX WHERE typeId = null
    whereas I would like it to generate

    Code:
    SELECT id FROM XXX WHERE typeId IS NULL
    What am I doing wrong here?

    Thanks,

    Robert

  • #2
    Try to look which dialect do you use, for some databases "= null" is ok even not compatible with ANSI

    Comment


    • #3
      Unfortunately that is a no-go for me since MySQL requires IS NULL.

      Comment

      Working...
      X