DATAGRAPH-162 handle potential cascaded persistent entity types of a Neo4jPersistentProperty correctly

This commit is contained in:
Michael Hunger
2011-12-23 01:13:07 +01:00
parent 9ff99064df
commit 1d45cddef3

View File

@@ -34,6 +34,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
/**
@@ -260,14 +261,15 @@ class Neo4jPersistentPropertyImpl extends AbstractPersistentProperty<Neo4jPersis
}
@Override
public boolean isEntity() {
return super.isEntity() && (hasRelationshipEntityType() || hasNodeEntityType());
return super.isEntity() && (isRelationshipEntity(getType()) || isNodeEntity(getType()));
}
private boolean hasRelationshipEntityType() {
return getType().isAnnotationPresent(RelationshipEntity.class);
private boolean isRelationshipEntity(final Class<?> type) {
return type.isAnnotationPresent(RelationshipEntity.class);
}
private boolean hasNodeEntityType() {
return getType().isAnnotationPresent(NodeEntity.class);
private boolean isNodeEntity(Class<?> type) {
return type.isAnnotationPresent(NodeEntity.class);
}
public String getIndexKey() {
@@ -300,4 +302,17 @@ class Neo4jPersistentPropertyImpl extends AbstractPersistentProperty<Neo4jPersis
public boolean isTransient() {
return false;
}
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityType() {
final Iterable<? extends TypeInformation<?>> result = super.getPersistentEntityType();
for (Iterator<? extends TypeInformation<?>> it = result.iterator(); it.hasNext(); ) {
final TypeInformation<?> typeInformation = it.next();
final Class type = typeInformation.getType();
if (isNodeEntity(type) || isRelationshipEntity(type)) continue;
System.out.println("removing "+getName()+" "+type+" "+typeInformation.getActualType().getType());
it.remove();
}
return result;
}
}