I am reporting a bug which occurred when I upgraded my project from Spring Boot version 2.0.3.RELEASE to version 2.0.4.RELEASE.
I am using Spring Data Neo4j in the project and include the spring-boot-starter-data-neo4j dependency.
Since Spring Boot version 2.0.4 the starter seems to provide Spring Data Neo4j version 5.0.9.RELEASE. The POM of Spring Data Neo4j defines the Neo4j OGM version 3.0.4 to be used, see here: https://github.com/spring-projects/spring-data-neo4j/blob/5.0.9.RELEASE/pom.xml
But the BOM of Spring Boot 2.0.4 defines the Neo4j OGM version 3.1.0, see here: https://github.com/spring-projects/spring-boot/blob/v2.0.4.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml
The really annoying issue here is that this is not only a "formal" mismatch but I encountered a weird runtime error with this new version constellation. When querying a Spring Data repository with a query method like findByUserId(String userId) I suddenly got the following exception:
java.lang.ClassNotFoundException: org.neo4j.ogm.cypher.Filter$NestedPathSegment
Looking into the problem I found out that the inner class NestedPathSegment exists in the Neo4j OGM version up to 3.0.4, see here: https://github.com/neo4j/neo4j-ogm/blob/v3.0.4/core/src/main/java/org/neo4j/ogm/cypher/Filter.java
But then it suddenly disappeared in Neo4j OGM version 3.1.0 which is managed by Spring Boot, see here: https://github.com/neo4j/neo4j-ogm/blob/v3.1.0/core/src/main/java/org/neo4j/ogm/cypher/Filter.java
Perhaps this is the reason why Spring Data Neo4j project did not move to that version so far.
I workaround the issue by overriding the Neo4j OGM version to force usage of 3.0.4 at the moment, to be compliant with Spring Data. I do it in gradle.properties:
neo4j-ogm.version=3.0.4
I am unsure if that issue is correct at your address because also the Neo4j OGM project does not seem to be consistent with their implementation.
@georgwittberger we've upgraded to Neo4j 3.1.0 way before that (in 2.0.0.RC2 actually, see #12145) so it looks like something has changed in Spring Data Neo4j maybe?
paging @michael-simons for feedback.
@snicoll Thanks for looking into that so quickly, St茅phane.
I also assume that there was some change in Spring Data Neo4j version 5.0.9 which causes the incompatibility with Neo4j OGM version 3.1.0.
To be more precise how to reproduce: The problem occurs when the query generated by Spring Data has to traverse the object graph for filtering. In my case I query a collection of @RelationshipEntity objects where the property of one related node entity is used for filtering. Image like this:
@RelationshipEntity(type = "RELATED_TO")
class MyRelation {
@Id
String id;
@StartNode
MyStartNode startNode;
@EndNode
MyEndNode endNode;
String customProperty;
}
@NodeEntity
class MyStartNode {
@Id
String id;
@Relationship(type="RELATED_TO")
MyRelation relatedTo;
}
@NodeEntity
class MyEndNode {
@Id
String id;
@Relationship(type="RELATED_TO")
MyRelation relatedTo;
}
@Repository
interface MyRelationRepository extends Neo4jRepository<MyRelation, String> {
Iterable<MyRelation> findByStartNodeId(String startNodeId);
}
We fixed a bug with nested properties in derived finder methods. To keep at least backward compatibility Neo4j OGM introduced an additional API in _3.0.4_ and _3.1.1-RC1_. These are the versions for Spring Data Neo4j _5.0.9_ and _5.1.0-RC1_ (Lovelace).
We broke the (API) contract here but unfortunately this was necessary, so it is absolutely our fault. I would suggest keeping Neo4j OGM 3.0.4 for now.
@snicoll As a possible fix we could release a stable _3.1.1_ in a few weeks. This could be picked up in the next upgrade, or?
Thanks for the feedback @meistermeier - We can of course upgrade to 3.1.1 for 2.0.5 and 2.1.0.M2. Let's repurpose this issue to that effect.
Thanks @meistermeier for chiming in and @snicoll for the proposed solution. The fix for nested properties will be in 3.1.1 and 3.0.4, 3.1.1 will be released with SDN Lovelace the latest.
I wonder why OGM is separately managed. Is it for Spring Boot users that want to use OGM but not Spring Data?
@georgwittberger At the moment, we recommend setting the version property as you already did. Sorry for the inconvenience.
@meistermeier any update about a 3.1.1 release? We're releasing Tuesday and would like a fix for this issue if possible.
The Neo4j-OGM 3.1.1 versions is tightly coupled with the Spring Data Lovelace release train. Monday is Spring Data Lovelace RC2 planned and we just released our RC2 yesterday.
Let me chat with the SD team about this. I am thinking about releasing 3.1.1 (final) this weekend because it has no open/known issues. If we would need any changes in OGM for SDN Lovelace GA we could go for a 3.1.2.
Side note: 2.0.5 is not in the calendar. Thought there would be more time for us.
Edit: Thinking about the release this weekend because of this issue not because I want to 馃槃
@meistermeier we're using 3.1.0 with the Kay release train (as this issue affects Spring Boot 2.0.x). We can't really upgrade to an RC for a maintenance release, that's why I am asking.
If using 3.1.x with Kay is a mistake, please let me know as well (even though I doubt we'll be able to downgrade unless you feel it is seriously wrong). Thanks for the support!
That is the root problem you brought to the 2.0.0 release party ;) Kay was only meant to work with Neo4j-OGM 3.0.x but I just saw that there is a Neo4j-OGM version definition in SB when it was too late. So currently we are keeping 3.1.x compatible with Kay (for SB) and Lovelace.
I also have the urge feeling that the version should not get downgraded otherwise I had suggested this in my first comment.
Let me release a stable, non-RC 3.1.1 over the weekend if nobody votes against this.
+1 for 3.1.1 from my side.
Closing in favour of PR #14132
I faced this problem today, and I have temporarily moved to 3.1.1. Is there any update on newer versions to have this fix?
Boot has already upgraded to 3.1.1 and beyond. IIRC, the latest 2.0.x and 2.1.x releases are using 3.1.5.
@DevanshModi The Spring Boot release 2.0.5 fixed that issue in my case and I was able to remove the OGM version override. Could you please try that version of Spring Boot (or higher)?
Most helpful comment
Thanks for the feedback @meistermeier - We can of course upgrade to
3.1.1for2.0.5and2.1.0.M2. Let's repurpose this issue to that effect.