cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Persisting relationships with properties with Spring Data Neo4J

Hi all, I have a conceptual question in terms of persisting relationships with properties. I've googled and seems @RelationshipEntity is the way to go, however all references I've seen of it come from the OGM dependency (like "org.neo4j.ogm.annotation" for example).

Is there a way to achieve this by using SDN? I wouldn't assume this is the way; I've heard the new SDN version is isolated from OGM. Or maybe my assumption is not correct?

1 ACCEPTED SOLUTION

Quick recap:
SDN 5 and lower use Neo4j-OGM as the mapping framework
SDN 6 is a standalone solution without Neo4j-OGM

From what we have learned with RelationshipEntity also from the user perspective, we decided to downgrade relationships with properties from a first class entity to a rich connection between @Node entities.
This means that we still support relationship with properties (SDN 6 documentation - Relationship properties) but you cannot work with them directly and have to use the relationship defining entities (nodes) to load, modify and persist them.

View solution in original post

4 REPLIES 4

Quick recap:
SDN 5 and lower use Neo4j-OGM as the mapping framework
SDN 6 is a standalone solution without Neo4j-OGM

From what we have learned with RelationshipEntity also from the user perspective, we decided to downgrade relationships with properties from a first class entity to a rich connection between @Node entities.
This means that we still support relationship with properties (SDN 6 documentation - Relationship properties) but you cannot work with them directly and have to use the relationship defining entities (nodes) to load, modify and persist them.

Thank you, this completely clears the questions I had.

Hi, I have the same question but the answer is not very clear to me. How to use the relationship defining entities (nodes) to load, modify and persist relationship properties exactly? The documentation mentions @RelationshipProperties is the way but doing that doesn't create any relationships at all. Same issue here by another user: java - Relationship not saved in SDN 6 (Spring data neo4j) - Stack Overflow

Finally, I discovered that the issue with persisting relationship properties using @RelationshipProperty annotated class is due to the implicit conversion between long and Long. Changing @RelationshipId private long id; to @RelationshipId private Long id; inside the @RelationshipProperty annotated class will do the trick. This appears to be a bug in SDN, it should report an error instead.