从接口内的application.properties访问数据

时间:2018-05-24 14:09:45

标签: spring spring-boot neo4j spring-data spring-data-neo4j

我想限制某些查询的结果

application.properties

...
spring.neo4j.resultlimit=10
...

PersonRepository

public interface PersonRepository extends GraphRepository<Person> {

    @Query("MATCH p=()-->() RETURN nodes(p) as n, relationships(p)[0] as e") //<--how can I access spring.neo4j.resultlimit value and limits this query?
    Iterable<Map<String, String>> graph();
}

1 个答案:

答案 0 :(得分:0)

您的Spring客户端可以获得spring.neo4j.resultlimit的值并将其传递给graph()方法,可以这样定义:

public interface PersonRepository extends GraphRepository<Person> {
    @Query("MATCH p=()-->() RETURN nodes(p) as n, relationships(p)[0] as e LIMIT {0}")
    Iterable<Map<String, String>> graph(Integer resultLimit);
}