The idea of this implementation for RowMapper is to have convenient tool for mapping ResultSet into nested object. Current implementation of BeanPropertyRowMapper doesn't support nor designed for nested properties.
class Employee {
public long id;
public long companyId;
public String lastName;
public Company company;
}
class Company {
public long id;
public String name;
}
NestedBeanPropertyRowMapper<Employee> rowMapper = NestedBeanPropertyRowMapper.newInstance(Employee.class);
rowMapper.setEntityDelimiter("__");
List<Employee> employees = jdbcTemplate.query("SELECT " +
" EMPLOYEE.*, " +
" COMPANY.ID as COMPANY__ID, " + // option1 without escaping column name
" COMPANY.NAME as `COMPANY.NAME` " + // option2 with escaping
" FROM EMPLOYEE JOIN COMPANY " +
" ON EMPLOYEE.COMPANY_ID = COMPANY.ID ",
new HashMap<>(), rowMapper);
Comment From: pivotal-issuemaster
@cziberpv Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-issuemaster
@cziberpv Thank you for signing the Contributor License Agreement!
Comment From: snicoll
@cziberpv thank you for the PR. Before we consider it, we'd need tests that cover the use cases this new class brings. Can you please add some?
Comment From: snicoll
Closing due to lack of requested feedback. If the feedback is provided we can consider reopening.