Spring managed bean injection in class implementing RowMapper

Viewed 616

I have a class BusinessRowMapper that implements RowMapper to convert PostGres JSONB object to Java object.

BusinessRowMapper implements RowMapper<PersonDetails>

it overrides 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;
    }
}

Now, How do I do Spring managed Injection of PersonUtility Bean in this BusinessRowMapper bean rather than passing the utility bean as constructor argument to BusinessRowMapper?

getNamedParameterJdbcTemplate().query(
                        ConstantsV4.RETRIEVE_PERSON_DETAIL_QUERY, params,
                        new BusinessRowMapper(utility));
1 Answers
Related