I am using Neo4j 3.0.0 with spring-data-neo4j (Version 4.1.1.RELEASE) and the neo4j-ogm-bolt-driver. I want to create the same relationship (same type) between two nodes multiple times.
Persisting the @RelationshipEntity
multiple times via a GraphRepository
interface only creates the relationship once.
After some investigation on this topic I found the workaround described here: Cannot add more than one relationship between nodes in neo4j but in my version of OGM it seems the method createRelationshipBetween
is not longer existing in the Neo4jTemplate
.
Is there any solution available with OGM or do I have to execute the creation of the duplicate relationships with cypher queries?
I need to have the same relationship-type multiple times between two nodes, therefore to add some other reltionship-type is not an option for me.
SDN 4.1/Neo4j OGM does not allow for multiple relations of the same type between two nodes. The exception to the rule is when you want to maintain 2 relationships- one outgoing and one incoming- this is when you'll specify the OUTGOING and INCOMING directions.
You can have multiple relationships if you model the relationship as a relationship entity- the relationship entity must have at least one property, and the value of at least one property must differ from other relationships between the two nodes. You could consider using a timestamp as a property.
Custom Cypher can do this but there will most likely be issues when loading the entity and persisting it back to the graph with multiple relationships of the same time.