Deprecated. THIS WILL BE REMOVED BY FINAL RELEASE
Use RowHandler.handleRow(Object) instead.
queryForList(String,Object,RowHandler) has been renamed BACK to queryWithRowHandler(String,Object,RowHandler).
The new signature is:
void queryWithRowHandler(String id, Object parameterObject, RowHandler rowHandler)
throws SQLException;
The RowHandler interface will also be changed back to the original strategy used in 1.x. That is, there will no
longer be a List parameter in the method signature of the handleRow() method. The new signature is:
public void handleRow(Object valueObject);
This was necessary to make the API more flexible. Many people complained about the change because they did not
want to return a list. They may have been using a RowHandler to build a Map, or even aggregate into a single
result object. In these cases the List parameter and return type on the RowHandler API was unecessary, confusing and extra overhead.
WHAT SHOULD YOU DO?
Well, basically your RowHandlers will need to be changed to handle the List themselves. For example:
----------------------------
// OLD WAY
public class MyRowHandler imlements RowHandler {
public void handleRow(Object valueObject, List list) {
list.add(valueObject);
}
}
// NEW WAY
public class MyNewRowHandler imlements RowHandler {
private List list = new ArrayList();
public void handleRow(Object valueObject) {
list.add(valueObject);
}
public List getList () {
return list;
}
}
----------------------------
Obviously the calling code will need to be changed too. For example:
----------------------------
// OLD WAY
RowHandler rowHandler = new MyRowHandler();
List list = sqlMap.queryForList("name", param, rowHandler);
// NEW WAY
RowHandler rowHandler = new MyNewRowHandler();
sqlMap.queryWithRowHandler("name", param, rowHandler);
List list = rowHandler.getList();
----------------------------
The cost is a few extra lines of code, but the benefit is a great deal of
flexibility and eliminated redundancy.