0

为了使用 neo4j-graphdatabase 独立服务器,我将 Spring Data Neo4j 4.0.0.M1 的依赖项添加到我的 pom.xml 中。

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

顺便提一句。我编写了自己的 CDI 扩展并在 JavaEE 6 下使用它。(它已经过测试并且可以工作。)

我在我的应用程序中管理人员。因此,如果我想在 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);
}

对于我的测试,我用 3 个语句创建了 3 个人:

1.

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

2.

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

3.

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

要让我使用的 updatedTime DESC 订购的所有人:

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

不要得到

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

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

调试它我用 sudo ngrep -t -d any port 7474

...并且来自我的 neo4j-server 的提交很好:

    {"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":[]} 

所以现在我的问题是:

1. 我怎样才能得到我 3 人的正确顺序?

2.这个问题取决于转换为Iterable<Person>或对象图映射?

3.这个问题取决于我的neo4j-session的缓存吗?

4

1 回答 1

0

为了方便有类似问题的人,在 4.0.0 M1 之后引入了排序和分页。请使用还包含许多错误修复的 4.0.0.RC1。

于 2015-07-20T15:52:56.230 回答