英文:
null pointer in namedParameterJdbcTemplate
问题
我发现namedParameterJdbcTemplate的值为null。
static String TABLE = "select * from cdh_spectrum_xstore_reg.%s";
static String GET_TRANSACTION_BY_FILENAME = " where etl_source_name = :etlSourceName" +
" and pos_key in (select pos_key from cdh_spectrum_xstore_reg.pos_log where etl_source_name = :etlSourceName order by load_date desc limit 1)" +
" and batch_ts in (select batch_ts from cdh_spectrum_xstore_reg.pos_log where etl_source_name = :etlSourceName order by load_date desc limit 1)" +
" limit 1";
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
public Transaction getIsolatedTransactionDetails(String fileName) {
return namedParameterJdbcTemplate.queryForObject(String.format(TABLE, "pos_log") + GET_TRANSACTION_BY_FILENAME,
new MapSqlParameterSource("etlSourceName", fileName),
transactionMapper);
}
英文:
I am getting the namedParameterJBCtemplate as null value
static String TABLE = "select * from cdh_spectrum_xstore_reg.%s";
static String GET_TRANSACTION_BY_FILENAME = " where etl_source_name = :etlSourceName" +
" and pos_key in (select pos_key from cdh_spectrum_xstore_reg.pos_log where etl_source_name = :etlSourceName order by load_date desc limit 1)" +
" and batch_ts in (select batch_ts from cdh_spectrum_xstore_reg.pos_log where etl_source_name = :etlSourceName order by load_date desc limit 1)" +
" limit 1";
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
public Transaction getIsolatedTransactionDetails(String fileName) {
return namedParameterJdbcTemplate.queryForObject(String.format(TABLE, "pos_log") + GET_TRANSACTION_BY_FILENAME,
new MapSqlParameterSource("etlSourceName", fileName),
transactionMapper);
}
Here the filename is correctly coming when I debug What I noticed is namedParameterJdbcTemplate is giving null.
专注分享java语言的经验与见解,让所有开发者获益!
评论