ResultSet rs = ps.executeQuery();
Set aliases = query.getAliases();
while (rs.next()) {
Row row;
Set columns;
SQLQuery.Alias alias;
Table table;
pos = 0;
Iterator i = aliases.iterator();
while (i.hasNext()) {
alias = (SQLQuery.Alias) i.next();
table = alias.getTable();
Set fcs = alias.getFetchColumns();
if (!fcs.isEmpty()) {
row = new Row(table);
Iterator fci = fcs.iterator();
while (fci.hasNext()) {
Column c = (Column) fci.next();
// TODO will this be flexible enough?
row.setValue(c, rs.getObject(++pos));
}
if (table.equals(query.getTargetTable())) {
list.add(row);
} else {
extraRows.add(row);