【发布时间】:2017-10-19 01:39:00
【问题描述】:
我有一个 BusinessRowMapper 类,它实现 RowMapper 以将 PostGres JSONB 对象转换为 Java 对象。
BusinessRowMapper implements RowMapper<PersonDetails>
它会覆盖 mapRow
public class BusinessRowMapper implements RowMapper<PersonDetails> {
private PersonUtility utils;
public BusinessRowMapper(PersonUtility utils) {
super();
this.utils = utils;
}
public PersonDetails mapRow(final ResultSet rs, final int rowNum) throws SQLException {
PersonDetails personDetail = utils.unMarshallAndConvertData(rs
.getString(ConstantsV4.COLUMN_CUST_DTLS_JSON_DOC));
return personDetail;
}
}
现在,我如何在这个 BusinessRowMapper bean 中进行 Spring 管理的 PersonUtility Bean 注入,而不是将实用程序 bean 作为构造函数参数传递给 BusinessRowMapper?
getNamedParameterJdbcTemplate().query(
ConstantsV4.RETRIEVE_PERSON_DETAIL_QUERY, params,
new BusinessRowMapper(utility));
【问题讨论】:
标签: java json spring postgresql inject