cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Migration to SDN 6 - issue with relationship between nodes

myshareit
Node Clone

I'm struggling to migrate from old version to SDN6. This is my test:

@Test
public void testParentDecisionGroupsForDecision() {
    User user = userDao.create("user1", "user1", "user1@test.com", null, null, 100L, null);

    Decision parentDecision = decisionDao.create("parentDecision1", "parentDecision1", null, null, user);

    DecisionGroup decisionGroup = decisionGroupDao.create("decisionGroup1", "decisionGroup1", parentDecision, OwnershipType.ANY, user);

    Decision childDecision = decisionDao.create("childDecision", "childDecision", null, decisionGroup, user);

    assertEquals(1, decisionGroupDao.findAllParentDecisionGroupsByDecisionId(childDecision.getId()).size());
}

It fails on the assertEquals statement - returns 0.

@Node
public class DecisionGroup extends BaseEntity {

    private static final String CONTAINS_DECISION_GROUP = "CONTAINS_DECISION_GROUP";
    private static final String CONTAINS = "CONTAINS";
....

    @Relationship(type = CONTAINS_DECISION_GROUP, direction = Relationship.Direction.INCOMING)
    private Set<OwnerDecision> ownerDecisions = new HashSet<>();

    @Relationship(type = CONTAINS, direction = Relationship.Direction.OUTGOING)
    private Set<Decision> childDecisions = new HashSet<>();


@Node
public class Decision extends BaseEntity {

    private static final String CONTAINS = "CONTAINS";

   ...

    @Relationship(type = CONTAINS, direction = Relationship.Direction.INCOMING)
    private Set<DecisionGroup> parentGroups = new HashSet<>();

    public Decision(String name, String description, String customId, DecisionGroup parentGroup, User author) {

        setName(name);
        this.description = description;
        setCustomId(customId);

        if (parentGroup != null) {
            getParentGroups().add(parentGroup);
            parentGroup.incrementTotalChildDecisions();
        }

        setCreateUser(author);
    }

    @Query("MATCH (dg:DecisionGroup)-[:CONTAINS]->(childD:Decision) WHERE childD.id = $decisionId RETURN dg")
    List<DecisionGroup> findAllParentDecisionGroupsByDecisionId(@Param("decisionId") Long decisionId);

For some reason there is not relationship CONTAINS between DecisionGroup and Decision nodes. What am I doing wrong and how to fix it? Thanks

1 REPLY 1

gerrit_meier
Neo4j
Neo4j

Hard to guess what happens in the DAOs. Could you add a little bit more information about the internal logic how you persist the data? (or link an example)