2

When we define Mapper for a class, we have to fetch every column in sql queries in order to map with the Class in jdbc resultsetmapper

eg.

public class Mapper implements ResultSetMapper<MyClass>{
    public MyClass map(int index, ResultSet rs, StatementContext ctx) throws SQLException{
        MyClass mc = new MyClass();
        mc.setEntity1(rs.getString("column1"));
        mc.setEntity2(rs.getString("column2"));
        mc.setEntity3(rs.getString("column3"));
        return mc;
    }
}

For using this mapper, I have to fetch every column used in Mapper, but If I fetch only 2 columns it will throw PSQLException.

So instead of defining another Mapper for fetching 2 columns, is there any possible method to Use the same Mapper for mapping to MyClass?

pingw33n
  • 12,292
  • 2
  • 37
  • 38
Dheerendra
  • 1,488
  • 5
  • 19
  • 36

0 Answers0