I want to join two tables and read all the columns within java. In java the resultset contains all the fields but they have the same names for both tables. Their are about 65 columns and I do not want to specify each column after the select.
SQL query:
select * from Tab a join Tab b on a.id = b.id;
In java I want:
private MyObject map(ResultSet rs) throws SQLException {
myObj.setNameA(rs.getString("a_name"));
myObj.setNameB(rs.getString("b_name"));
}
My idea was to rename each column with the variables of the tables like 'a_name' and 'b_name' and then to read the fields in java.
Can I rename each field of the table without specifying each column after the select? (like 'select a.name as a_name, b.name as b_name,...')
Or is their any better solution to get all the columns in java?