Skip to content

Cannot add new relationships when using @RelationshipProperties #2599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cberes opened this issue Sep 20, 2022 · 2 comments
Closed

Cannot add new relationships when using @RelationshipProperties #2599

cberes opened this issue Sep 20, 2022 · 2 comments
Assignees
Labels
type: bug A general bug

Comments

@cberes
Copy link
Contributor

cberes commented Sep 20, 2022

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 20, 2022
@meistermeier meistermeier self-assigned this Sep 21, 2022
meistermeier added a commit that referenced this issue Sep 26, 2022
@meistermeier
Copy link
Collaborator

Thanks for reporting this bug. Yes, it is definitely a (stupid) bug and I am sorry that you have to encounter it.
For now I can only advise to use 6.3.2 and give the 6.3.4-GH-2599-SNAPSHOT a try (should be available in the next 30 minutes).

@meistermeier meistermeier added this to the 6.3.4 (2021.2.4) milestone Sep 26, 2022
@meistermeier meistermeier added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 26, 2022
@meistermeier
Copy link
Collaborator

I also merged this now into the development branches for 6.3. and 7.0.
Thanks again for reporting this.

@michael-simons michael-simons mentioned this issue Jan 4, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants