mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-24 21:07:26 +08:00
#30 : excluded QueryExcluded annotated classes from EntityType supertypes
This commit is contained in:
parent
d75978bb93
commit
9d94cb8fc5
@ -36,6 +36,7 @@ import com.mysema.codegen.model.TypeCategory;
|
||||
import com.mysema.codegen.model.TypeExtends;
|
||||
import com.mysema.codegen.model.TypeSuper;
|
||||
import com.mysema.codegen.model.Types;
|
||||
import com.mysema.query.annotations.QueryExclude;
|
||||
import com.mysema.query.codegen.EntityType;
|
||||
import com.mysema.query.codegen.QueryTypeFactory;
|
||||
import com.mysema.query.codegen.Supertype;
|
||||
@ -424,12 +425,18 @@ public final class ExtendedTypeFactory {
|
||||
if (e.getKind() == ElementKind.CLASS) {
|
||||
if (e.getSuperclass().getKind() != TypeKind.NONE) {
|
||||
TypeMirror supertype = normalize(e.getSuperclass());
|
||||
Type superClass = getType(supertype, deep);
|
||||
if (superClass == null) {
|
||||
System.err.println("Got no type for " + supertype);
|
||||
} else if (!superClass.getFullName().startsWith("java")) {
|
||||
superTypes = Collections.singleton(getType(supertype, deep));
|
||||
if (supertype instanceof DeclaredType
|
||||
&& ((DeclaredType)supertype).asElement().getAnnotation(QueryExclude.class) != null) {
|
||||
return Collections.emptySet();
|
||||
} else {
|
||||
Type superClass = getType(supertype, deep);
|
||||
if (superClass == null) {
|
||||
System.err.println("Got no type for " + supertype);
|
||||
} else if (!superClass.getFullName().startsWith("java")) {
|
||||
superTypes = Collections.singleton(getType(supertype, deep));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// interface
|
||||
} else {
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package com.mysema.query.domain;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mysema.query.annotations.QueryEntity;
|
||||
import com.mysema.query.annotations.QueryExclude;
|
||||
import com.mysema.query.types.path.EntityPathBase;
|
||||
|
||||
public class QueryExcludeTest {
|
||||
|
||||
@QueryExclude
|
||||
@QueryEntity
|
||||
public class Entity {
|
||||
|
||||
}
|
||||
|
||||
@QueryEntity
|
||||
public class SubEntity extends Entity {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SubEntity() {
|
||||
assertEquals(EntityPathBase.class, QQueryExcludeTest_SubEntity.class.getSuperclass());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user