From 6fdf3a040e2fea96b0287663b58350deabfcebea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20H=C3=BCbner?= Date: Wed, 28 Nov 2012 19:59:36 +0100 Subject: [PATCH] fixed: revert most of commit b4a39e243c2961c5a00e691469fcbe6a9f3c90a7 processor will fail otherwise because @ManyToOne is not in the classpath --- .../java/com/overstock/sample/processor/JpaProcessor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/overstock/sample/processor/JpaProcessor.java b/src/main/java/com/overstock/sample/processor/JpaProcessor.java index 875c1b1..0c10fc3 100644 --- a/src/main/java/com/overstock/sample/processor/JpaProcessor.java +++ b/src/main/java/com/overstock/sample/processor/JpaProcessor.java @@ -56,6 +56,7 @@ public class JpaProcessor extends AbstractProcessor { private ElementTypePair entityType; private ElementTypePair oneToManyType; private ElementTypePair collectionType; + private ElementTypePair manyToOneType; private ExecutableElement mappedByAttribute; @@ -71,6 +72,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) { entityType = getType("javax.persistence.Entity"); oneToManyType = getType("javax.persistence.OneToMany"); collectionType = getType("java.util.Collection"); + manyToOneType = getType("javax.persistence.ManyToOne"); mappedByAttribute = getMethod(oneToManyType.element, "mappedBy"); } @@ -227,7 +229,7 @@ private AnnotationValue getMappedByValue(AnnotationMirror oneToManyAnnotation) { private Element findParentReferenceInChildType(TypeMirror parentType, Element childType) { for (Element element: childType.getEnclosedElements()) { if (element.getKind() == ElementKind.FIELD || element.getKind() == ElementKind.METHOD) { - if (element.getAnnotation(ManyToOne.class) != null + if (getAnnotation(element, manyToOneType.type) != null && typeUtils().isSameType(parentType, getPropertyType(element))) { return element; }