mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
#246 fixed unknownAsEmbeddable handling
This commit is contained in:
parent
3447acadaa
commit
79c5b66c4c
@ -54,13 +54,13 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-envers</artifactId>
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -61,7 +61,7 @@ public class TypeExtractor extends AbstractTypeVisitor6<TypeElement, Void> {
|
||||
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<TypeElement, Void> {
|
||||
}
|
||||
}
|
||||
|
||||
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<TypeElement, Void> {
|
||||
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
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
@ -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{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user