-
Notifications
You must be signed in to change notification settings - Fork 619
Closed
Labels
type: bugA general bugA general bug
Description
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.
@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.
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug