空指针异常在 namedParameterJdbcTemplate 中。

huangapple 未分类评论44阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年4月6日 02:07:46
  • 转载请务必保留本文链接:https://java.coder-hub.com/61047195.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定