Reputation: 88
I have problems with creating relationships in a NEO4J Db with SDN. The attached nodes are created, just the relationships are missing.
Aggregate Root Service
@Node("Service")
@Data(staticConstructor = "of")
public final class ServiceEntity {
@Id
private final Long id;
private final String name;
@Relationship(type = "handles", direction = INCOMING)
private final AuthorityEntity authority;
@Relationship("gives")
private final ArtifactEntity output;
@Relationship(value = "needs", direction = INCOMING)
private final Collection<ArtifactEntity> input;
}
Artifact
@Node("Artifact")
@Data(staticConstructor = "of")
public class ArtifactEntity {
@Id
private final Long id;
private final String name;
}
Authority
@Node("Authority")
@Data(staticConstructor = "of")
public class AuthorityEntity {
@Id
private final String name;
}
Neo4jRepository
public interface ServiceSpringRepository extends Neo4jRepository<ServiceEntity, Long> {
}
Whenever I save some Services it will create all the attached Service, Artifact and Authority nodes, but without any relationships. The view looks like as follows for match(n) return n
For match(n)-[r]->(m) return n,r,m
I get no records.
The Database Overview looks like this:
Upvotes: 0
Views: 259
Reputation: 69
Any @Node must have a valid @Id to have a relationship. Refactor your code like this:
@Node("Authority")
@Data(staticConstructor = "of")
public class AuthorityEntity {
@Id
@Generated
private final String name;
}
Upvotes: 1