To work with a neo4j-graphdatabase standalone server i add the dependency of Spring Data Neo4j 4.0.0.M1 to my 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.)
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>)
:
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:
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'})"
to get all persons ordered by the updatedTime DESC i use:
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
...and the commit from my neo4j-server was fine:
{"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?
2. Depends this problem on convertion to the Iterable<Person>
or object-graph-mapping?
3. Depends this problem on caching from my neo4j-session?