Skip to content

Cannot add new relationships when using @RelationshipProperties #2599

@cberes

Description

@cberes

SDN will not save relationships annotated with @RelationshipProperties if the start node already exists.

Please see this example app that reproduces the bug.

For example, say you have a schema like this, where two nodes are related and this is represented by a
class annotated with @RelationshipProperties

@Node
public class Cat {
    @Relationship("HAS_CLAW") List<HasClaw> claws;
}

@Node
public class Claw {
}

@RelationshipProperties
public class HasClaw {
    @Id @GeneratedValue Long id;

    boolean dewclaw;

    @TargetNode Claw claw;
}

Once you create a Cat, you can no longer add new HAS_CLAWS relationships

Cat cat = new Cat();
cat.getClaws().add(new HasClaw(false, new Claw()));
catRepository.save(cat);

cat.getClaws().add(new HasClaw(true, new Claw()));
catRepository.save(cat);

Cat found = catRepository.findById(cat.getId()).get();
assertThat(found.getClaws()).hasSize(2); // fails: size is 1

Note that relationships not annotated with @RelationshipProperties (for example the Dog entity in the example code)
are not affected by this.

This example worked correctly in SDN 6.3.2, but it fails with SDN 6.3.3.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions