I was wondering if it is possible to query relationships and nodes so that the nodes have the relationships without the other node being given to the spring context.
My query looks like this:
MATCH (p:ProcessStep)
WHERE id(p) = 87
OPTIONAL MATCH (:ProcessStep)-[r]->()
OPTIONAL MATCH (o:ProcessStep)-[:PREVIOUS*]->(p)
RETURN p, o, r
It returns a chain of nodes pointing towards a given id. Every node has multiple other relationships which I want to get as a results as well, but spring only maps the :PREVIOUS relationship (previousProcessStep) on the nodes all others are null.
Just to get it right, what you would like to do is get Spring to map all of your Relationships in your NodeEntity Class (ProcessStep), right?
If your Relationships have different types, I don't think you can get that for free by just using the repository.
Also, do you want to access the ProcessStep object or the relationship object (Previous)? From your code, I assume you haven't mapped your Relationship into a NodeEntity object. If all of the nodes you want to return have the same relationship type you can simply declare a List and map your relationship to it.
If you have different relationship types, a way of achieving what you want is auto-wiring the neo4j driver and fetching the result from it. That way you have complete freedom to query what you want and manipulate the results yourself instead of relying on Spring's Entity mapper.
Just to get it right, what you would like to do is get Spring to map all of your Relationships in your NodeEntity Class (ProcessStep), right?
Correct.
If your Relationships have different types, I don't think you can get that for free by just using the repository.
I solved the problem by querying each object individually again.
Also, do you want to access the ProcessStep object or the relationship object (Previous)? From your code, I assume you haven't mapped your Relationship into a NodeEntity object. If all of the nodes you want to return have the same relationship type you can simply declare a List and map your relationship to it.
I only need access to the object.
If you have different relationship types, a way of achieving what you want is auto-wiring the neo4j driver and fetching the result from it. That way you have complete freedom to query what you want and manipulate the results yourself instead of relying on Spring's Entity mapper.