10
我使用了SimpleJdbcTemplate和MapSqlParameterSource在如下因素的方法:SimpleJdbcTemplate類和空參數
MapSqlParameterSource parameterSource = new MapSqlParameterSource();
parameterSource.addValue("typeId", typeId, Types.BIGINT);
List<Long> ids = _jdbcTemplate.query(_selectIdByParameters, new EntityIdRowMapper(), parameterSource);
當typeId
(這是一個Long
)是null
,那麼查詢看起來下列方式:
SELECT id FROM XXX WHERE typeId = null
,而我希望它產生
SELECT id FROM XXX WHERE typeId IS NULL
我已經reported this issue和響應是
你將不得不提供基於您的查詢參數的適當的SQL語句。
因此,我的代碼散佈着空檢查。
是否有處理髮送到SimpleJdbcTemplate
空參數更優雅的方式?
將它的工作,如果是NamedParameterJdbcTemplate是用來代替了SimpleJdbcTemplate? – 2016-09-27 06:02:15