diff --git a/querydsl-apt/pom.xml b/querydsl-apt/pom.xml index 45540b0d5..6b32375aa 100644 --- a/querydsl-apt/pom.xml +++ b/querydsl-apt/pom.xml @@ -54,13 +54,13 @@ joda-time 1.6 test - + org.hibernate hibernate-core ${hibernate.version} test - + org.hibernate hibernate-envers diff --git a/querydsl-apt/src/main/java/com/mysema/query/apt/AbstractQuerydslProcessor.java b/querydsl-apt/src/main/java/com/mysema/query/apt/AbstractQuerydslProcessor.java index bf5d50fcc..eb8b26ee6 100644 --- a/querydsl-apt/src/main/java/com/mysema/query/apt/AbstractQuerydslProcessor.java +++ b/querydsl-apt/src/main/java/com/mysema/query/apt/AbstractQuerydslProcessor.java @@ -20,6 +20,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Deque; import java.util.HashSet; import java.util.Iterator; diff --git a/querydsl-apt/src/main/java/com/mysema/query/apt/TypeExtractor.java b/querydsl-apt/src/main/java/com/mysema/query/apt/TypeExtractor.java index 6e9ead74f..6a36a5d3f 100644 --- a/querydsl-apt/src/main/java/com/mysema/query/apt/TypeExtractor.java +++ b/querydsl-apt/src/main/java/com/mysema/query/apt/TypeExtractor.java @@ -61,7 +61,7 @@ public class TypeExtractor extends AbstractTypeVisitor6 { switch (typeElement.getKind()) { case ENUM: return skipEnum ? null : typeElement; case CLASS: return typeElement; - case INTERFACE: return visit(t.getTypeArguments().get(t.getTypeArguments().size()-1)); + case INTERFACE: return visitInterface(t); default: throw new IllegalArgumentException("Illegal type " + typeElement); } } else { @@ -69,6 +69,19 @@ public class TypeExtractor extends AbstractTypeVisitor6 { } } + private TypeElement visitInterface(DeclaredType t) { + if (t.getTypeArguments().isEmpty()) { + return (TypeElement)t.asElement(); + } else { + int count = t.getTypeArguments().size(); + if (t.asElement().toString().startsWith("java.util")) { + return t.getTypeArguments().get(count - 1).accept(this, null); + } else { + return (TypeElement)t.asElement(); + } + } + } + @Override public TypeElement visitError(ErrorType t, Void p) { return visitDeclared(t, p); @@ -78,14 +91,23 @@ public class TypeExtractor extends AbstractTypeVisitor6 { public TypeElement visitTypeVariable(TypeVariable t, Void p) { if (t.getUpperBound() != null) { return visit(t.getUpperBound()); - } else { + } else if (t.getLowerBound() != null) { return visit(t.getLowerBound()); + } else { + return null; } } @Override public TypeElement visitWildcard(WildcardType t, Void p) { - return visit(t.getExtendsBound()); + if (t.getExtendsBound() != null) { + return visit(t.getExtendsBound()); + } else if (t.getSuperBound() != null) { + return visit(t.getSuperBound()); + } else { + return null; + } + } @Override diff --git a/querydsl-apt/src/test/java/com/mysema/query/apt/QuerydslAnnotationProcessorTest.java b/querydsl-apt/src/test/java/com/mysema/query/apt/QuerydslAnnotationProcessorTest.java index 86f0ed757..4f10c9f86 100644 --- a/querydsl-apt/src/test/java/com/mysema/query/apt/QuerydslAnnotationProcessorTest.java +++ b/querydsl-apt/src/test/java/com/mysema/query/apt/QuerydslAnnotationProcessorTest.java @@ -37,61 +37,61 @@ public class QuerydslAnnotationProcessorTest extends AbstractProcessorTest{ } @Test - public void ProcessMonitoredCompany() throws IOException{ + public void Process_MonitoredCompany() throws IOException{ String path = new File(PACKAGE_PATH, "MonitoredCompany.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"MonitoredCompany"); } @Test - public void ProcessInheritance3() throws IOException{ + public void Process_Inheritance3() throws IOException{ String path = new File("src/test/java/com/mysema/query/inheritance/Inheritance3Test.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"inheritance3"); } @Test - public void ProcessInheritance8() throws IOException{ + public void Process_Inheritance8() throws IOException{ String path = new File("src/test/java/com/mysema/query/inheritance/Inheritance8Test.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"inheritance8"); } @Test - public void ProcessQueryEmbedded3() throws IOException{ + public void Process_QueryEmbedded3() throws IOException{ String path = new File("src/test/java/com/mysema/query/domain/QueryEmbedded3Test.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"embedded3"); } @Test - public void ProcessQueryEmbedded4() throws IOException{ + public void Process_QueryEmbedded4() throws IOException{ String path = new File("src/test/java/com/mysema/query/domain/QueryEmbedded4Test.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"embedded3"); } @Test - public void ProcessDelegate() throws IOException{ + public void Process_Delegate() throws IOException{ String path = new File("src/test/java/com/mysema/query/domain/DelegateTest.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"delegate"); } @Test - public void ProcessAbstractClasses() throws IOException{ + public void Process_AbstractClasses() throws IOException{ String path = new File("src/test/java/com/mysema/query/domain/AbstractClassesTest.java").getPath(); process(JPAAnnotationProcessor.class, Collections.singletonList(path),"abstractClasses"); } @Test - public void ProcessGenericSignature() throws IOException{ + public void Process_GenericSignature() throws IOException{ String path = new File("src/test/java/com/mysema/query/domain/GenericSignatureTest.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"genericSignature"); } @Test - public void ProcessAbstractProperties2Test() throws IOException { + public void Process_AbstractProperties2Test() throws IOException { String path = new File("src/test/java/com/mysema/query/domain/AbstractProperties2Test.java").getPath(); process(QuerydslAnnotationProcessor.class, Collections.singletonList(path),"abstractProperties"); } @Test - public void EntityInheritanceTest() throws IOException { + public void Entity_InheritanceTest() throws IOException { String path = new File("src/test/java/com/mysema/query/domain/EntityInheritanceTest.java").getPath(); process(JPAAnnotationProcessor.class, Collections.singletonList(path),"entityInheritance"); } diff --git a/querydsl-apt/src/test/java/com/mysema/query/apt/UnknownAsEmbeddableTest.java b/querydsl-apt/src/test/java/com/mysema/query/apt/UnknownAsEmbeddableTest.java index 00c1cd16b..8a1338f60 100644 --- a/querydsl-apt/src/test/java/com/mysema/query/apt/UnknownAsEmbeddableTest.java +++ b/querydsl-apt/src/test/java/com/mysema/query/apt/UnknownAsEmbeddableTest.java @@ -25,7 +25,7 @@ import org.junit.Test; public class UnknownAsEmbeddableTest extends AbstractProcessorTest { - private static final String packagePath = "src/test/java/com/mysema/query/domain/custom"; + private static final String packagePath = "src/test/java/com/mysema/query/domain"; @Test public void Process() throws IOException{