From 3bc33872c5b53097ded0ab368c448897f94cb7f2 Mon Sep 17 00:00:00 2001 From: zell Date: Wed, 22 Aug 2007 05:55:57 +0000 Subject: [PATCH] If we declare an entity-level @Computed(shadowOf=...) then use that class as the default FROM table, duh. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2205 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/jdbc/depot/BuildVisitor.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java index 26e858da..ad5fc063 100644 --- a/src/java/com/samskivert/jdbc/depot/BuildVisitor.java +++ b/src/java/com/samskivert/jdbc/depot/BuildVisitor.java @@ -353,14 +353,20 @@ public abstract class BuildVisitor implements ExpressionVisitor if (selectClause.getFromOverride() != null) { selectClause.getFromOverride().accept(this); - } else if (_types.getTableName(pClass) != null) { - _builder.append(" from "); - appendTableName(pClass); - _builder.append(" as "); - appendTableAbbreviation(pClass); - } else { - throw new SQLException("Query on @Computed entity with no FromOverrideClause."); + Computed computed = _types.getMarshaller(pClass).getComputed(); + Class tClass; + if (computed != null && !PersistentRecord.class.equals(computed.shadowOf())) { + tClass = computed.shadowOf(); + } else if (_types.getTableName(pClass) != null) { + tClass = pClass; + } else { + 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()) {