List<Expression<?>> sources = new ArrayList<Expression<?>>(metadata.getJoins().size());
for (JoinExpression join : metadata.getJoins()) {
if (join.getType() == JoinType.DEFAULT) {
sources.add(join.getTarget());
} else {
Operation target = (Operation) join.getTarget();
sources.add(target.getArg(1));
}
}
// ordered
if (!metadata.getOrderBy().isEmpty()) {
order(metadata, sources, list);