if (source == null) break;
String viewColumnName = column.getColumnName();
String sourceColumnName = column.getPropertyName(); // getColumnName() returns alias
Column sourceColumn = source.getColumn(sourceColumnName);
if (sourceColumn == null) {
throw new InvalidQueryException(Visitors.readable(command),
"The view references a non-existant column '"
+ column.getColumnName() + "' in '" + source.getName() + "'");
}
viewColumns.add(new ImmutableColumn(viewColumnName, sourceColumn.getPropertyType(),
sourceColumn.isFullTextSearchable()));
}
if (viewColumns.size() != columns.size()) {
// We weren't able to resolve all of the columns,
// so maybe the columns were referencing yet-to-be-built views ...
continue;
}
// If we could resolve the definition ...
ImmutableView view = new ImmutableView(name, viewColumns, command);
definitions.remove(name);
schemata = schemata.with(view);
added = true;
}
} while (added && !definitions.isEmpty());
if (!definitions.isEmpty()) {
QueryCommand command = definitions.values().iterator().next();
throw new InvalidQueryException(Visitors.readable(command), "The view definition cannot be resolved: "
+ Visitors.readable(command));
}
return schemata;
}