While moving from SDN 3
to SDN 4
and from Neo4j 2.3
to Neo4j 3.0.1
I ran into a issue with inconsistency between OEM and custom Cypher queries.
I have a following Cypher query:
@Query("MATCH ()-[r]-(cg:CriterionGroup) WHERE id(cg) = {criterionGroupId} DELETE cg, r")
void deleteCriterionGroup(@Param("criterionGroupId") Long criterionGroupId);
Right now, with SDN 4 this query doesn't work without following workaround after deleteCriterionGroup
method invocation:
session.clear();
Could you please show the correct code how to delete CriterionGroup
now in SDN 4 in order to maintain the references of related nodes consistent.
This is a schema of my data:
As you can see - CriterionGroup
connected to Decision
, Criterion
and User
nodes.
UPDATED
As suggested, I have updated my method:
@Override
public void deleteCriterionGroup(Long criterionGroupId) {
CriterionGroup criterionGroup = criterionGroupRepository.findOne(criterionGroupId);
criterionGroup.setAuthor(null);
criterionGroup.setOwner(null);
criterionGroup.setCriteria(null);
criterionGroup = criterionGroupRepository.save(criterionGroup);
criterionGroupRepository.delete(criterionGroup);
}