diff --git a/src/docbkx/reference/programming-model/repositories.xml b/src/docbkx/reference/programming-model/repositories.xml
index 1d80a9e07..71cf38ecb 100644
--- a/src/docbkx/reference/programming-model/repositories.xml
+++ b/src/docbkx/reference/programming-model/repositories.xml
@@ -8,17 +8,17 @@
They allow for interface based composition of repositories consisting of provided default
implementations for certain interfaces and additional custom implementations for other methods.
-
-
- Spring Data Graph provides only the infrastructure and some default repository implementations
- so far. Future releases will support finders derived from method names, named queries, and
- annotated query methods.
- (e.g.
- findByName(name),
- @Query(name="find-by-name-query") findByName(name), and
- @Query(query="{name:%s}") findByName(name))
-
-
+
+
+
+
+
+
+
+
+
+
+
Spring Data Graph comes with typed repository implementations that provide methods for
locating node and relationship entities. There are 3 types of basic repository interfaces
@@ -27,106 +27,136 @@
indexing subsystem for queries, and TraversalRepository handles Neo4j traversals.
- CRUDRepository delegates to the configured TypeRepresentationStrategy
- (see )
- for type based queries.
-
-
- Load an instance via a Neo4j node id
- T findOne(id)
-
-
- Check for existence of a Neo4j node id
- boolean exists(id)
-
-
- Iterate over all nodes of a node entity type
- Iterable<T> findAll()
- (supported in future versions:
- Iterable<T> findAll(Sort) and
- Page<T> findAll(Pageable))
-
-
- Count the instances of a node entity type
- Long count()
-
-
- Save a graph entity
- T save(T) and Iterable<T> save(Iterable<T>)
-
-
- Delete a graph entity
- void delete(T), void; delete(Iterable<T>),
- and deleteAll()
-
-
-
-
-
- IndexRepository works with the indexing subsystem and provides methods to find
- entities by indexed properties, ranged queries, and combinations thereof. The index key is
- the name of the indexed entity field, unless overridden in the @Indexed annotation.
-
-
- Iterate over all indexed entity instances with a certain field value
- Iterable<T> findAllByPropertyValue(key, value)
-
-
- Get a single entity instance with a certain field value
- T findByPropertyValue(key, value)
-
-
- Iterate over all indexed entity instances with field values in a certain numerical range (inclusive)
- Iterable<T> findAllByRange(key, from, to)
-
-
- Iterate over all indexed entity instances with field values matching the given fulltext string or QueryContext query
- Iterable<T> findAllByQuery(key, queryOrQueryContext)
-
-
- There is also a NamedIndexRepository with the same methods, but with an additional index
- name parameter, making it possible to query any index.
+ GraphRepository is a convenience repository interface, extending CRUDRepository,
+ IndexRepository, and TraversalRepository. Generally, it has all the
+ desired repository methods. If named index operations are required, then NamedIndexRepository
+ may also be included.
-
- TraversalRepository delegates to the Neo4j traversal framework.
-
-
- Iterate over a traversal result
- Iterable<T> findAllByTraversal(startEntity, traversalDescription)
-
-
-
-
- The Repository instances are either created manually via a
- DirectGraphRepositoryFactory, bound to a concrete node or relationship entity class.
- The DirectGraphRepositoryFactory is configured in the Spring context and can be injected.
-
-
- Using GraphRepositories
- graphRepository = graphRepositoryFactory
- .createGraphRepository(Person.class);
+
+ CRUDRepository
+
+ CRUDRepository delegates to the configured TypeRepresentationStrategy
+ (see )
+ for type based queries.
+
+
+ Load an instance via a Neo4j node id
+ T findOne(id)
+
+
+ Check for existence of a Neo4j node id
+ boolean exists(id)
+
+
+ Iterate over all nodes of a node entity type
+ Iterable<T> findAll()
+ (supported in future versions:
+ Iterable<T> findAll(Sort) and
+ Page<T> findAll(Pageable))
+
+
+ Count the instances of a node entity type
+ Long count()
+
+
+ Save a graph entity
+ T save(T) and Iterable<T> save(Iterable<T>)
+
+
+ Delete a graph entity
+ void delete(T), void; delete(Iterable<T>),
+ and deleteAll()
+
+
+
+
+ Important to note here is that the save, delete, and deleteAll
+ methods are only there to conform to the org.springframework.data.repository.Repository
+ interface. The recommended way of saving and deleting entities is by using entity.persist()
+ and entity.remove().
+
+
-Person michael = graphRepository.save(new Person("Michael", 36));
+
+ IndexRepository and NamedIndexRepository
+
+ IndexRepository works with the indexing subsystem and provides methods to find
+ entities by indexed properties, ranged queries, and combinations thereof. The index key is
+ the name of the indexed entity field, unless overridden in the @Indexed annotation.
+
+
+ Iterate over all indexed entity instances with a certain field value
+ Iterable<T> findAllByPropertyValue(key, value)
+
+
+ Get a single entity instance with a certain field value
+ T findByPropertyValue(key, value)
+
+
+ Iterate over all indexed entity instances with field values in a certain numerical range (inclusive)
+ Iterable<T> findAllByRange(key, from, to)
+
+
+ Iterate over all indexed entity instances with field values matching the given fulltext string or QueryContext query
+ Iterable<T> findAllByQuery(key, queryOrQueryContext)
+
+
+
+
+ There is also a NamedIndexRepository with the same methods, but with an additional index
+ name parameter, making it possible to query any index.
+
-Person dave = graphRepository.findOne(123);
+
-Long numberOfPeople = graphRepository.count();
+
+ TraversalRepository
+
+ TraversalRepository delegates to the Neo4j traversal framework.
+
+
+ Iterate over a traversal result
+ Iterable<T> findAllByTraversal(startEntity, traversalDescription)
+
+
+
+
-Person mark = graphRepository.findByPropertyValue("name", "mark");
+
+ Creating repositories
+
+ The Repository instances are either created manually via a
+ DirectGraphRepositoryFactory, bound to a concrete node or relationship entity class.
+ The DirectGraphRepositoryFactory is configured in the Spring context and can be injected.
+
+
+ Using GraphRepositories
+ graphRepository = graphRepositoryFactory
+ .createGraphRepository(Person.class);
-Iterable devs = graphRepository.findAllByProperyValue("occupation", "developer");
+ Person michael = graphRepository.save(new Person("Michael", 36));
-Iterable middleAgedPeople = graphRepository.findAllByRange("age", 20, 40);
+ Person dave = graphRepository.findOne(123);
-Iterable aTeam = graphRepository.findAllByQuery("name", "A*");
+ Long numberOfPeople = graphRepository.count();
+
+ Person mark = graphRepository.findByPropertyValue("name", "mark");
+
+ Iterable devs = graphRepository.findAllByProperyValue("occupation", "developer");
+
+ Iterable middleAgedPeople = graphRepository.findAllByRange("age", 20, 40);
+
+ Iterable aTeam = graphRepository.findAllByQuery("name", "A*");
+
+ Iterable davesFriends = graphRepository.findAllByTraversal(dave,
+ Traversal.description().pruneAfterDepth(1)
+ .relationships(KNOWS).filter(returnAllButStartNode()));
+ ]]>
+
+
-Iterable davesFriends = graphRepository.findAllByTraversal(dave,
- Traversal.description().pruneAfterDepth(1)
- .relationships(KNOWS).filter(returnAllButStartNode()));
-]]>
-