cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r397877 - in /incubator/cayenne/trunk/cayenne-jpa/src: main/java/org/apache/cayenne/jpa/map/ main/java/org/apache/cayenne/util/ test/java/org/apache/cayenne/jpa/bridge/
Date Fri, 28 Apr 2006 12:13:50 GMT
Author: aadamchik
Date: Fri Apr 28 05:13:45 2006
New Revision: 397877

URL: http://svn.apache.org/viewcvs?rev=397877&view=rev
Log:
changing JpaEntityMap traversal algorithm to the one based on annotations.

Added:
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TreeNodeChild.java
Removed:
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversableTreeNode.java
Modified:
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeOverride.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntity.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityListeners.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityResult.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaJoinTable.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaNamedQuery.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSecondaryTable.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSqlResultSetMapping.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaTable.java
    incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversalUtil.java
    incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
Fri Apr 28 05:13:45 2006
@@ -58,13 +58,9 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.cayenne.util.TraversableTreeNode;
+import org.apache.cayenne.util.TreeNodeChild;
 
-public abstract class JpaAbstractEntity implements TraversableTreeNode {
-
-    static final Class[] TRAVERSABLE_CHILDREN = new Class[] {
-            JpaAttribute.class, JpaEmbeddedId.class, JpaId.class
-    };
+public abstract class JpaAbstractEntity {
 
     protected String className;
     protected AccessType access;
@@ -84,23 +80,7 @@
     protected Collection<JpaId> ids;
     protected Collection<JpaAttribute> attributes;
 
-    public Class[] getTraversableChildTypes() {
-        return JpaAbstractEntity.TRAVERSABLE_CHILDREN;
-    }
-
-    public Object getTraversableChild(int nodeTypeIndex) {
-        switch (nodeTypeIndex) {
-            case 0:
-                return attributes;
-            case 1:
-                return embeddedId;
-            case 2:
-                return ids;
-            default:
-                throw new ArrayIndexOutOfBoundsException(nodeTypeIndex);
-        }
-    }
-
+    @TreeNodeChild
     public JpaEmbeddedId getEmbeddedId() {
         return embeddedId;
     }
@@ -109,6 +89,7 @@
         this.embeddedId = embeddedId;
     }
 
+    @TreeNodeChild
     public JpaEntityListeners getEntityListeners() {
         return entityListeners;
     }
@@ -197,6 +178,7 @@
         this.preUpdate = preUpdate;
     }
 
