Its all about how you define the domain model. By default related entities will be fetched lazily. If you want eager fetching you need to specify that with an @Fetch annotation.
See http://docs.spring.io/spring-data/data-neo4j/docs/3.2.1.RELEASE/reference/html/# <http://docs.spring.io/spring-data/data-neo4j/docs/3.2.1.RELEASE/reference/html/#> Accessing Relationship Entities Clark Richey [email protected] > On Jan 27, 2015, at 7:00 PM, BtySgtMajor <[email protected]> wrote: > > I haven't seen too much discussion on this, so I'm hoping for some > clarification/insight as to this topic. If I've missed something, I > apologize and would appreciate any pointers to any articles I missed. > > Let's say I have a Survey entity, and within it are a series of > SurveyQuestion entities in a 1-to-many relationship. Now let's say that > within the Survey entity I want to use @Query on a property to grab an > ordered list of related SurveyQuestion objects. > > Now, I'm fairly certain that SDN has no way of remembering my insertion order > into the graph (nor should it, really), so I have a property on the Survey > entity that denotes the order. So, I can use a Cypher query from within > @Query to get an ordered list of SurveyQuestion entities and return them as > an Iterable or List, for example. > > E.g. MATCH (s:Survey)-[:SURVEY_QUESTION]->(q:SurveyQuestion) WHERE id(s) = > {self} RETURN q ORDER BY q.position > > If I do that, though, I'm noticing that the objects that are returned are NOT > hydrated, i.e. I have to "fetch" each one as I use them. Is there an easy > way to hydrate them all at once? (I can't simply call fetch() on the > property.) > > Or, better yet, is there a best practice or preferred way of accomplishing > what I'm after without breaking the bank in terms of overhead? > > If I'm way off on anything here, I'd love to know as I get deeper still into > SDN. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
