To work with a neo4j-graphdatabase standalone server i add the dependency of SDN 4.0.0.RC1 to my pom:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>4.0.0.RC1</version>
<exclusions>
<exclusion>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
</exclusion>
</exclusions>
</dependency>
In my application i want to manage families. Persons as NodeEntities, relationtypes as NodeEntities and family-relationships as RelationshipEntities.
To save nodes or relationships i use repository.save(T t) (repository extends GraphRepository<T>)
. This works for all nodes, but not for relationships.
The explicit not working code:
Relation createdRelation = new Relation(typeName, from, to, getCurrentUsername());
createdRelation.setBegin(begin);
createdRelation.setEnd(end);
Relation relation = relationRepository.save(createdRelation);
I get an Relation-Object back from save(T t). But the RelationshipEntity is not persisted in the graphdatabase. Also my Relation-Object does not have any id.
The RelationshipEntity class looks like this:
@RelationshipEntity(type = "RELATION")
public class Relation extends BaseMutableGraphEntity {
@Property
private String type;
@StartNode
private Person fromPerson;
@EndNode
private Person toPerson;
private Relation() {
}
...getters and setters...}
The graph-id is saved in the BaseClass:
public abstract class BaseGraphEntity implements AuditEntity {
@GraphId
private Long id;
...with getters and setters...}
My question now is:
How can i save my RelationshipEntities with Spring Data Neo4j 4 RC1?
Is there an other repository for RelationshipEntities?
P.S.: I tried to change the place of my graph-id to the main RelationshipEntity, but it does not work.