+    @TreeNodeChild(type=JpaId.class)
     public Collection<JpaId> getIds() {
         if (ids == null) {
             ids = new ArrayList<JpaId>();
@@ -205,6 +187,7 @@
         return ids;
     }
 
+    @TreeNodeChild(type=JpaAttribute.class)
     public Collection<JpaAttribute> getAttributes() {
         if (attributes == null) {
             attributes = new ArrayList<JpaAttribute>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
Fri Apr 28 05:13:45 2006
@@ -61,6 +61,8 @@
 import javax.persistence.EnumType;
 import javax.persistence.TemporalType;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 /**
  * Represents a mapping of an entity attribute.
  * 
@@ -122,6 +124,7 @@
 
     // **** Semantics properties
 
+    @TreeNodeChild
     public JpaBasic getBasic() {
         return basic;
     }
@@ -131,6 +134,7 @@
         this.basic = basic;
     }
 
+    @TreeNodeChild
     public JpaManyToMany getManyToMany() {
         return manyToMany;
     }
@@ -140,6 +144,7 @@
         this.manyToMany = manyToMany;
     }
 
+    @TreeNodeChild
     public JpaManyToOne getManyToOne() {
         return manyToOne;
     }
@@ -149,6 +154,7 @@
         this.manyToOne = manyToOne;
     }
 
+    @TreeNodeChild
     public JpaOneToMany getOneToMany() {
         return oneToMany;
     }
@@ -158,6 +164,7 @@
         this.oneToMany = oneToMany;
     }
 
+    @TreeNodeChild
     public JpaOneToOne getOneToOne() {
         return oneToOne;
     }
@@ -193,6 +200,7 @@
 
     // **** Mapping properties
 
+    @TreeNodeChild
     public JpaColumn getColumn() {
         return column;
     }
@@ -202,6 +210,7 @@
         this.column = column;
     }
 
+    @TreeNodeChild(type=JpaJoinColumn.class)
     public Collection<JpaJoinColumn> getJoinColumns() {
         if (joinColumns == null) {
             joinColumns = new ArrayList<JpaJoinColumn>() {
@@ -222,6 +231,7 @@
         return joinColumns;
     }
 
+    @TreeNodeChild
     public JpaJoinTable getJoinTable() {
         return joinTable;
     }

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeOverride.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeOverride.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeOverride.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttributeOverride.java
Fri Apr 28 05:13:45 2006
@@ -57,6 +57,8 @@
 
 import javax.persistence.AttributeOverride;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaAttributeOverride {
 
     protected String name;
@@ -74,6 +76,7 @@
         }
     }
 
+    @TreeNodeChild
     public JpaColumn getColumn() {
         return column;
     }

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
Fri Apr 28 05:13:45 2006
@@ -58,6 +58,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 /**
  * A descriptor of a persistent class whose instances are stored as an intrinsic part of
  * an owning entity and share the identity of that entity.
@@ -78,6 +80,7 @@
         this.access = access;
     }
 
+    @TreeNodeChild(type=JpaEmbeddableAttribute.class)
     public Collection<JpaEmbeddableAttribute> getEmbeddableAttributes() {
         if (embeddableAttributes == null) {
             embeddableAttributes = new ArrayList(5);

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
Fri Apr 28 05:13:45 2006
@@ -58,6 +58,8 @@
 import javax.persistence.EnumType;
 import javax.persistence.TemporalType;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 /**
  * An attribute that belongs to {@link org.apache.cayenne.jpa.map.JpaEmbeddable}.
  * 
@@ -81,6 +83,7 @@
         this.name = name;
     }
 
+    @TreeNodeChild
     public JpaBasic getBasic() {
         return basic;
     }

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
Fri Apr 28 05:13:45 2006
@@ -58,29 +58,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.apache.cayenne.util.TraversableTreeNode;
+import org.apache.cayenne.util.TreeNodeChild;
 
-public class JpaEmbeddedId implements TraversableTreeNode {
-
-    static final Class[] TRAVERSABLE_CHILDREN = new Class[] {
-        JpaAttributeOverride.class
-    };
+public class JpaEmbeddedId {
 
     protected String name;
     protected Collection<JpaAttributeOverride> attributeOverrides;
 
-    public Class[] getTraversableChildTypes() {
-        return TRAVERSABLE_CHILDREN;
-    }
-
-    public Object getTraversableChild(int nodeTypeIndex) {
-        if (nodeTypeIndex == 0) {
-            return attributeOverrides;
-        }
-
-        throw new ArrayIndexOutOfBoundsException(nodeTypeIndex);
-    }
-
     public String getName() {
         return name;
     }
@@ -89,6 +73,7 @@
         this.name = name;
     }
 
+    @TreeNodeChild(type=JpaAttributeOverride.class)
     public Collection<JpaAttributeOverride> getAttributeOverrides() {
         if (attributeOverrides == null) {
             attributeOverrides = new ArrayList<JpaAttributeOverride>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntity.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntity.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntity.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntity.java
Fri Apr 28 05:13:45 2006
@@ -58,6 +58,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 /**
  * A JPA-compliant entity.
  * 
@@ -65,28 +67,6 @@
  */
 public class JpaEntity extends JpaAbstractEntity {
 
-    static final Class[] EXTRA_TRAVERSABLE_CHILDREN = new Class[] {
-            JpaTable.class, JpaAttributeOverride.class, JpaNamedQuery.class
-    };
-    static final Class[] TRAVERSABLE_CHILDREN = new Class[JpaAbstractEntity.TRAVERSABLE_CHILDREN.length
-            + EXTRA_TRAVERSABLE_CHILDREN.length];
-
-    static {
-        System.arraycopy(
-                EXTRA_TRAVERSABLE_CHILDREN,
-                0,
-                TRAVERSABLE_CHILDREN,
-                0,
-                EXTRA_TRAVERSABLE_CHILDREN.length);
-
-        System.arraycopy(
-                JpaAbstractEntity.TRAVERSABLE_CHILDREN,
-                0,
-                TRAVERSABLE_CHILDREN,
-                EXTRA_TRAVERSABLE_CHILDREN.length,
-                JpaAbstractEntity.TRAVERSABLE_CHILDREN.length);
-    }
-
     protected String name;
     protected JpaTable table;
     protected JpaInheritance inheritance;
@@ -101,25 +81,6 @@
     protected Collection<JpaSecondaryTable> secondaryTables;
     protected Collection<JpaPrimaryKeyJoinColumn> primaryKeyJoinColumns;
 
-    public Class[] getTraversableChildTypes() {
-        return JpaEntity.TRAVERSABLE_CHILDREN;
-    }
-
-    public Object getTraversableChild(int nodeTypeIndex) {
-
-        switch (nodeTypeIndex) {
-            case 0:
-                return table;
-            case 1:
-                return attributeOverrides;
-            case 2:
-                return namedQueries;
-            default:
-                return super.getTraversableChild(nodeTypeIndex
-                        - EXTRA_TRAVERSABLE_CHILDREN.length);
-        }
-    }
-
     public String getName() {
         return name;
     }
@@ -128,6 +89,7 @@
         this.name = name;
     }
 
+    @TreeNodeChild
     public JpaDiscriminatorColumn getDiscriminatorColumn() {
         return discriminatorColumn;
     }
@@ -158,6 +120,7 @@
         this.discriminatorValue = discriminatorValue;
     }
 
+    @TreeNodeChild
     public JpaInheritance getInheritance() {
         return inheritance;
     }
@@ -166,6 +129,7 @@
         this.inheritance = inheritance;
     }
 
+    @TreeNodeChild
     public JpaSequenceGenerator getSequenceGenerator() {
         return sequenceGenerator;
     }
@@ -174,6 +138,7 @@
         this.sequenceGenerator = sequenceGenerator;
     }
 
