If we declare an entity-level @Computed(shadowOf=...) then use that class as the default FROM table, duh.

This commit is contained in:
Par Winzell
2007-08-22 05:55:57 +00:00
parent a6f5211db4
commit 470c56d38c
@@ -353,15 +353,21 @@ public abstract class BuildVisitor implements ExpressionVisitor
if (selectClause.getFromOverride() != null) { if (selectClause.getFromOverride() != null) {
selectClause.getFromOverride().accept(this); selectClause.getFromOverride().accept(this);
} else {
Computed computed = _types.getMarshaller(pClass).getComputed();
Class<? extends PersistentRecord> tClass;
if (computed != null && !PersistentRecord.class.equals(computed.shadowOf())) {
tClass = computed.shadowOf();
} else if (_types.getTableName(pClass) != null) { } else if (_types.getTableName(pClass) != null) {
_builder.append(" from "); tClass = pClass;
appendTableName(pClass);
_builder.append(" as ");
appendTableAbbreviation(pClass);
} else { } else {
throw new SQLException("Query on @Computed entity with no FromOverrideClause."); throw new SQLException("Query on @Computed entity with no FromOverrideClause.");
} }
_builder.append(" from ");
appendTableName(tClass);
_builder.append(" as ");
appendTableAbbreviation(tClass);
}
for (Join clause : selectClause.getJoinClauses()) { for (Join clause : selectClause.getJoinClauses()) {
clause.accept(this); clause.accept(this);