openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1141583 - in /openjpa/trunk/openjpa-persistence/src/main: java/org/apache/openjpa/persistence/meta/MetamodelImpl.java resources/org/apache/openjpa/persistence/meta/localizer.properties
Date Thu, 30 Jun 2011 15:52:12 GMT
Author: ppoddar
Date: Thu Jun 30 15:52:11 2011
New Revision: 1141583

URL: http://svn.apache.org/viewvc?rev=1141583&view=rev
Log:
OPENJPA-2024: Ignore non-canonical fields during metamodel assignment

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
    openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java?rev=1141583&r1=1141582&r2=1141583&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/MetamodelImpl.java
Thu Jun 30 15:52:11 2011
@@ -308,6 +308,9 @@ public class MetamodelImpl implements Me
     	for (Field mf : mfields) {
             try {
                 ParameterizedType mfType = getParameterziedType(mf);
+                if (mfType == null) {
+                	continue;
+                }
     	        Attribute<? super X, ?> f = type.getAttribute(mf.getName());
     	        Class<?> fClass = f.getJavaType();
     	       java.lang.reflect.Type[] args = mfType.getActualTypeArguments();
@@ -334,12 +337,18 @@ public class MetamodelImpl implements Me
     
     /**
      * Gets the parameterized type of the given field after validating. 
+     * 
+     * @return the field's type as a parameterized type. If the field
+     * is not parameterized type (that can happen for non-canonical 
+     * metamodel or weaving process introducing synthetic fields),
+     * returns null.
      */
     ParameterizedType getParameterziedType(Field mf) {
         java.lang.reflect.Type t = mf.getGenericType();
         if (t instanceof ParameterizedType == false) {
-            throw new IllegalStateException(_loc.get("meta-field-not-param", 
+        	repos.getLog().warn(_loc.get("meta-field-not-param", 
             mf.getDeclaringClass(), mf.getName(), toTypeName(t)).getMessage());
+        	return null;
         }
         ParameterizedType mfType = (ParameterizedType)t;
         java.lang.reflect.Type[] args = mfType.getActualTypeArguments();
@@ -367,9 +376,9 @@ public class MetamodelImpl implements Me
         java.lang.reflect.Type[] args = pType.getActualTypeArguments();
         StringBuilder tmp = new StringBuilder(pType.getRawType().toString());
         for (int i = 0; i < args.length; i++) {
-            tmp.append((i == 0) ? "<" : ",");
+            tmp.append((i == 0) ? '<' : ',');
             tmp.append(toTypeName(args[i]));
-            tmp.append((i == args.length-1) ? ">" : "");
+            if (i == args.length-1) tmp.append('>');
         }
         return tmp.toString();
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties?rev=1141583&r1=1141582&r2=1141583&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/meta/localizer.properties
Thu Jun 30 15:52:11 2011
@@ -53,7 +53,9 @@ mmg-bad-log: Log level specified in -Alo
 meta-class-no-anno: Meta class "{0}" registered for "{1}" is not annotated \
 	with "{2}" annotation.	
 meta-field-mismatch: The field "{0}" in meta class "{1}" is of type "{2}" \
-	which does not match the persistent property type "{3}".   
+	which does not match the persistent property type "{3}".  
+meta-field-not-param: Encountered field " {2} {1}" in "{0}". This field is \
+	not recognized as canonical field. Ignoring.
 type-wrong-category:"{0}" categorized as "{1}" should be a "{2}"
 mmg-asl-header: Licensed to the Apache Software Foundation (ASF) under one \
 	or more contributor license agreements.  See the NOTICE file distributed \



Mime
View raw message