2015-07-20 47 views
0

爲了使用neo4j-graph數據庫獨立服務器,我將Spring Data Neo4j 4.0.0.M1的依賴項添加到我的pom中。Spring Data Neo4J 4 - 在GraphRepository中的Order By不起作用

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

Btw。我寫了自己的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服務器是罰款:

{"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會話緩存這個問題?

+1

請使用4.0.0.RC1 - 自M1以來,已經有許多修復和功能(包括可以使用的排序和分頁功能)。讓我們知道,如果問題仍然存在。 – Luanne

+0

謝謝,這解決了我的問題! – mzober

回答

0

爲了有類似問題的人的利益,排序和分頁是在4.0.0 M1之後引入的。請使用4.0.0.RC1,其中也包含許多錯誤修復程序。