Spring Data Graph

org.springframework.data.neo4j.repository
Class AbstractGraphRepository<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>

java.lang.Object
  extended by org.springframework.data.neo4j.repository.AbstractGraphRepository<S,T>
Type Parameters:
T - GraphBacked target of this finder, enables the finder methods to return this concrete type
S - Type of backing state, either Node or Relationship
All Implemented Interfaces:
CRUDRepository<T>, GraphRepository<T>, IndexRepository<T>, NamedIndexRepository<T>, TraversalRepository<T>, org.springframework.data.repository.CrudRepository<T,Long>, org.springframework.data.repository.PagingAndSortingRepository<T,Long>, org.springframework.data.repository.Repository<T,Long>
Direct Known Subclasses:
NodeGraphRepository, RelationshipGraphRepository

@Repository
public abstract class AbstractGraphRepository<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
extends Object
implements GraphRepository<T>, NamedIndexRepository<T>

Repository like finder for Node and Relationship-Entities. Provides finder methods for direct access, access via TypeRepresentationStrategy and indexing.


Field Summary
protected  Class<T> clazz
          Target graphbacked type
static org.neo4j.helpers.collection.ClosableIterable EMPTY_CLOSABLE_ITERABLE
           
protected  GraphDatabaseContext graphDatabaseContext
           
 
Constructor Summary
AbstractGraphRepository(GraphDatabaseContext graphDatabaseContext, Class<T> clazz)
           
 
Method Summary
 long count()
          uses the configured TypeRepresentationStrategy, depending on the strategy this number might be an approximation
protected  T createEntity(S node)
           
protected
<T extends Number>
org.apache.lucene.search.NumericRangeQuery<T>
createInclusiveRangeQuery(String property, Number from, Number to)
           
 void delete(Iterable<? extends T> entities)
          deletes the given entities by calling their entity.remove() methods
 void delete(Long id)
           
 void delete(T entity)
          deletes the given entity by calling its entity.remove() method
 void deleteAll()
          removes all entities of this type, use with care
 boolean exists(Long id)
           
 org.neo4j.helpers.collection.ClosableIterable<T> findAll()
          uses the configured TypeRepresentationStrategy to load all entities, might return a large result
 org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
          finder that takes the provided sorting and paging into account NOTE: the sorting is not yet implemented
 org.neo4j.helpers.collection.ClosableIterable<T> findAll(org.springframework.data.domain.Sort sort)
          finder that takes the provided sorting into account NOTE: the sorting is not yet implemented
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByPropertyValue(String property, Object value)
          Index based exact finder, uses the default index name for this type (short class name).
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByPropertyValue(String indexName, String property, Object value)
          Index based exact finder.
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByQuery(String key, Object query)
          Index based fulltext / query object finder, uses the default index name for this type (short class name).
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByQuery(String indexName, String key, Object query)
          Index based fulltext / query object finder.
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByRange(String property, Number from, Number to)
           
 org.neo4j.helpers.collection.ClosableIterable<T> findAllByRange(String indexName, String property, Number from, Number to)
           
 T findByPropertyValue(String property, Object value)
          Index based single finder, uses the default index name for this type (short class name).
 T findByPropertyValue(String indexName, String property, Object value)
          Index based single finder.
 T findOne(Long id)
           
protected abstract  S getById(long id)
           
