openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r765846 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Date Fri, 17 Apr 2009 04:26:11 GMT
Author: faywang
Date: Fri Apr 17 04:26:10 2009
New Revision: 765846

URL: http://svn.apache.org/viewvc?rev=765846&view=rev
Log:
OPENJPA-1038: detect circular dependencies among embeddables 
and issue proper error message to avoid stack overflow

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?rev=765846&r1=765845&r2=765846&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Fri Apr 17 04:26:10 2009
@@ -1673,8 +1673,7 @@
 
         // are we the target of an embedded value?
         if (embed) {
-            if (_owner.getFieldMetaData().getDefiningMetaData().
-                getDescribedType().isAssignableFrom(_type))
+            if (recursiveEmbed(_owner))
                 throw new MetaDataException(_loc.get("recurse-embed", _owner));
 
             // copy info from the "real" metadata for this type
@@ -1765,6 +1764,17 @@
         }
     }
 
+    private boolean recursiveEmbed(ValueMetaData owner) {
+        ClassMetaData cm = owner.getFieldMetaData().getDefiningMetaData(); 
+        if (cm.getDescribedType().isAssignableFrom(_type))
+            return true;
+        ValueMetaData owner1 = cm.getEmbeddingMetaData();
+        if (owner1 == null)
+            return false;
+        else 
+            return recursiveEmbed(owner1);
+    }
+    
     /**
      * Validate resolved metadata.
      */



Mime
View raw message