Announcement Announcement Module
Collapse
No announcement yet.
@Query and returning fetched relationships. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Query and returning fetched relationships.

    I don't recall if this was in the documentation. But if I want to write a query that retrieves a Node and also fetches related Nodes and I want the repo to return the main Node with their set of related nodes populated. I don't want to put @Fetch on Set<User> friends property of User, as there are many use cases where I need the User without their friends.

    Would it be something like (method name is exaggerated for demo purposes)

    @Query("start user=node({0}) " +
    "match (user)-[:FRIEND]-(friends) " +
    "return user, friends ")
    public User findUserWithAllTheirFriendsFetchedIntoTheSetOfFrie ndsInUser(Long nodeId);


    Thanks

    Mark

  • #2
    Sorry have to bump this, the answer will have a profound affect on my apps design/architecture/layout.

    Basically, my single page app might be making 7 Web Requests to get each part of the page to display all the Node based on 7 different relationships, and I wanted to know if Cypher has the equivalent of JPA's fetch in a query like

    SELECT u FROM User u JOIN FETCH u.friends f JOIN FETCH f.friends

    Thanks

    Mark

    Comment

    Working...
    X