openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1420324 - in /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta: AnnotationProcessor6.java SourceAnnotationHandler.java
Date Tue, 11 Dec 2012 18:23:57 GMT
Author: ppoddar
Date: Tue Dec 11 18:23:50 2012
New Revision: 1420324

URL: http://svn.apache.org/viewvc?rev=1420324&view=rev
Log:
OPENJPA-2305: Change inheritance hierarchy of generated canonical metamodel

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java?rev=1420324&r1=1420323&r2=1420324&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/AnnotationProcessor6.java
Tue Dec 11 18:23:50 2012
@@ -103,7 +103,6 @@ import org.apache.openjpa.persistence.ut
                     "openjpa.header",
                     "openjpa.metamodel"
                   })
-@SupportedSourceVersion(RELEASE_6)
 
 public class AnnotationProcessor6 extends AbstractProcessor {
     private SourceAnnotationHandler handler;
@@ -206,6 +205,7 @@ public class AnnotationProcessor6 extend
      */
     @Override
     public boolean process(Set<? extends TypeElement> annos, RoundEnvironment roundEnv)
{
+        System.err.println("Activated " + this.getClass().getName());
         if (active && !roundEnv.processingOver()) {
             Set<? extends Element> elements = roundEnv.getRootElements();
             for (Element e : elements) {
@@ -226,25 +226,24 @@ public class AnnotationProcessor6 extend
     	if (!handler.isAnnotatedAsEntity(e)) {
             return false;
         }
-
+    	
         Elements eUtils = processingEnv.getElementUtils();
         String originalClass = eUtils.getBinaryName((TypeElement) e).toString();
         String originalSimpleClass = e.getSimpleName().toString();
         String metaClass = factory.getMetaModelClassName(originalClass);
-
+        
         SourceCode source = new SourceCode(metaClass);
         comment(source);
         annotate(source, originalClass);
-        TypeElement supCls = handler.getPersistentSupertype(e);
-        if (supCls != null) {
-            String superName = factory.getMetaModelClassName(supCls.toString());
-            source.getTopLevelClass().setSuper(superName);
-        }
         try {
             PrintWriter writer = createSourceFile(originalClass, metaClass, e);
             SourceCode.Class modelClass = source.getTopLevelClass();
-            Set<? extends Element> members = handler.getPersistentMembers(e);
-            
+            Set<Element> members = handler.getPersistentMembers(e);
+            TypeElement supCls = handler.getPersistentSupertype(e);
+            while (supCls != null) {
+            	members.addAll(handler.getPersistentMembers(supCls));
+                supCls = handler.getPersistentSupertype(supCls);
+            }
             for (Element m : members) {
                 boolean isPersistentCollection = m.getAnnotation(PersistentCollection.class)
!= null; 
                 

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java?rev=1420324&r1=1420323&r2=1420324&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/meta/SourceAnnotationHandler.java
Tue Dec 11 18:23:50 2012
@@ -41,6 +41,7 @@ import javax.lang.model.element.TypeElem
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.ArrayType;
 import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.NoType;
 import javax.lang.model.type.PrimitiveType;
 import javax.lang.model.type.TypeKind;
 import javax.lang.model.type.TypeMirror;
@@ -651,11 +652,11 @@ public class SourceAnnotationHandler 
     }
 
     public TypeElement getPersistentSupertype(TypeElement cls) {
+    	if (cls == null) return null;
         TypeMirror sup = cls.getSuperclass();
-        if (sup == null || isRootObject(sup))
+        if (sup == null || sup.getKind() == TypeKind.NONE ||  isRootObject(sup))
             return null;
-        TypeElement supe =
-            (TypeElement) processingEnv.getTypeUtils().asElement(sup);
+        TypeElement supe = (TypeElement) processingEnv.getTypeUtils().asElement(sup);
         if (isAnnotatedAsEntity(supe)) 
             return supe;
         return getPersistentSupertype(supe);



Mime
View raw message