}
@SuppressWarnings({"unchecked"})
protected <T> Set<T> listSet(Class[] types, int max, boolean close) {
Set<T> result = new LinkedHashSet<T>(initialCollectionSize(max));
ResultSetMapper rsm = executeAndBuildResultSetMapper();
if (types == null) {
types = rsm.resolveTables();
}
Object previousElement = null;
while (rsm.next()) {
Object[] objects = rsm.parseObjects(types);
Object row = resolveRowResults(objects);
int size = result.size();
T newElement = (T) row;