+    @TreeNodeChild
     public JpaSqlResultSetMapping getSqlResultSetMapping() {
         return sqlResultSetMapping;
     }
@@ -182,6 +147,7 @@
         this.sqlResultSetMapping = sqlResultSetMapping;
     }
 
+    @TreeNodeChild
     public JpaTable getTable() {
         return table;
     }
@@ -190,6 +156,7 @@
         this.table = table;
     }
 
+    @TreeNodeChild
     public JpaTableGenerator getTableGenerator() {
         return tableGenerator;
     }
@@ -202,6 +169,7 @@
      * Returns a collection of attribute overrides. Attribute overrides allows to change
      * the definition of attributes from a mapped superclass.
      */
+    @TreeNodeChild(type = JpaAttributeOverride.class)
     public Collection<JpaAttributeOverride> getAttributeOverrides() {
         if (attributeOverrides == null) {
             attributeOverrides = new ArrayList<JpaAttributeOverride>();
@@ -210,6 +178,7 @@
         return attributeOverrides;
     }
 
+    @TreeNodeChild(type = JpaNamedNativeQuery.class)
     public Collection<JpaNamedNativeQuery> getNamedNativeQueries() {
         if (namedNativeQueries == null) {
             namedNativeQueries = new ArrayList();
@@ -217,6 +186,7 @@
         return namedNativeQueries;
     }
 
+    @TreeNodeChild(type = JpaNamedQuery.class)
     public Collection<JpaNamedQuery> getNamedQueries() {
         if (namedQueries == null) {
             namedQueries = new ArrayList();
@@ -229,6 +199,7 @@
      * of a primary table. PK join columns used by subclasses in a
      * {@link javax.persistence.InheritanceType#JOINED} mapping scenario.
      */
+    @TreeNodeChild(type = JpaPrimaryKeyJoinColumn.class)
     public Collection<JpaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
         if (primaryKeyJoinColumns == null) {
             primaryKeyJoinColumns = new ArrayList();
@@ -236,6 +207,7 @@
         return primaryKeyJoinColumns;
     }
 
+    @TreeNodeChild(type = JpaSecondaryTable.class)
     public Collection<JpaSecondaryTable> getSecondaryTables() {
         if (secondaryTables == null) {
             secondaryTables = new ArrayList();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityListeners.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityListeners.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityListeners.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityListeners.java
Fri Apr 28 05:13:45 2006
@@ -58,6 +58,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 /**
  * A collection of entity listener descriptors.
  * 
@@ -69,6 +71,7 @@
 
     protected Collection<JpaEntityListener> entityListeners;
 
+    @TreeNodeChild(type = JpaEntityListener.class)
     public Collection<JpaEntityListener> getEntityListeners() {
         if (entityListeners == null) {
             entityListeners = new ArrayList<JpaEntityListener>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityMap.java
Fri Apr 28 05:13:45 2006
@@ -6,7 +6,7 @@
 import javax.persistence.CascadeType;
 import javax.persistence.FlushModeType;
 
-import org.apache.cayenne.util.TraversableTreeNode;
+import org.apache.cayenne.util.TreeNodeChild;
 import org.objectstyle.cayenne.validation.ValidationResult;
 
 /**
@@ -15,11 +15,7 @@
  * 
  * @author Andrus Adamchik
  */
-public class JpaEntityMap implements TraversableTreeNode {
-
-    static final Class[] TRAVERSABLE_CHILDREN = new Class[] {
-            JpaEntity.class, JpaNamedQuery.class
-    };
+public class JpaEntityMap {
 
     // mapped properties
     protected String packageName;
@@ -61,21 +57,6 @@
         throw new UnsupportedOperationException("TODO");
     }
 
-    public Class[] getTraversableChildTypes() {
-        return TRAVERSABLE_CHILDREN;
-    }
-
-    public Object getTraversableChild(int nodeTypeIndex) {
-        switch (nodeTypeIndex) {
-            case 0:
-                return entities;
-            case 1:
-                return namedQueries;
-            default:
-                throw new ArrayIndexOutOfBoundsException(nodeTypeIndex);
-        }
-    }
-
     /**
      * Returns a JpaEntity describing a given persistent class.
      */
@@ -105,6 +86,7 @@
         return null;
     }
 
+    @TreeNodeChild
     public JpaEntityListeners getDefaultEntityListeners() {
         return defaultEntityListeners;
     }
@@ -163,6 +145,7 @@
         return cascades;
     }
 
+    @TreeNodeChild(type = JpaEmbeddable.class)
     public Collection<JpaEmbeddable> getEmbeddables() {
         if (embeddables == null) {
             embeddables = new ArrayList<JpaEmbeddable>();
@@ -171,6 +154,7 @@
         return embeddables;
     }
 
+    @TreeNodeChild(type = JpaEntity.class)
     public Collection<JpaEntity> getEntities() {
         if (entities == null) {
             entities = new ArrayList<JpaEntity>();
@@ -179,6 +163,7 @@
         return entities;
     }
 
+    @TreeNodeChild(type = JpaMappedSuperclass.class)
     public Collection<JpaMappedSuperclass> getMappedSuperclasses() {
         if (mappedSuperclasses == null) {
             mappedSuperclasses = new ArrayList<JpaMappedSuperclass>();
@@ -187,6 +172,7 @@
         return mappedSuperclasses;
     }
 
+    @TreeNodeChild(type = JpaNamedNativeQuery.class)
     public Collection<JpaNamedNativeQuery> getNamedNativeQueries() {
         if (namedNativeQueries == null) {
             namedNativeQueries = new ArrayList<JpaNamedNativeQuery>();
@@ -195,6 +181,7 @@
         return namedNativeQueries;
     }
 
+    @TreeNodeChild(type = JpaNamedQuery.class)
     public Collection<JpaNamedQuery> getNamedQueries() {
         if (namedQueries == null) {
             namedQueries = new ArrayList<JpaNamedQuery>();
@@ -203,6 +190,7 @@
         return namedQueries;
     }
 
+    @TreeNodeChild(type = JpaSequenceGenerator.class)
     public Collection<JpaSequenceGenerator> getSequenceGenerators() {
         if (sequenceGenerators == null) {
             sequenceGenerators = new ArrayList<JpaSequenceGenerator>();
@@ -211,6 +199,7 @@
         return sequenceGenerators;
     }
 
+    @TreeNodeChild(type = JpaSqlResultSetMapping.class)
     public Collection<JpaSqlResultSetMapping> getSqlResultSetMappings() {
         if (sqlResultSetMappings == null) {
             sqlResultSetMappings = new ArrayList<JpaSqlResultSetMapping>();
@@ -219,6 +208,7 @@
         return sqlResultSetMappings;
     }
 
+    @TreeNodeChild(type = JpaTableGenerator.class)
     public Collection<JpaTableGenerator> getTableGenerators() {
         if (tableGenerators == null) {
             tableGenerators = new ArrayList<JpaTableGenerator>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityResult.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityResult.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityResult.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEntityResult.java
Fri Apr 28 05:13:45 2006
@@ -60,6 +60,8 @@
 
 import javax.persistence.EntityResult;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaEntityResult {
 
     protected String entityClassName;
@@ -80,6 +82,7 @@
         }
     }
 
+    @TreeNodeChild(type=JpaFieldResult.class)
     public Collection<JpaFieldResult> getFieldResults() {
         if (fieldResults == null) {
             fieldResults = new ArrayList<JpaFieldResult>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
Fri Apr 28 05:13:45 2006
@@ -57,6 +57,8 @@
 
 import javax.persistence.TemporalType;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaId {
 
     protected String name;
@@ -64,6 +66,7 @@
     protected JpaGeneratedValue generatedValue;
     protected TemporalType temporal = TemporalType.TIMESTAMP;
 
+    @TreeNodeChild
     public JpaColumn getColumn() {
         return column;
     }
@@ -72,6 +75,7 @@
         this.column = column;
     }
 
+    @TreeNodeChild
     public JpaGeneratedValue getGeneratedValue() {
         return generatedValue;
     }

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaJoinTable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaJoinTable.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaJoinTable.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaJoinTable.java
Fri Apr 28 05:13:45 2006
@@ -60,6 +60,8 @@
 
 import javax.persistence.JoinTable;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaJoinTable {
 
     protected String name;
@@ -120,6 +122,7 @@
         this.schema = schema;
     }
 
+    @TreeNodeChild(type = JpaJoinColumn.class)
     public Collection<JpaJoinColumn> getInverseJoinColumns() {
         if (inverseJoinColumns == null) {
             inverseJoinColumns = new ArrayList<JpaJoinColumn>();
@@ -128,6 +131,7 @@
         return inverseJoinColumns;
     }
 
+    @TreeNodeChild(type = JpaJoinColumn.class)
     public Collection<JpaJoinColumn> getJoinColumns() {
         if (joinColumns == null) {
             joinColumns = new ArrayList<JpaJoinColumn>();
@@ -136,6 +140,7 @@
         return joinColumns;
     }
 
+    @TreeNodeChild(type = JpaUniqueConstraint.class)
     public Collection<JpaUniqueConstraint> getUniqueConstraints() {
         if (uniqueConstraints == null) {
             uniqueConstraints = new ArrayList<JpaUniqueConstraint>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManyToMany.java
Fri Apr 28 05:13:45 2006
@@ -66,7 +66,7 @@
     protected String targetEntityName;
     protected FetchType fetch = FetchType.LAZY;
     protected String mappedBy;
-    protected Collection cascades;
+    protected Collection<CascadeType> cascades;
 
     public JpaManyToMany() {
 

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaNamedQuery.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaNamedQuery.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaNamedQuery.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaNamedQuery.java
Fri Apr 28 05:13:45 2006
@@ -60,8 +60,7 @@
 
 import javax.persistence.NamedQuery;
 
-import org.apache.cayenne.util.HierarchicalTreeVisitor;
-import org.objectstyle.cayenne.project.ProjectPath;
+import org.apache.cayenne.util.TreeNodeChild;
 
 public class JpaNamedQuery {
 
@@ -83,18 +82,6 @@
         }
     }
 
-    public void traverse(HierarchicalTreeVisitor visitor, ProjectPath parentPath) {
-        ProjectPath path = parentPath != null
-                ? parentPath.appendToPath(this)
-                : new ProjectPath(this);
-
-        if (visitor.onStartNode(path)) {
-            // TODO, andrus, 4/24/2006 - traverse the hints
-
-            visitor.onFinishNode(path);
-        }
-    }
-
     public String getName() {
         return name;
     }
@@ -111,6 +98,7 @@
         this.query = query;
     }
 
+    @TreeNodeChild(type=JpaQueryHint.class)
     public Collection<JpaQueryHint> getHints() {
         if (hints == null) {
             hints = new ArrayList<JpaQueryHint>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSecondaryTable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSecondaryTable.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSecondaryTable.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSecondaryTable.java
Fri Apr 28 05:13:45 2006
@@ -60,6 +60,8 @@
 
 import javax.persistence.SecondaryTable;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaSecondaryTable extends JpaTable {
 
     protected Collection<JpaPrimaryKeyJoinColumn> primaryKeyJoinColumns;
@@ -86,6 +88,7 @@
         }
     }
 
+    @TreeNodeChild(type = JpaPrimaryKeyJoinColumn.class)
     public Collection<JpaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
         if (primaryKeyJoinColumns == null) {
             primaryKeyJoinColumns = new ArrayList<JpaPrimaryKeyJoinColumn>();

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSqlResultSetMapping.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSqlResultSetMapping.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSqlResultSetMapping.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaSqlResultSetMapping.java
Fri Apr 28 05:13:45 2006
@@ -60,6 +60,8 @@
 
 import javax.persistence.SqlResultSetMapping;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaSqlResultSetMapping {
 
     protected String name;
@@ -92,6 +94,7 @@
         this.name = name;
     }
 
+    @TreeNodeChild(type=JpaColumnResult.class)
     public Collection<JpaColumnResult> getColumnResults() {
         if (columnResults == null) {
             columnResults = new ArrayList<JpaColumnResult>(5);
@@ -99,6 +102,7 @@
         return columnResults;
     }
 
+    @TreeNodeChild(type=JpaEntityResult.class)
     public Collection<JpaEntityResult> getEntityResults() {
         if (entityResults == null) {
             entityResults = new ArrayList<JpaEntityResult>(5);

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaTable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaTable.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaTable.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaTable.java
Fri Apr 28 05:13:45 2006
@@ -60,6 +60,8 @@
 
 import javax.persistence.Table;
 
+import org.apache.cayenne.util.TreeNodeChild;
+
 public class JpaTable {
 
     protected String name;
@@ -109,6 +111,7 @@
         this.schema = schema;
     }
 
+    @TreeNodeChild(type = JpaUniqueConstraint.class)
     public Collection<JpaUniqueConstraint> getUniqueConstraints() {
         if (uniqueConstraints == null) {
             uniqueConstraints = new ArrayList<JpaUniqueConstraint>(2);

Modified: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversalUtil.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversalUtil.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversalUtil.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TraversalUtil.java
Fri Apr 28 05:13:45 2006
@@ -55,17 +55,60 @@
  */
 package org.apache.cayenne.util;
 
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 
+import org.apache.cayenne.jpa.JpaProviderException;
 import org.objectstyle.cayenne.project.ProjectPath;
 
 /**
- * Defines tree traversal utility methods.
+ * Defines tree traversal utility methods. Object tree sematics is determined using
+ * {@link org.apache.cayenne.util.TreeNodeChild} property getter annotation.
  * 
  * @author Andrus Adamchik
  */
 public class TraversalUtil {
 
+    static final ClassTraversalDescriptor noopDescriptor = new ClassTraversalDescriptor();
+    static final Map<String, ClassTraversalDescriptor> descriptors = new HashMap<String,
ClassTraversalDescriptor>();
+
+    private static Method[] traversableGetters(Class nodeType) {
+
+        Collection<Method> getters = null;
+
+        Method[] methods = nodeType.getMethods();
+        for (int i = 0; i < methods.length; i++) {
+            if (methods[i].isAnnotationPresent(TreeNodeChild.class)
+                    && !Void.TYPE.equals(methods[i].getReturnType())) {
+
+                if (getters == null) {
+                    getters = new ArrayList<Method>(5);
+                }
+
+                getters.add(methods[i]);
+            }
+        }
+
+        return getters != null ? getters.toArray(new Method[getters.size()]) : null;
+    }
+
+    static synchronized ClassTraversalDescriptor getDescriptor(Class nodeType) {
+        String typeName = nodeType.getName();
+        ClassTraversalDescriptor descriptor = descriptors.get(typeName);
+        if (descriptor == null) {
+            Method[] getters = traversableGetters(nodeType);
+            descriptor = getters != null
+                    ? new ClassTraversalDescriptor(getters)
+                    : noopDescriptor;
+            descriptors.put(typeName, descriptor);
+        }
+
+        return descriptor;
+    }
+
     /**
      * Performs tree traversal with a given visitor. Any tree node object that implements
      * {@link TraversableTreeNode} will have its children traversed as well.
@@ -85,41 +128,83 @@
 
         if (visitor.onStartNode(path)) {
 
-            if (node instanceof TraversableTreeNode) {
+            ClassTraversalDescriptor descriptor = getDescriptor(node.getClass());
+            Class[] childTypes = descriptor.getTraversableChildTypes();
+            if (childTypes != null && childTypes.length > 0) {
+                for (int i = 0; i < childTypes.length; i++) {
+
+                    HierarchicalTreeVisitor childVisitor = visitor.childVisitor(
+                            path,
+                            childTypes[i]);
+                    if (childVisitor != null) {
+                        Object child = descriptor.getTraversableChild(node, i);
 
-                TraversableTreeNode treeNode = (TraversableTreeNode) node;
-
-                Class[] childTypes = treeNode.getTraversableChildTypes();
-                if (childTypes != null && childTypes.length > 0) {
-                    for (int i = 0; i < childTypes.length; i++) {
-
-                        HierarchicalTreeVisitor childVisitor = visitor.childVisitor(
-                                path,
-                                childTypes[i]);
-                        if (childVisitor != null) {
-                            Object child = treeNode.getTraversableChild(i);
-
-                            if (child == null) {
-                                continue;
-                            }
-                            else if (child instanceof Collection) {
-                                Collection children = (Collection) child;
+                        if (child == null) {
+                            continue;
+                        }
+                        else if (child instanceof Collection) {
+                            Collection children = (Collection) child;
 
-                                if (children != null && !children.isEmpty()) {
-                                    for (Object collectionChild : children) {
-                                        traverse(collectionChild, childVisitor, path);
-                                    }
+                            if (children != null && !children.isEmpty()) {
+                                for (Object collectionChild : children) {
+                                    traverse(collectionChild, childVisitor, path);
                                 }
                             }
-                            else {
-                                traverse(child, childVisitor, path);
-                            }
+                        }
+                        else {
+                            traverse(child, childVisitor, path);
                         }
                     }
                 }
             }
 
             visitor.onFinishNode(path);
+        }
+    }
+
+    static class ClassTraversalDescriptor {
+
+        Class[] traversableChildTypes;
+        Method[] traversableGetters;
+
+        ClassTraversalDescriptor() {
+
+        }
+
+        ClassTraversalDescriptor(Method[] traversableChildGetters) {
+            this.traversableGetters = traversableChildGetters;
+            this.traversableChildTypes = new Class[traversableChildGetters.length];
+            for (int i = 0; i < traversableChildGetters.length; i++) {
+                Class type = traversableChildGetters[i].getReturnType();
+                if (Collection.class.isAssignableFrom(type)) {
+                    type = traversableChildGetters[i]
+                            .getAnnotation(TreeNodeChild.class)
+                            .type();
+
+                    // TODO: andrus, 4/27/2006 - determine type from collection generics
+                    // metadata.
+                    if (void.class.equals(type)) {
+                        throw new JpaProviderException("No type for collection defined: "
+                                + traversableChildGetters[i].getName());
+                    }
+                }
+
+                traversableChildTypes[i] = type;
+            }
+        }
+
+        Class[] getTraversableChildTypes() {
+            return traversableChildTypes;
+        }
+
+        Object getTraversableChild(Object object, int childIndex) {
+
+            try {
+                return traversableGetters[childIndex].invoke(object, (Object[]) null);
+            }
+            catch (Exception e) {
+                throw new JpaProviderException("Error reading traversible property", e);
+            }
         }
     }
 }

Added: incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TreeNodeChild.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TreeNodeChild.java?rev=397877&view=auto
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TreeNodeChild.java
(added)
+++ incubator/cayenne/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/util/TreeNodeChild.java
Fri Apr 28 05:13:45 2006
@@ -0,0 +1,75 @@
+/* ====================================================================
+ * 
+ * The ObjectStyle Group Software License, version 1.1
+ * ObjectStyle Group - http://objectstyle.org/
+ * 
+ * Copyright (c) 2002-2005, Andrei (Andrus) Adamchik and individual authors
+ * of the software. All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 
+ * 3. The end-user documentation included with the redistribution, if any,
+ *    must include the following acknowlegement:
+ *    "This product includes software developed by independent contributors
+ *    and hosted on ObjectStyle Group web site (http://objectstyle.org/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ * 
+ * 4. The names "ObjectStyle Group" and "Cayenne" must not be used to endorse
+ *    or promote products derived from this software without prior written
+ *    permission. For written permission, email
+ *    "andrus at objectstyle dot org".
+ * 
+ * 5. Products derived from this software may not be called "ObjectStyle"
+ *    or "Cayenne", nor may "ObjectStyle" or "Cayenne" appear in their
+ *    names without prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ * 
+ * This software consists of voluntary contributions made by many
+ * individuals and hosted on ObjectStyle Group web site.  For more
+ * information on the ObjectStyle Group, please see
+ * <http://objectstyle.org/>.
+ */
+package org.apache.cayenne.util;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotates a public getter for the child property during the tree traversal. If an
+ * object implements {@link org.apache.cayenne.util.TraversableTreeNode}, this annotation
+ * is ignored.
+ * 
+ * @author Andrus Adamchik
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface TreeNodeChild {
+
+    Class type() default void.class;
+}

Modified: incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java?rev=397877&r1=397876&r2=397877&view=diff
==============================================================================
--- incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
(original)
+++ incubator/cayenne/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/bridge/DataMapMappingAssertion.java
Fri Apr 28 05:13:45 2006
@@ -55,20 +55,30 @@
  */
 package org.apache.cayenne.jpa.bridge;
 
+import java.util.Iterator;
+
 import junit.framework.Assert;
 
+import org.apache.cayenne.jpa.map.JpaEntity;
+import org.apache.cayenne.jpa.map.JpaNamedNativeQuery;
+import org.apache.cayenne.jpa.map.JpaNamedQuery;
+import org.apache.cayenne.jpa.map.JpaSecondaryTable;
+import org.apache.cayenne.jpa.map.JpaTable;
+import org.apache.cayenne.jpa.map.JpaUniqueConstraint;
 import org.objectstyle.cayenne.map.DataMap;
+import org.objectstyle.cayenne.map.DbEntity;
+import org.objectstyle.cayenne.map.ObjEntity;
 
 public class DataMapMappingAssertion extends Assert {
 
     public void testDataMap(DataMap dataMap) {
         assertNotNull(dataMap);
         assertEquals("n1", dataMap.getName());
-        
+
         assertNotNull(dataMap.getObjEntities());
         assertEquals(5, dataMap.getObjEntities().size());
-        // Iterator<ObjEntity> entityIt = dataMap.getObjEntities().iterator();
-        // assertEntity1(entityIt.next());
+        Iterator<ObjEntity> entityIt = dataMap.getObjEntities().iterator();
+        assertEntity1(entityIt.next());
         // assertEntity2(entityIt.next());
         // assertEntity3(entityIt.next());
         // assertEntity4(entityIt.next());
@@ -113,11 +123,26 @@
 
         // TODO: NOT SUPPORTED YET - Sequencegenerators (In fact we can support that
         // already...)
-//        assertEquals(2, entityMap.getSequenceGenerators().size());
-//        assertSequenceGenerator1(entityMap.getSequenceGenerators().iterator().next());
+        // assertEquals(2, entityMap.getSequenceGenerators().size());
+        // assertSequenceGenerator1(entityMap.getSequenceGenerators().iterator().next());
 
         // TODO: NOT SUPPORTED YET - Table Generators (we can support that already)
         // assertEquals(2, entityMap.getTableGenerators().size());
         // assertTableGenerator(entityMap.getTableGenerators().iterator().next());
+    }
+
+    protected void assertEntity1(ObjEntity entity1) {
+        assertNotNull(entity1);
+        assertEquals("MockEntity1", entity1.getName());
+        assertEquals("org.apache.cayenne.jpa.entity.MockEntity1", entity1.getClassName());
+
+        assertTable(entity1.getDbEntity());
+    }
+
+    protected void assertTable(DbEntity table) {
+        assertNotNull(table);
+        assertEquals("mock_persistent_1", table.getName());
+        assertEquals("catalog1", table.getCatalog());
+        assertEquals("schema1", table.getSchema());
     }
 }



Mime
View raw message