From 1d45cddef3307a39523f1fc110ff2bde9bdea8f3 Mon Sep 17 00:00:00 2001 From: Michael Hunger Date: Fri, 23 Dec 2011 01:13:07 +0100 Subject: [PATCH] DATAGRAPH-162 handle potential cascaded persistent entity types of a Neo4jPersistentProperty correctly --- .../mapping/Neo4JPersistentPropertyImpl.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/Neo4JPersistentPropertyImpl.java b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/Neo4JPersistentPropertyImpl.java index b09413e8a..e588933be 100644 --- a/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/Neo4JPersistentPropertyImpl.java +++ b/spring-data-neo4j/src/main/java/org/springframework/data/neo4j/support/mapping/Neo4JPersistentPropertyImpl.java @@ -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 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> getPersistentEntityType() { + final Iterable> result = super.getPersistentEntityType(); + for (Iterator> 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; + } }