Skip to content
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

After Update to Spring Boot 2.4.1 , not able to fetch parent Object using custom query [DATAGRAPH-1473] #2034

spring-projects-issues opened this issue Dec 30, 2020 · 5 comments
in: core type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Dec 30, 2020

wolfy027 opened DATAGRAPH-1473 and commented

Custom Query used in AnimalRepository > @Query


MATCH path=(n:Animal {uuid: $id})-[:`PARENT`*0..]->() RETURN path

Spring Boot Version before update : 2.3.4

Spring Boot Version before update : 2.4.1


Domain reference:


@JsonSerialize(as = Animal.class)
@JsonDeserialize(as = Animal.class)
public class Animal{
@GeneratedValue(generatorClass = GeneratedValue.UUIDGenerator.class)
private UUID uuid;
@Relationship(type = "PARENT", direction = Relationship.Direction.OUTGOING)
private Animal parent;



All the other properties are parsed except for parent which is null for any animal.



Affects: 6.0.2 (2020.0.2)

Copy link

@robin850 robin850 commented Jan 6, 2021


I had a similar issue. Basically, with something like this:

class Technology {
    private String name;
class Application {
    private List<Technology> technologies;

Then, on the repository side, trying to fetch an application and its technologies would return the application but with an empty set of technologies:

@Query("MATCH (a:Application)" +
        " OPTIONAL MATCH (a)-[r:RELIES_ON]->(t:Technology)" +
        " RETURN a, r, t")
List<Application> fooBar(String name);

It can be fixed this by using COLLECT(r), COLLECT(t). Fetching and collecting the relationship part (even though it is not mapped to an @RelationshipProperties class) is important ; the list is empty with only COLLECT(t) even though that's what matters here.

Also, it looks like the behavior changed even for 1:1 mapping in this version (e.g. this ticket on SO).

I don't know if it is expected or not but maybe the documentation could be improve at this level as there seems to be behavioral differences between the previous SDN/OGM and SDN 6 regarding relationships.

Copy link

@meistermeier meistermeier commented Jan 7, 2021

You are right in both cases @robin850: You need to make use of the COLLECT function in order to provide a single result in contrast to a cartesian product. And yes, this is for sure some documentation missing on this bit. There is already an issue for this, so I will close this issue as it now is only a duplicate of #2032

Copy link

@wolfy027 wolfy027 commented Jan 18, 2021

Thanks, the issue got solved with the updated query suggested by @robin850

Copy link

@wolfy027 wolfy027 commented Jan 18, 2021

MATCH (c:Animal {uuid: $id}) OPTIONAL MATCH (c)-[r:PARENT]->(p:Animal) RETURN c,collect(r),collect(p)

This gives me response with attributes of current node and it's parent's nodes, but it skips the grand-parent's attributes.

MATCH (c:Animal {uuid: $id}) OPTIONAL MATCH (c)-[r:PARENT*]->(p:Animal) RETURN c,collect(r),collect(p) does'nt work

What should be the suggested change? @robin850 @meistermeier

Copy link

@meistermeier meistermeier commented Jan 19, 2021

Before I open up a new issue on this one: Could you set the SDN version to 6.0.3 in your pom?
There were several fixes targeting inheritance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: core type: bug
None yet

No branches or pull requests

4 participants