From d5619a3b2824f6acd99d5e40049521404d206011 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 6 Sep 2008 02:38:20 +0000 Subject: [PATCH] Automatically add the shadow to our type set for @Computed(shadowOf=FooRecord) record classes. --- src/java/com/samskivert/jdbc/depot/DepotTypes.java | 11 ++++++++++- .../samskivert/jdbc/depot/clause/SelectClause.java | 9 --------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/DepotTypes.java b/src/java/com/samskivert/jdbc/depot/DepotTypes.java index d51f9c1..4cffe24 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotTypes.java +++ b/src/java/com/samskivert/jdbc/depot/DepotTypes.java @@ -169,8 +169,17 @@ public class DepotTypes if (_classMap.containsKey(type)) { return; } - _classMap.put(type, ctx.getMarshaller(type)); + + // add the class in question + DepotMarshaller marsh = ctx.getMarshaller(type); + _classMap.put(type, marsh); _classIx.put(type, _classIx.size()); + + // if this class is @Computed and has a shadow, add its shadow + if (marsh.getComputed() != null && + !PersistentRecord.class.equals(marsh.getComputed().shadowOf())) { + addClass(ctx, marsh.getComputed().shadowOf()); + } } /** diff --git a/src/java/com/samskivert/jdbc/depot/clause/SelectClause.java b/src/java/com/samskivert/jdbc/depot/clause/SelectClause.java index 6216d5a..e2f3676 100644 --- a/src/java/com/samskivert/jdbc/depot/clause/SelectClause.java +++ b/src/java/com/samskivert/jdbc/depot/clause/SelectClause.java @@ -175,15 +175,6 @@ public class SelectClause extends QueryClause { classSet.add(_pClass); - // TODO: This should not have to do a getAnnotation(). - Computed computed = _pClass.getAnnotation(Computed.class); - if (computed != null) { - Class shadowClass = computed.shadowOf(); - if (!PersistentRecord.class.equals(shadowClass)) { - classSet.add(shadowClass); - } - } - if (_fromOverride != null) { _fromOverride.addClasses(classSet); }