34,591
社区成员
发帖
与我相关
我的任务
分享
(List<State>) new QueryRunner().query(conn, "select * from states", new BeanListHandler(State.class,new BasicRowProcessor(new StateBeanProcessor())));
public class StateBeanProcessor extends BeanProcessor {
@Override
protected int[] mapColumnsToProperties(ResultSetMetaData rsmd, PropertyDescriptor[] props) throws SQLException {
int[] mapping = super.mapColumnsToProperties(rsmd, props);
/*Map database columns to fields in the order in which they appear
1st column in the DB will be mapped to 1st field in the Java
class and so on.. */
for(int i=0;i<mapping.length;++i) {
mapping[i]=i;
}
}
}