protected  org.neo4j.graphdb.index.Index<S> getIndex(String indexName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.neo4j.repository.CRUDRepository
save, save
 
Methods inherited from interface org.springframework.data.neo4j.repository.TraversalRepository
findAllByTraversal
 

Field Detail

EMPTY_CLOSABLE_ITERABLE

public static final org.neo4j.helpers.collection.ClosableIterable EMPTY_CLOSABLE_ITERABLE

clazz

protected final Class<T extends GraphBacked<S>> clazz
Target graphbacked type


graphDatabaseContext

protected final GraphDatabaseContext graphDatabaseContext
Constructor Detail

AbstractGraphRepository

public AbstractGraphRepository(GraphDatabaseContext graphDatabaseContext,
                               Class<T> clazz)
Method Detail

count

public long count()
Description copied from interface: CRUDRepository
uses the configured TypeRepresentationStrategy, depending on the strategy this number might be an approximation

Specified by:
count in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
count in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Returns:
Number of instances of the target type in the graph.

findAll

public org.neo4j.helpers.collection.ClosableIterable<T> findAll()
Description copied from interface: CRUDRepository
uses the configured TypeRepresentationStrategy to load all entities, might return a large result

Specified by:
findAll in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
findAll in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Returns:
lazy Iterable over all instances of the target type.

findOne

public T findOne(Long id)
Specified by:
findOne in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
findOne in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Parameters:
id - id
Returns:
Entity with the given id or null.

findByPropertyValue

public T findByPropertyValue(String property,
                             Object value)
Index based single finder, uses the default index name for this type (short class name).

Specified by:
findByPropertyValue in interface IndexRepository<T extends GraphBacked<S>>
Parameters:
property -
value -
Returns:
Single Entity with this property and value

findByPropertyValue

public T findByPropertyValue(String indexName,
                             String property,
                             Object value)
Index based single finder.

Specified by:
findByPropertyValue in interface NamedIndexRepository<T extends GraphBacked<S>>
Parameters:
indexName - or null for default
property -
value -
Returns:
Single Entity with this property and value

getIndex

protected org.neo4j.graphdb.index.Index<S> getIndex(String indexName)

createEntity

protected T createEntity(S node)

findAllByPropertyValue

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByPropertyValue(String indexName,
                                                                               String property,
                                                                               Object value)
Index based exact finder.

Specified by:
findAllByPropertyValue in interface NamedIndexRepository<T extends GraphBacked<S>>
Parameters:
indexName - or null for default index
property -
value -
Returns:
Iterable over Entities with this property and value

findAllByPropertyValue

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByPropertyValue(String property,
                                                                               Object value)
Index based exact finder, uses the default index name for this type (short class name).

Specified by:
findAllByPropertyValue in interface IndexRepository<T extends GraphBacked<S>>
Parameters:
property -
value -
Returns:
Iterable over Entities with this property and value

findAllByQuery

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByQuery(String key,
                                                                       Object query)
Index based fulltext / query object finder, uses the default index name for this type (short class name).

Specified by:
findAllByQuery in interface IndexRepository<T extends GraphBacked<S>>
Parameters:
key - key of the field to query
query - lucene query object or query-string @return Iterable over Entities with this property and value

findAllByQuery

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByQuery(String indexName,
                                                                       String key,
                                                                       Object query)
Index based fulltext / query object finder.

Specified by:
findAllByQuery in interface NamedIndexRepository<T extends GraphBacked<S>>
Parameters:
indexName - or null for default index
key - key of the field to query
query - lucene query object or query-string @return Iterable over Entities with this property and value

findAllByRange

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByRange(String property,
                                                                       Number from,
                                                                       Number to)
Specified by:
findAllByRange in interface IndexRepository<T extends GraphBacked<S>>

findAllByRange

public org.neo4j.helpers.collection.ClosableIterable<T> findAllByRange(String indexName,
                                                                       String property,
                                                                       Number from,
                                                                       Number to)
Specified by:
findAllByRange in interface NamedIndexRepository<T extends GraphBacked<S>>

createInclusiveRangeQuery

protected <T extends Number> org.apache.lucene.search.NumericRangeQuery<T> createInclusiveRangeQuery(String property,
                                                                                                     Number from,
                                                                                                     Number to)

getById

protected abstract S getById(long id)

exists

public boolean exists(Long id)
Specified by:
exists in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
exists in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Returns:
true if the entity with this id exists

delete

public void delete(T entity)
Description copied from interface: CRUDRepository
deletes the given entity by calling its entity.remove() method

Specified by:
delete in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Parameters:
entity - to delete

delete

public void delete(Long id)
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>

delete

public void delete(Iterable<? extends T> entities)
Description copied from interface: CRUDRepository
deletes the given entities by calling their entity.remove() methods

Specified by:
delete in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>
Parameters:
entities - to delete

deleteAll

public void deleteAll()
Description copied from interface: CRUDRepository
removes all entities of this type, use with care

Specified by:
deleteAll in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
deleteAll in interface org.springframework.data.repository.CrudRepository<T extends GraphBacked<S>,Long>

findAll

public org.neo4j.helpers.collection.ClosableIterable<T> findAll(org.springframework.data.domain.Sort sort)
Description copied from interface: CRUDRepository
finder that takes the provided sorting into account NOTE: the sorting is not yet implemented

Specified by:
findAll in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends GraphBacked<S>,Long>
Returns:
all elements of the repository type, sorted according to the sort NOTE: please close the iterable if it is not fully looped through

findAll

public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable)
Description copied from interface: CRUDRepository
finder that takes the provided sorting and paging into account NOTE: the sorting is not yet implemented

Specified by:
findAll in interface CRUDRepository<T extends GraphBacked<S>>
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T extends GraphBacked<S>,Long>
Returns:
all elements of the repository type, sorted according to the sort NOTE: please close the iterable if it is not fully looped through

Spring Data Graph

Copyright © 2011 SpringSource. All Rights Reserved.