-
Notifications
You must be signed in to change notification settings - Fork 617
Node(ID) already exists with label X
and properties y
= 'z', a
= 'b' on repository save with unicity
#2456
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
Comments
Spring Data Neo4j won't create entities already existing in the database.
|
@meistermeier thank you for your response. Here is what I did:
When a want to create a new Entity linked to an existing LinkedEntity, I set the tenant property and add an additionalLabel which is "BU" concatenated to the tenant. The objectif is to get a new relation as :
Please note that I have an unicity constraint on LinkedEntity code and tenant as we can get another LinkedEntity like (p:
At this line I can't understand why removing all additional labels: |
We remove and set the labels because we need to be sure that after the persist operation you are left only with the labels defined on you entity at the moment of calling save. |
@meistermeier Thank for your response and your investigation. |
FYI: A composite key won't work, yet. |
I am currently wondering what version of Spring Data Neo4j 6 you are using. |
@meistermeier I used version 6.0.6 and then migrated to 6.1.1. The log I posted was for both versions, I think. Do you mean an higher version than 6.1.1 could help? |
Yes definitely, we did some enhancement in this area. If possible use 6.1.7 (latest 6.1 as of this writing) or 6.2.0. |
Ok thank you @meistermeier |
Closing this for now. If the problem persists if using more current versions, feel free to open this issue again. |
Hi the Team,
I got the error
Node(ID) already exists with label Entity and properties prop1 = v1, prop2 = v2
when try trying to save an entity defined as:I created an unicity constraint for LinkedEntity where prop1 and prop2 must be unique (
ASSERT (n.prop1, n.prop2)
)Now when a LinkedEntity already exists I get a Constraint violation exception when I try to create a new Entity linkedTo the existing LinkedEntity.
It seems Spring data Neo4j try to create the existing LinkedEntity again.
Is it possible to only create not existing nodes and the create the relationship?
The text was updated successfully, but these errors were encountered: