cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Does an @Relationship collection need to be labelled?

More specifically, can my node class have a collection of @RelationshipEntity to represent any of several @RelationshipEntity sub-classes? Do I have to put multiple labels on the relationship or can I just leave off a type = on the node's collection object?

I found this exchange on SO, but it's not quite the same problem.

For example, if I had Persons who were participating in groups, either as regular members or as leaders and I want to keep track of how many groups they are participating in without having to sum int numGroups = subGroup1.size() + subGroup2.size() ... do I need to invent a top-level relationship name for the Participation abstract class?

public abstract class Participation {

    Person startNode;
    Group endNode;
}
@RelationshipEntity
public class OrganizationParticipation {

     @StartNode
     Person startNode;
     @EndNode (type = 'MEMBER_OF')
     SubGroup1 endNode;
}
@RelationshipEntity
public class InstitutionParticipation {

     @StartNode
     Person startNode;
     @EndNode (type = 'LEADER_OF')
     SubGroup2 endNode;
}
@NodeEntity
public class Person {

     @Relationship 
     private Set<Participation> groupParticipation;
}
Person p = new Person();

int numGroupsRegardlessOfRoleOrGroupType = p.getGroupParticipation.size();

0 REPLIES 0