In neo4j kann nicht mehr als eine Beziehung zwischen Knoten hinzugefügt werden

Ich versuche mit Neo4J ein soziales Netzwerk zu modellieren. Dies erfordert, dass ein Benutzer mehrere Beziehungen zu einem anderen Benutzer haben kann. Wenn ich versuche, diese Beziehungen beizubehalten, wird nur eine gespeichert. Dies ist zum Beispiel die Testeinheit, die ich mache:

@Test
public void testFindConnections() {

    Id id1 = new Id();
    id1.setId("first-node");

    Id id2 = new Id();
    id2.setId("second-node");
    idService.save(id2);

    id1.connectedTo(id2, "first-rel");
    id1.connectedTo(id2, "second-rel");

    idService.save(id1);

    for (Id im : idService.findAll()) {
        System.out.println("-" + im.getId());
        if (im.getConnections().size() > 0) {
            for (ConnectionType ite : im.getConnections()) {
                System.out
                        .println("--" + ite.getId() + " " + ite.getType());
            }
        }
    }
}

Dies sollte Folgendes ausgeben:

-first-node
--0 first-rel
--1 second-rel
-second-node
--0 first-rel
--1 second-rel

Es gibt jedoch Folgendes aus:

-first-node
--0 first-rel
-second-node
--0 first-rel

Dies ist meine Knoteneinheit:

@NodeEntity
public class Id {

    @GraphId
    Long nodeId;
    @Indexed(unique = false)
    String id;

    @Fetch
    @RelatedToVia(direction=Direction.BOTH)
    Collection<ConnectionType> connections = new HashSet<ConnectionType>();
}

Und meine Beziehungseinheit:

@RelationshipEntity(type = "CONNECTED_TO")
public class ConnectionType {

    @GraphId Long id;
    @StartNode Id fromUser;
    @EndNode Id toUser;

    String type;
}

Woran könnte das liegen? Gibt es eine andere Möglichkeit, mehrere Beziehungen zwischen Knoten zu modellieren?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage