Skip to content

Hydratation of object relationships using path #2473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paulux84 opened this issue Feb 4, 2022 · 4 comments
Closed

Hydratation of object relationships using path #2473

paulux84 opened this issue Feb 4, 2022 · 4 comments
Assignees
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue

Comments

@paulux84
Copy link

paulux84 commented Feb 4, 2022

Hi,
I've created a query inside the repository to return a node with its nearest nodes, but only one of the relationships was marshalled inside returning object.
The query is the following:

    @Query("MATCH p=(n:Place)-[:HAS_SERVICE]->(:Service) WHERE NOT $date IN n.lockedDates " +
            "AND NOT EXISTS((:Order{date:$date})-[:TAKES_PLACE]->(n)) " +
            "RETURN p")
    List<Place> findPlaceFreeOnDate(LocalDate date);

spring-data-neo4j version 6.2.2-GH-2470-SNAPSHOT
Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 4, 2022
@meistermeier meistermeier self-assigned this Feb 6, 2022
@meistermeier
Copy link
Collaborator

Short version: I think what you are looking for is Path return patterns.
So your return pattern should be something like: RETURN n, collect(nodes(p)), collect(relationships(p)).

Longer version:
Spring Data Neo4j works completely record/row oriented. There are some exceptions to the rule when we detect an already mapped object within the same result set (result = sum of all returned records) where we try to re-use the very same instance if possible.
What happens in your case:

class A {
    @Relationship("LINKED_TO") List<B> bs;
}

Would return with the query MATCH p=(:A)-[:LINKED_TO]->(:B) return p and let's say three Bs:

A1 | B1
A1 | B2
A1 | B3

But SDN already has hydrated A1 and would not touch the bs list. Also this would be somehow wrong because we would get very far away from the record-focused mapping approach and now manipulate objects in some "future"/later mapping runs instead of just re-using them.

Please let me know if this works for you.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 8, 2022
@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 15, 2022
@paulux84
Copy link
Author

Thanks for reply...now is clear

@meistermeier
Copy link
Collaborator

Thanks for the feedback. Good to hear that it worked out in the end.

@michael-simons michael-simons mentioned this issue Jan 4, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

3 participants