openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r811211 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
Date Fri, 04 Sep 2009 03:20:20 GMT
Author: faywang
Date: Fri Sep  4 03:20:19 2009
New Revision: 811211

URL: http://svn.apache.org/viewvc?rev=811211&view=rev
Log:
OPENJPA-1286: Relationships in mapped superclass must be unidirectional

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

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java?rev=811211&r1=811210&r2=811211&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
Fri Sep  4 03:20:19 2009
@@ -48,6 +48,7 @@
 import org.apache.commons.collections.comparators.ComparatorChain;
 import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.conf.Specification;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
 import org.apache.openjpa.kernel.StoreContext;
 import org.apache.openjpa.lib.conf.Configurations;
@@ -858,6 +859,19 @@
             if (field.getMappedBy() != null)
                 throw new MetaDataException(_loc.get("circ-mapped-by", this,
                     _mappedBy));
+            Specification spec = getRepository().getConfiguration().getSpecificationInstance();
+            if (spec != null) {
+                int specVersion = spec.getVersion();
+                if (specVersion >= 2) {
+                    if (field.getDeclaringMetaData().isAbstract())
+                        throw new MetaDataException(_loc.get("no-mapped-by-in-mapped-super",
field,
+                                field.getDeclaringMetaData()));
+
+                    if (this.getDeclaringMetaData().isAbstract())
+                        throw new MetaDataException(_loc.get("no-mapped-by-in-mapped-super",
this,
+                                this.getDeclaringMetaData()));
+                }            
+            }
             _mappedByMeta = field;
         }
         return _mappedByMeta;



Mime
View raw message