Search code examples
inheritanceneo4jannotationsspring-data-neo4j-4neo4j-ogm

Annotate inherited class fields


I'm working with Spring Data Neo4j and want to persist an user into the Neo4j DB. The user (Neo4jUser) extends an user from a generic project that is independent from the Neo4j implementation.

Since every user should have a id, username and email, the generic user looks like this:

public class User{
  private Long id;
  private String username;
  private String email;

  //Constructor, Getter, Setter
}

Now my problem is, that i want to use the "id" attribute from the generic User as the @GraphId in the specific user. However, I don't really know how to put annotations on inherited fields. The Neo4j specification says, if the attribute is named "id" it will be recognized as GraphId without the annotation, but there is still a WARN when i compile. I'd like to eliminate this warning.


Solution

  • I didn't need anotation in the inherited class, since the warning i had was not the fault of neo4j but the fault of maven (probably). After a mvn update the warning was gone