I have 3 tables which correspond to 3 Java objects:
- Object A (Table A)
- Object B (Table B)
- Object C (Table C)
I will query Table A and JOIN on Table B and Table C. I've only used the JdbcTemplate to query for Table A and have used Spring's BeanPropertyRowMapper to map the result to Object A. But now I would like to JOIN the remaining tables.
So I've created a new Java object that stores the 3 tables mentioned above. This looks like:
public class AllTables {
private ObjectA tableA;
private ObjectB tableB;
private ObjectC tableC;
}
And an example query would look like:
SELECT tableA.*, tableB.*, tableC.*
FROM table_a tableA
JOIN tableB
ON tableB.ref_id = tableA.id
JOIN table_c tableC
ON tableC.ref_id = tableA.id;
Does Spring provide any facilities to auto-map these tables / columns with their respective Java equivalent object?
I do not want to manually map the ResultSet and if I have to, is there a way to pass a ResultSet to BeanPropertyRowMapper manually to leverage the column mapping?