简体   繁体   English

Spring Data Neo4J 4-在GraphRepository中排序不起作用

[英]Spring Data Neo4J 4 - Order By in GraphRepository don't work

To work with a neo4j-graphdatabase standalone server i add the dependency of Spring Data Neo4j 4.0.0.M1 to my pom. 为了使用neo4j-graphdatabase独立服务器,我将Spring Data Neo4j 4.0.0.M1的依赖项添加到pom中。

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>4.0.0.M1</version>
</dependency>

Btw. 顺便说一句。 i write my own CDI-Extension and work with it under JavaEE 6. (It is tested and it works.) 我编写了自己的CDI-Extension并在JavaEE 6下使用它。(它已经过测试,可以正常工作。)

I manage persons in my application. 我在我的申请中管理人员。 So if i want to get all persons order by the updatedTime i use this easy query with my PersonRepository (GraphRepository<Person>) : 因此,如果我想在updatedTime之前获得所有人员的订单,则可以对我的PersonRepository (GraphRepository<Person>)使用此简单查询:

public interface PersonRepository extends GraphRepository<Person> {

    @Query("MATCH (person:Person) " +
            "Return person " +
            "ORDER BY person.updatedTime DESC " +
            "SKIP {0} " +
            "LIMIT {1} ")
    Iterable<Person> findAll(int offset, int maxResults);
}

For my test i created 3 persons with 3 statements: 为了测试,我用3条陈述创建了3个人:

1. 1。

"statement":"CREATE (n:Person {createdTime:946717810000,
creator:'test-151658',updatedTime:978340210000,
updater:'test-151658',sic:'sic-141226',gender:'MALE'})"

2. 2。

"statement":"CREATE (n:Person {createdTime:946717810000,
creator:'test-151658',updatedTime:1041412210000,
updater:'test-151658',sic:'sic-141402',gender:'MALE'})"

3. 3。

"statement":"CREATE (n:Person {createdTime:946717810000,
creator:'test-151658',updatedTime:1104570610000,
updater:'test-151658',sic:'sic-105603',gender:'MALE'})"

to get all persons ordered by the updatedTime DESC i use: 为了让所有的人都按updatedTime DESC排序,我使用:

Iterable<Person> results = repository.findAll(0, 100);

and don't get 而且不要

Person 1: updatedTime:1104570610000,
Person 2: updatedTime:1041412210000,
Person 3: updatedTime:978340210000

but

Person 1: updatedTime:1041412210000,
Person 2: updatedTime:978340210000,
Person 3: updatedTime:1104570610000 

to debug it i use sudo ngrep -t -d any port 7474 调试它,我使用sudo ngrep -t -d any port 7474

...and the commit from my neo4j-server was fine: ...而且我的neo4j服务器的提交很好:

    {"commit":"http://neo4j:7474/db/dat
      a/transaction/833/commit","results":[{"columns":["person"],
    "data":[{"graph":{"nodes":[{"id":"266","labels":["Person"],"properties":{"creator":"test-151658","createdTime":946717810000,
    "updatedTime":1104570610000,
"updater":"test-151658",
    "sic":"sic-105603","gender":"MALE"}}],"relationships":[]}},{"graph":{"nodes":[{"id":"265","labels":["Person"],
    "properties":{"creator":"test-151658",
    "createdTime":946717810000,"updat
          edTime":1041412210000,"updater":"test-151658","sic":"sic-141402","gender":"MALE"}}],
    "relationships":[]}},{"graph":{"nodes":[{"id":"264",
    "labels":["Person"],"properties":{"creator":"test-151658"
    ,"createdTime":
          946717810000,"updatedTime":978340210000,
    "updater":"test-151658","sic":"sic-141226","gender":"MALE"}}],"relationships":[]}}]}],
    "transaction":{"expires":"Mon, 20 Jul 2015 10:03:42 +0000"}
    ,"errors":[]} 

So now my questions are: 所以现在我的问题是:

1. How can i get the right ordering of my 3 persons? 1.我该如何正确订购3个人?

2. Depends this problem on convertion to the Iterable<Person> or object-graph-mapping? 2.这个问题取决于转换为Iterable<Person>还是object-graph-mapping?

3. Depends this problem on caching from my neo4j-session? 3.这个问题取决于我的neo4j-session的缓存吗?

For the benefit of people with a similar question, sorting and paging was introduced after 4.0.0 M1. 为了使有类似问题的人受益,在4.0.0 M1之后引入了排序和分页。 Please use 4.0.0.RC1 which also contains many bug fixes. 请使用4.0.0.RC1,其中也包含许多错误修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM