*/
protected void removeMissingRelationshipsInStoreAndKeepOnlyNewRelationShipsInSet( Node node,
Set<Node> targetNodes,
Class<?> targetType ) {
Neo4jMappingContext mappingContext = template.getInfrastructure().getMappingContext();
for ( Relationship relationship : node.getRelationships( type, direction ) ) {
Node otherNode = relationship.getOtherNode(node);
if ( !targetNodes.remove(otherNode) ) {
if ( targetType != null ) {
Object actualTargetType = determineEndNodeType(otherNode);
try {
Neo4jPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(actualTargetType);
if (! targetType.isAssignableFrom(persistentEntity.getType())) continue;
} catch (Exception e) {
throw new IllegalStateException(format("Could not read type '%s' - type does not exist", actualTargetType), e);
}
}