Hey there,
currently we are using Spring boot 2.3.4 with neo4j-ogm 3.1.13 and spring-data-neo4j 5.3.4. I had difficulties moving to next version, so I ask you for support for this setup.
I have a class A which contains a property as follows.
@NodeEntity
class A(...) {
...
@Relationship(type = "HAS_CONCORDANCE", direction = Relationship.INCOMING)
var b: MutableList<B> = mutableListOf()
...
}
and the relationship-entity B
@RelationshipEntity(type = Relationships.HAS_CONCORDANCE)
data class B(
@Id @GeneratedValue val id: Long?,
@StartNode val user: User, @EndNode val a: A,
...
)
My test case includes having already one of the B's in the list and adding a new one with a Neo4jRepository. This works in ~65% of the cases, that at the end I have both relationships persisted. But often it occurs, that the new one is not persisted. I can see then, that the returned object from repository.save has still a null id.
The method containing load and save is in an Transactional Annotation.
I'm a bit cueless how to proceed, because this error happens at random...
Could you also provide the other end / the User
?
Of course,
User looks like this
class User(var name: String) {
@Id
var id: Long? = null
@Relationship(type = Relationships.HAS_CONCORDANCE)
var concordances: MutableSet<B> = mutableSetOf()
...
}
All in all im a bit confused, which objects I need to update. I tried also adding that thing to the user, but no difference. So far with that OGM i feel like theres a bunch of magic and abstraction where its hard for me to check, what from the dependent objects is saved or not.
Sorry to add another question before I can help you. What do you mean by saying "moving to the next version"?
The natural dependency of SDN 5.3 would be Neo4j-OGM 3.2, so I assume that you mean upgrading OGM but I am not sure.
Also if I've understood you correctly, the scenario works with the given version above, right?
In my pom I see spring-boot-starter-data-neo4j 2.3.4 RELEASE which bringts spring-data-neo4j 5.3.4 RELEASE which comes with neo-ogm- 3.1.13
My upgrade trials were for spring boot 2.3.5 which ships with spring-data-neo4j 6. I had problems here switching all my RelationshipEntities and not all dependent objects were updated as expected.
This szenario from above works in my tests often, but also failes sometimes. But that sometimes is often enough to be super annoying.
I checked the debug logs for ogm, in the repository.save process when we are successful, the relationship is mentioned 27 times while in case of error its only mentioned 12 times. But i dont know how helpful the debug logs are, i simplified here a bit, got 4-5 more relationship-types...
I'm not sure if its a lucky streak, but your question for user side made my trying to remove the property "concordances" from the user object, so that from the java side, the relationship-property is just included in the A class (and the reference to the user is just inside the relationship). So far it worked 10 times in a row...
Just for clarification this is not 100% correct:
Spring Boot 2.1 -> Spring Data Neo4j 5.1 -> Neo4j-OGM 3.1
Spring Boot 2.2 -> Spring Data Neo4j 5.2 -> Neo4j-OGM 3.2
Spring Boot 2.3 -> Spring Data Neo4j 5.3 -> Neo4j-OGM 3.2
would be the correct versioning if no manual versions are defined
Bidirectional relationships should work with Neo4j-OGM (at least with 3.2 even more correctly) but are always a little bit more complicated to handle/define/remove.