Version
spring-boot-starter-data-neo4j:3.2.5
Description
There is a problem that the @RelationshipId member is null in the return value of Neo4jOperations#save and CrudRepository#save.
But relationship ID of refetched node after saved is non null.
Is this the intended behavior?
Testing
I tried to test based on the official sample.
https://github.com/spring-projects/spring-data-neo4j/blob/main/src/test/java/org/springframework/data/neo4j/documentation/spring_boot/TemplateExampleTest.java
@Test
void relationshipIdOfSavedEntityShouldBeNonNull(@Autowired Neo4jTemplate neo4jTemplate) {
MovieEntity movie = new MovieEntity("The Love Bug",
"A movie that follows the adventures of Herbie, Herbie's driver, "
+ "Jim Douglas (Dean Jones), and Jim's love interest, " + "Carole Bennett (Michele Lee)");
Roles roles1 = new Roles(new PersonEntity(1931, "Dean Jones"), Collections.singletonList("Didi"));
Roles roles2 = new Roles(new PersonEntity(1942, "Michele Lee"), Collections.singletonList("Michi"));
movie.getActorsAndRoles().add(roles1);
movie.getActorsAndRoles().add(roles2);
MovieEntity result = neo4jTemplate.save(movie);
assertThat(result.getActorsAndRoles()).allSatisfy(relationship -> {
assertThat(relationship.getId()).isNotNull();
});
}
This test fails because the relationship ID is null.
@Test
void relationshipIdOfFetchedEntityShouldBeNonNull(@Autowired Neo4jTemplate neo4jTemplate) {
MovieEntity movie = new MovieEntity("The Love Bug",
"A movie that follows the adventures of Herbie, Herbie's driver, "
+ "Jim Douglas (Dean Jones), and Jim's love interest, " + "Carole Bennett (Michele Lee)");
Roles roles1 = new Roles(new PersonEntity(1931, "Dean Jones"), Collections.singletonList("Didi"));
Roles roles2 = new Roles(new PersonEntity(1942, "Michele Lee"), Collections.singletonList("Michi"));
movie.getActorsAndRoles().add(roles1);
movie.getActorsAndRoles().add(roles2);
neo4jTemplate.save(movie);
Optional<MovieEntity> result = neo4jTemplate.findById("The Love Bug", MovieEntity.class);
assertThat(result).hasValueSatisfying(value -> {
assertThat(value.getActorsAndRoles()).allSatisfy(relationship -> {
assertThat(relationship.getId()).isNotNull();
});
});
}
On the other hand, the relationship ID of the fetched node is non null, so this test succeeds.
Version
spring-boot-starter-data-neo4j:3.2.5Description
There is a problem that the
@RelationshipIdmember isnullin the return value ofNeo4jOperations#saveandCrudRepository#save.But relationship ID of refetched node after saved is non null.
Is this the intended behavior?
Testing
I tried to test based on the official sample.
https://github.com/spring-projects/spring-data-neo4j/blob/main/src/test/java/org/springframework/data/neo4j/documentation/spring_boot/TemplateExampleTest.java
This test fails because the relationship ID is null.
On the other hand, the relationship ID of the fetched node is non null, so this test succeeds.