javaneo4jspring-data-neo4jspring-data-neo4j-5

get value from imported class for interface


Setting

I import a class from my Java project via

import myproj.domain.ActionResponse;

Then I try to make an interface for a repository with by extending a Neo4jRepository.

I am following these docs: "parameter types change from <T> to <T, ID>" - https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/

@Repository
    public interface ActionResponseRepository extends Neo4jRepository<ActionResponse, ActionResponse.getId() >  {
...

ActionResponse extends NamedType which extends GraphType which has a

...
@GraphId
    @JsonProperty("id")
    Long id;

    public Long getId() {
        return id;
    }
...

Question

This: extends Neo4jRepository<ActionResponse, ActionResponse.getId() > is incorrect syntax.

How do I fill the second parameter field with the id from the ActionReponse class?


Solution

  • The second parameter of the annotation is the ID type.

    So you should declare something like:

    extends Neo4jRepository<ActionResponse, Long>