#816000 : improvements to external supertype handling

This commit is contained in:
Timo Westkämper 2011-08-02 06:37:47 +00:00
parent 1140d1124e
commit a273ec7053
9 changed files with 71 additions and 11 deletions

View File

@ -406,7 +406,9 @@ public final class ExtendedTypeFactory {
if (e.getSuperclass().getKind() != TypeKind.NONE){
TypeMirror supertype = normalize(e.getSuperclass());
Type superClass = getType(supertype, deep);
if (!superClass.getFullName().startsWith("java")){
if (superClass == null) {
System.err.println("Got no type for " + supertype);
} else if (!superClass.getFullName().startsWith("java")){
superTypes = Collections.singleton(getType(supertype, deep));
}
}

View File

@ -712,6 +712,7 @@ public class Processor {
private void serialize(Serializer serializer, Collection<EntityType> models) {
Messager msg = env.getMessager();
for (EntityType model : models) {
try {
Type type = configuration.getTypeMappings().getPathType(model, model, true);

View File

@ -3,7 +3,6 @@ package com.mysema.query.domain;
import org.junit.Ignore;
import com.mysema.query.annotations.QueryEntity;
import com.mysema.query.codegen.sub.AbstractEntity;
@Ignore
public class ExternalEntityTest {

View File

@ -204,5 +204,4 @@ public class EntityType extends TypeAdapter implements Comparable<EntityType> {
return escapedPropertyNames;
}
}

View File

@ -50,9 +50,12 @@ public final class TypeResolver {
if (index > -1){
// get binding of var via model supertype
Supertype type = subtype.getSuperType();
while (!type.getType().equals(declaringType)){
type = type.getEntityType().getSuperType();
Supertype type = subtype.getSuperType();
while (!type.getEntityType().equals(declaringType)){
// if (type.getEntityType().getSuperType() == null) {
// throw new IllegalStateException("Got no supertype for " + type.getType() + ", declaring type " + declaringType);
// }
type = type.getEntityType().getSuperType();
}
return type.getType().getParameters().get(index);
}else{

View File

@ -1,5 +0,0 @@
package com.mysema.query.codegen.sub;
public class AbstractEntity<T> {
}

View File

@ -0,0 +1,8 @@
package com.mysema.query.domain;
import com.mysema.query.annotations.QueryEntity;
@QueryEntity
public class AbstractEntity<T> extends GenericEntity<Integer, T>{
}

View File

@ -0,0 +1,17 @@
package com.mysema.query.domain;
import java.io.Serializable;
public class GenericEntity<KeyType extends Serializable, T> {
private KeyType id;
public KeyType getId() {
return id;
}
public void setId(KeyType id) {
this.id = id;
}
}

View File

@ -0,0 +1,36 @@
package com.mysema.query.domain;
import static com.mysema.query.types.PathMetadataFactory.forVariable;
import com.mysema.query.types.PathMetadata;
import com.mysema.query.types.path.BeanPath;
import com.mysema.query.types.path.EntityPathBase;
import com.mysema.query.types.path.NumberPath;
/**
* QAnimal is a Querydsl query type for Animal
*/
@SuppressWarnings("unchecked")
public class QAbstractEntity extends EntityPathBase<AbstractEntity> {
private static final long serialVersionUID = 781156670;
public static final QAbstractEntity animal = new QAbstractEntity("abstractEntity");
public final NumberPath<Integer> id = createNumber("id", Integer.class);
public QAbstractEntity(String variable) {
super(AbstractEntity.class, forVariable(variable));
}
public QAbstractEntity(BeanPath<? extends AbstractEntity<?>> entity) {
super(entity.getType(), entity.getMetadata());
}
public QAbstractEntity(PathMetadata<?> metadata) {
super(AbstractEntity.class, metadata);
}
}