Spring Data Neo4j

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

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>, CypherDslRepository<T>, GraphRepository<T>, IndexRepository<T>, NamedIndexRepository<T>, SpatialRepository<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:
NodeGraphRepositoryImpl, RelationshipGraphRepository

public abstract class AbstractGraphRepository<S extends org.neo4j.graphdb.PropertyContainer,T>
extends Object
implements GraphRepository<T>, NamedIndexRepository<T>, SpatialRepository<T>, CypherDslRepository<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  Neo4jTemplate template
           
 
Constructor Summary
AbstractGraphRepository(Neo4jTemplate template, 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)
           
 EndResult<T> findAll()
          uses the configured TypeRepresentationStrategy to load all entities, might return a large result
 Iterable<T> findAll(Iterable<Long> ids)
           
 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
 EndResult<T> findAll(org.springframework.data.domain.Sort sort)
          finder that takes the provided sorting into account NOTE: the sorting is not yet implemented
 EndResult<T> findAllByPropertyValue(String property, Object value)
          Index based exact finder, uses the default index name for this type (short class name).
 EndResult<T> findAllByPropertyValue(String indexName, String property, Object value)
          Index based exact finder.
 EndResult<T> findAllByQuery(String key, Object query)
          Index based fulltext / query object finder, uses the default index name for this type (short class name).
 EndResult<T> findAllByQuery(String indexName, String property, Object query)
          Index based fulltext / query object finder.
 EndResult<T> findAllByRange(String property, Number from, Number to)
           
 EndResult<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)
           
 EndResult<T> findWithinBoundingBox(String indexName, double lowerLeftLat, double lowerLeftLon, double upperRightLat, double upperRightLon)
           
 EndResult<T> findWithinDistance(String indexName, double lat, double lon, double distanceKm)
           
 EndResult<T> findWithinWellKnownText(String indexName, String wellKnownText)
           
protected abstract  S getById(long id)
           
protected  org.neo4j.graphdb.index.ReadableIndex<S> getIndex(String indexName, String property)
           
 Class getStoredJavaType(Object entity)
           
 org.springframework.data.domain.Page<T> query(org.neo4j.cypherdsl.grammar.Execute query, org.neo4j.cypherdsl.grammar.Execute countQuery, Map<String,Object> params, org.springframework.data.domain.Pageable page)
           
 EndResult<T> query(org.neo4j.cypherdsl.grammar.Execute query, Map<String,Object> params)
           
 org.springframework.data.domain.Page<T> query(org.neo4j.cypherdsl.grammar.Execute query, Map<String,Object> params, org.springframework.data.domain.Pageable page)
           
 EndResult<T> query(String query, Map<String,Object> params)
           
<U extends T>
Iterable<U>
save(Iterable<U> entities)
          persists the provided entities by forwarding to their entity.persist() methods
<U extends T>
U
save(U entity)
          persists an entity by forwarding to entity.persist()
 
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.TraversalRepository
findAllByTraversal
 

Field Detail

EMPTY_CLOSABLE_ITERABLE

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

clazz

protected final Class<T> clazz
Target graphbacked type


template

protected final Neo4jTemplate template
Constructor Detail

AbstractGraphRepository

public AbstractGraphRepository(Neo4jTemplate template,
                               Class<T> clazz)
Method Detail

findWithinWellKnownText

public EndResult<T> findWithinWellKnownText(String indexName,
                                            String wellKnownText)
Specified by:
findWithinWellKnownText in interface SpatialRepository<T>

findWithinDistance

public EndResult<T> findWithinDistance(String indexName,
                                       double lat,
                                       double lon,
                                       double distanceKm)
Specified by:
findWithinDistance in interface SpatialRepository<T>

findWithinBoundingBox

public EndResult<T> findWithinBoundingBox(String indexName,
                                          double lowerLeftLat,
                                          double lowerLeftLon,
                                          double upperRightLat,
                                          double upperRightLon)
Specified by:
findWithinBoundingBox in interface SpatialRepository<T>

save

public <U extends T> U save(U entity)
Description copied from interface: CRUDRepository
persists an entity by forwarding to entity.persist()

Specified by:
save in interface CRUDRepository<T>
Specified by:
save in interface org.springframework.data.repository.CrudRepository<T,Long>
Parameters:
entity - to be persisted
Returns:
the saved entity (being the same reference as the parameter)

save

public <U extends T> Iterable<U> save(Iterable<U> entities)
Description copied from interface: CRUDRepository
persists the provided entities by forwarding to their entity.persist() methods

Specified by:
save in interface CRUDRepository<T>
Specified by:
save in interface org.springframework.data.repository.CrudRepository<T,Long>
Parameters:
entities - to be persisted
Returns:
the input iterable

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>
Specified by:
count in interface org.springframework.data.repository.CrudRepository<T,Long>
Returns:
Number of instances of the target type in the graph.

findAll

public EndResult<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>
Specified by:
findAll in interface org.springframework.data.repository.CrudRepository<T,Long>
Returns:
lazy Iterable over all instances of the target type.

findOne

public T findOne(Long id)
Specified by:
findOne in interface CRUDRepository<T>
Specified by:
findOne in interface org.springframework.data.repository.CrudRepository<T,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>
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>
Parameters:
indexName - or null for default
property -
value -
Returns:
Single Entity with this property and value

getIndex

protected org.neo4j.graphdb.index.ReadableIndex<S> getIndex(String indexName,
                                                            String property)

createEntity

protected T createEntity(S node)

findAllByPropertyValue

public EndResult<T> findAllByPropertyValue(String indexName,
                                           String property,
                                           Object value)
Index based exact finder.

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

findAllByPropertyValue

public EndResult<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>
Parameters:
property -
value -
Returns:
Iterable over Entities with this property and value

findAllByQuery

public EndResult<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>
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 EndResult<T> findAllByQuery(String indexName,
                                   String property,
                                   Object query)
Index based fulltext / query object finder.

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

findAllByRange

public EndResult<T> findAllByRange(String property,
                                   Number from,
                                   Number to)
Specified by:
findAllByRange in interface IndexRepository<T>

findAllByRange

public EndResult<T> findAllByRange(String indexName,
                                   String property,
                                   Number from,
                                   Number to)
Specified by:
findAllByRange in interface NamedIndexRepository<T>

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>
Specified by:
exists in interface org.springframework.data.repository.CrudRepository<T,Long>
Returns:
true if the entity with this id exists

getStoredJavaType

public Class getStoredJavaType(Object entity)
Specified by:
getStoredJavaType in interface CRUDRepository<T>

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>
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T,Long>
Parameters:
entity - to delete

delete

public void delete(Long id)
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T,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>
Specified by:
delete in interface org.springframework.data.repository.CrudRepository<T,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>
Specified by:
deleteAll in interface org.springframework.data.repository.CrudRepository<T,Long>

findAll

public EndResult<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>
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,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

query

public EndResult<T> query(String query,
                          Map<String,Object> params)
Specified by:
query in interface CRUDRepository<T>

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>
Specified by:
findAll in interface org.springframework.data.repository.PagingAndSortingRepository<T,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 Iterable<T> findAll(Iterable<Long> ids)
Specified by:
findAll in interface org.springframework.data.repository.CrudRepository<T,Long>

query

public org.springframework.data.domain.Page<T> query(org.neo4j.cypherdsl.grammar.Execute query,
                                                     org.neo4j.cypherdsl.grammar.Execute countQuery,
                                                     Map<String,Object> params,
                                                     org.springframework.data.domain.Pageable page)
Specified by:
query in interface CypherDslRepository<T>

query

public org.springframework.data.domain.Page<T> query(org.neo4j.cypherdsl.grammar.Execute query,
                                                     Map<String,Object> params,
                                                     org.springframework.data.domain.Pageable page)
Specified by:
query in interface CypherDslRepository<T>

query

public EndResult<T> query(org.neo4j.cypherdsl.grammar.Execute query,
                          Map<String,Object> params)
Specified by:
query in interface CypherDslRepository<T>

Spring Data Neo4j

Copyright © 2013 SpringSource. All Rights Reserved.