Skip to content

Missing relationship with projection #2819

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
Marc-AntoineGL opened this issue Nov 9, 2023 · 9 comments
Closed

Missing relationship with projection #2819

Marc-AntoineGL opened this issue Nov 9, 2023 · 9 comments
Assignees
Labels
status: waiting-for-feedback We need additional information before we can continue

Comments

@Marc-AntoineGL
Copy link

Hello,

Spring version: 2.7.11
spring-boot-starter-data-neo4j: 2.7.11

(At the moment we stay on version 2 but will upgrade as soon as possible)

I am using repositories methods with some projections and on some cases i'm getting some empty attributes in some nodes containing relationships. I'll try to explain as clear as possible the case where i'm getting this.
(The short answer is that I'm getting the wrong collectionName inside the DefaultNeo4jEntityConverter class at the line "Value list = values.get(collectionName)", I will come back to it later)

In my project I have ParentA, ParentB and ParentC classes. They are linked by relationships like that

//ParentA class
@Relationship(type = "HasBs", direction = Direction.OUTGOING)
private ParentB parentB; 
//ParentB class
@Relationship(type = "HasCs", direction = Direction.OUTGOING)
private ParentC parentC; 

I have some inheritance with my nodes. I have ChildA, ChildB, ChildC classes (extending the parent ones);
I have a simple generated repository method findById(Long id, Class<?> projClazz).
When calling this method i'm using kind of nested projection like that

//ChildA repository
ChildAProjection {
    ChildBProjection getParentB();
}
//ChildB repository
ChildBProjection {
   ChildCProjection getParentC();
}

So, now I would like to get my ChildA node with the relationships defined in the child & parent classes. I perform a call like this:

ChildAProjection proj = childARepository.findById(new Long(1), ChildAProjection.class)

With that, in my "proj" variable, I can perfectly find the parentB attribute filled correctly, but regarding the parentC of the parentB attribute, it is null.

What I've noted when trying to debug in your library is that when you're parsing the Record sent by neo4j, you have some "Node_Relation_Node" strings. And that's what is causing the trouble in my case, i'll try to explain.

In the record sent by neo4j for the execution of my request. I have something like

[...]ChildA_HasBs_ParentB: [{__internalNeo4jId__: 1, ParentB_HasCs_ParentC[...]

For the first relation, the collectionName in

//DefaultNeo4jEntityConverter 
String collectionName = relationshipDescription.generateRelatedNodesCollectionName(genericNodeDescription);

is correct because it's "ChildA_HasBs_ParentB" but in the second relation (deeper relation), there is a mistake because the collectionName is "ChildB_HasCs_ParentC" so it doesn't find it in the Record...

So in the end, my ChildA has the ChildB attribute, but this later one doesn't have the ChildC attribute filled.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 9, 2023
@meistermeier meistermeier self-assigned this Nov 17, 2023
@meistermeier meistermeier added status: needs-investigation An issue that has been triaged but needs further investigation and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 17, 2023
meistermeier added a commit that referenced this issue Nov 20, 2023
@meistermeier
Copy link
Collaborator

Thanks for bringing this to our attention. This is indeed buggy around the detection of the right base type to determine the relationship name that is meant to connect the nodes.
There is now a fix that I will port into a 6.3. preview branch tomorrow for you to test.

@meistermeier
Copy link
Collaborator

There is now a 6.3.14-GH-2819-SNAPSHOT available. If you want to give us feedback on the fix.

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: needs-investigation An issue that has been triaged but needs further investigation labels Nov 21, 2023
@Marc-AntoineGL
Copy link
Author

Ok thanks I will try to test that as soon as possible and I will let you know.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 22, 2023
@Marc-AntoineGL
Copy link
Author

Just a nooby question maybe, sorry, but where exactly can I find this snapshot ? 😅

@meistermeier
Copy link
Collaborator

Not a problem at all, typically I attach also the maven repositories when I mention a SNAPSHOT version. So it's also my bad.

<repositories>
  <repository>
    <id>spring-milestones</id>
    <name>Spring Milestones</name>
    <url>https://repo.spring.io/milestone</url>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
  <repository>
    <id>spring-snapshots</id>
    <name>Spring Snapshots</name>
    <url>https://repo.spring.io/snapshot</url>
    <releases>
      <enabled>false</enabled>
    </releases>
  </repository>
</repositories>

@meistermeier
Copy link
Collaborator

Any update on this?
I will merge this now into the development branches because next release day is on Friday.
Note: Spring Boot 2.7 and with this Spring Data 6.3 got its last official OSS patch release last month. Even though I will also merge this into 6.3 there won't be any planned upcoming release anymore. https://spring.io/projects/spring-boot#support

@meistermeier meistermeier added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Dec 12, 2023
@meistermeier meistermeier added this to the 7.1.7 (2023.0.7) milestone Dec 12, 2023
@Marc-AntoineGL
Copy link
Author

Hello, sorry for late I had some end of the year devs rush...

I just tested it now and it works like a charm for me !
I was testing it with 3 levels of inheritance and with a 4 relationships projection depth.
I think that's not too much of a test but I guess if it work for these, it will work for N levels.

Regarding the next release subject you noted, does it mean the current 2.7.18 will then use your next "6.3.19" (I guess ?) you plan to release on friday ? And this "6.3.19" will be the last version you will release for the 6.3.x versions ? Or am I mistaken ?

Another question regarding this issue you fixed. Was it also present on the 7.x.x versions ? Or did you fix exclusively for the 6.3.x ?

@meistermeier
Copy link
Collaborator

Regarding the next release subject you noted, does it mean the current 2.7.18 will then use your next "6.3.19" (I guess ?) you plan to release on friday ? And this "6.3.19" will be the last version you will release for the 6.3.x versions ? Or am I mistaken ?

Unfortunately no, the release in November was the last open source release. I also just learned this the past week.

Another question regarding this issue you fixed. Was it also present on the 7.x.x versions ? Or did you fix exclusively for the 6.3.x ?

No worries, I fixed it in the current versions: 7.0.x (which is also EOL), 7.1.x and 7.2.x before I created the backport for 6.3.x for you to have a simple way to verify the behaviour.

@Marc-AntoineGL
Copy link
Author

So, if I wanna keep using 2.7 with your correction, until my spring upgrades, I will need to keep your 6.3.14-GH-2819-SNAPSHOT in my pom.xml file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-feedback We need additional information before we can continue
Projects
None yet
Development

No branches or pull requests

3 participants