I got a graph which is described by the following Cypher expression:
CREATE
(BMW:Brand {name: "BMW", country: "Germany"}),
(X3:Model {name: "X3", acceleration: 7.1, maxSpeed: 227.5, displacement: 1997, consumption: 6}),
(lastGen:Generation {from: 2013}),
(xDrive20i:Modification {name: "xDrive20i", maxSpeed: 210, acceleration: 8.3, consumption: 7.9}),
(X3)-[:MODEL_OF]->(BMW),
(BMW)-[:MODEL]->(X3),
(lastGen)-[:GENERATION_OF]->(X3),
(X3)-[:GENERATION]->(lastGen),
(xDrive20i)-[:MODIFICATION_OF]->(X3),
(X3)-[:MODIFICATION]->(xDrive20i),
(lastGen)-[:MODIFICATION]->(xDrive20i),
(xDrive20i)-[:MODIFICATION_OF]->(lastGen);
I described a java class matching to Brand
's data structure:
@NodeEntity
@TypeAlias("Brand")
public class Brand {
@GraphId
private Long id;
@Indexed(indexType = IndexType.FULLTEXT, indexName = "brand_name")
private String name;
private String origin;
private String owner;
@RelatedTo(type = "MODEL", direction = Direction.OUTGOING)
private Set<Model> models;
//getters and setters are ommited
}
and repository:
public interface BrandRepository extends GraphRepository<Brand>{
//method's signatures are ommited
}
When I call brandRepository.count()
it returns 1 as I expect. But if I call brandRepository.getOne(2249L)
I get an exception:
java.lang.IllegalStateException: No primary SDN label exists .. (i.e one with starting with __TYPE__)
As I understand reading LabelBasedNodeTypeRepresentationStrategy
source, a node has to have at least one label with __TYPE__
prefix.
How do I map the entity to the graph given that I may not change the graph structure?
I wouldn't mind implementing my own custom LabelBasedNodeTypeRepresentationStrategy
if there is no other way. But in this case could somebody let me know why it is implemented this way (I think it is not accidentally) and how should I bind custom solution to spring-data-neo4j
use it?
I use neo4j-2.0.0-M06 and spring-data-neo4j-3.0.0.M1.