ArrayList<T> result = new ArrayList<T>();
// For performance reasons we reuse the same arguments-array and InstantiatorArguments-object for all rows.
// This should be fine as long as the instantiators don't hang on to their arguments for too long.
Object[] arguments = new Object[types.size()];
InstantiatorArguments instantiatorArguments = new InstantiatorArguments(types, Arrays.asList(arguments));
while (resultSet.next()) {
for (int i = 0; i < arguments.length; i++)
arguments[i] = resultSet.getObject(i+1);