Announcement Announcement Module
No announcement yet.
Traversal over RelationShips Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Traversal over RelationShips

    Hello everyone

    I'm trying to figure out a way to traverse over RelationShips. In pure Neo4j-API I'd write something like:
    PHP Code:
    for(RelationShip r Traversal.description()...whatever(...)...traverse(startNode).relationships()) {

    I could not find a way in Spring Data Graph to do the same. The Traversers that are used in @GraphTraversal and findAllByTraversal() always return nodes.

    I went on and tried to implement a class RelationshipBackedRelationshipIterableWrapper that would convert a Neo4j RelationShip to an @RelationShip backed entity, so that I could use a "normal" neo4j traverser over RelationShips and convert the Iterable<RelationShip> to an Iterable<MyRelationshipEntity>.
    I could not find a way to convert a Neo4j RelationShip instance to a @RelationShip entity. graphDatabaseContext does not seem to provide an equivalence to createEntityFromState() that is used in NodeBackedNodeIterableWrapper.

    Any hints how to traverse over RelationShips?

    Best regards,

  • #2
    I'd use just the entity properties to traverse the relationships.

    for (Group group user.groups) for (User member : group.members) { if ("xx") && member.task == Task.MANAGE) doSomething(); }