In Neo4J I have a @NodeEntity Person
.
I'd like to be able to also add additional labels such as :USER
, :CUSTOMER
, :OWNER
, :AGENT
, etc.
It seems that spring-data-neo4j:3.0.0-RELEASE
has support for an @Labels
annotation, but I get a NullPointerException
when trying to use it.
@NodeEntity
public class Person {
@GraphId
Long id
@Indexed(unique=true)
String email
@Labels // <- Seems this is unsupported.
private Collection<String>labels
public void addLabel(String label) {
this.labels.add(label) // <- NullPointer thrown here.
}
}
I assume this is because it's not yet supported. If this is indeed the case, would someone kindly give me an example of how to achieve the same result by updating the repository behind it, adding a manual @Query
annotation to add the label?
I'm not sure how to:
- Reference the current node in the query.
- Execute the cypher after the save() method has been called and the node has been created.