@Repository public interface Neo4jOperations
Neo4jTemplate
, that provides the API for using
the persistence framework in a more direct way as an alternative to the repositories.Modifier and Type | Method and Description |
---|---|
long |
count(Class<?> entityClass)
Provides the instance count for the given node entity type.
|
void |
delete(Object entity)
Removes the given node or relationship entity from the graph.
|
org.neo4j.ogm.session.result.QueryStatistics |
execute(String cypherQuery)
Issue a single Cypher update operation (such as a CREATE, MERGE or DELETE statement).
|
org.neo4j.ogm.session.result.QueryStatistics |
execute(String cypher,
Map<String,Object> parameters)
Allows a cypher statement with a modification statement to be executed.
|
<T> T |
load(Class<T> type,
Long id)
Loads an entity of type T that matches the specified ID to the default depth.
|
<T> T |
load(Class<T> type,
Long id,
int depth)
Loads an entity of type T that matches the specified ID to the given depth.
|
<T> Collection<T> |
loadAll(Class<T> type)
Retrieves all the entities of the given class in the database hydrated to the default depth.
|
<T> Collection<T> |
loadAll(Class<T> type,
int depth)
Retrieves all the entities of the given class in the database hydrated to the specified depth.
|
<T> Collection<T> |
loadAll(Collection<T> objects,
int depth)
Reloads all of the entities in the given
Collection to the specified depth. |
<T> Collection<T> |
loadAllByProperties(Class<T> type,
org.neo4j.ogm.cypher.Filters parameters)
Retrieves all the entities of the specified type that contain a properties matching the ones supplied with given name and value.
|
<T> Collection<T> |
loadAllByProperty(Class<T> type,
String propertyName,
Object propertyValue)
Retrieves all the entities of the specified type that contain a property matching the given name with the given value.
|
<T> T |
loadByProperties(Class<T> type,
org.neo4j.ogm.cypher.Filters parameters)
Retrieves the entity of the specified type that contains properties matching the ones supplied with given name and value.
|
<T> T |
loadByProperty(Class<T> type,
String propertyName,
Object propertyValue)
Retrieves the entity of the specified type that contains a property matching the given name with the given value.
|
Iterable<Map<String,Object>> |
query(String cypherQuery,
Map<String,?> params)
|
<T> T |
queryForObject(Class<T> entityType,
String cypherQuery,
Map<String,?> parameters)
Runs the specified Cypher query with the given parameters against the underlying Neo4j database and returns the result
marshalled as an object of the requested type.
|
<T> Iterable<T> |
queryForObjects(Class<T> entityType,
String cypherQuery,
Map<String,?> parameters)
Runs the specified Cypher query with the given parameters against the underlying Neo4j database and returns the result
marshalled as a group of objects of the requested type.
|
<T> T |
save(T entity)
Saves the specified entity in the graph database.
|
<T> T load(Class<T> type, Long id)
type
- The type of entity to loadid
- The ID of the node or relationship to matchnull
if no match is found<T> T load(Class<T> type, Long id, int depth)
type
- The type of entity to loadid
- The ID of the node or relationship to matchdepth
- The maximum number of relationships away from the identified object to follow when loading related entities.
A value of 0 just loads the object's properties and no related entities. A value of -1 implies no depth limit.null
if no match is found<T> Collection<T> loadAll(Class<T> type)
type
- The type of entity to return.Collection
containing all instances of the given type in the database or an empty collection if none
are found, never null
<T> Collection<T> loadAll(Class<T> type, int depth)
type
- The type of entity to return.depth
- The maximum number of relationships away from each loaded object to follow when loading related entities.
A value of 0 just loads the object's properties and no related entities. A value of -1 implies no depth limit.Collection
containing all instances of the given type in the database or an empty collection if none
are found, never null
<T> Collection<T> loadAll(Collection<T> objects, int depth)
Collection
to the specified depth. Of course, this will
only work for persistent objects (i.e., those with a non-null @GraphId
field).objects
- The objects to re-hydratedepth
- The depth to which the objects should be hydratedCollection
of entities matching those in the given collection hydrated to the given depth<T> T loadByProperty(Class<T> type, String propertyName, Object propertyValue)
loadAllByProperty(Class, String, Object)
instead.type
- The type of entity to loadpropertyName
- The name of the property on the entity against which to match the given valuepropertyValue
- The value of the named property against which to match entitiesnull
NotFoundException
- if there are no matching entitiesIllegalStateException
- if there's more than one matching entity<T> Collection<T> loadAllByProperty(Class<T> type, String propertyName, Object propertyValue)
type
- The type of entity to loadpropertyName
- The name of the property on the entity against which to match the given valuepropertyValue
- The value of the named property against which to match entitiesCollection
containing all the entities that match the given property or an empty Collection
if
there aren't any matches, never null
<T> T loadByProperties(Class<T> type, org.neo4j.ogm.cypher.Filters parameters)
loadAllByProperty(Class, String, Object)
instead.type
- The type of entity to loadparameters
- The parameters to filter bynull
NotFoundException
- if there are no matching entitiesIllegalStateException
- if there's more than one matching entity<T> Collection<T> loadAllByProperties(Class<T> type, org.neo4j.ogm.cypher.Filters parameters)
type
- The type of entity to loadparameters
- The parameters to filter byCollection
containing all the entities that match the given properties or an empty Collection
if
there aren't any matches, never null
<T> T save(T entity)
entity
- The entity to savevoid delete(Object entity)
entity
- The entity to deleteIterable<Map<String,Object>> query(String cypherQuery, Map<String,?> params)
Iterable
of Map
s.
Each of the resultant maps corresponds to a "row" in the result set and the key set in each map contains all the names
contained in the RETURN
clause of the given query.
cypherQuery
- The Cypher query to executeparams
- The parameter to merge into the cypher query or an empty Map
if the given query isn't parameterisedIterable
of Map
s represening the result of the query or an empty Iterable
if there are
no results, never null
RuntimeException
- if the given query is not a valid Cypher MATCH
query<T> T queryForObject(Class<T> entityType, String cypherQuery, Map<String,?> parameters)
entityType
- The Class
denoting the type of entity to returncypherQuery
- The Cypher query to executeparameters
- The parameter to merge into the Cypher query or an empty Map
if the query's not parameterisednull
if nothing is
found by the queryRuntimeException
- If more than one result is returned or there's an issue executing the query<T> Iterable<T> queryForObjects(Class<T> entityType, String cypherQuery, Map<String,?> parameters)
entityType
- The Class
denoting the type of entity to returncypherQuery
- The Cypher query to executeparameters
- The parameter to merge into the Cypher query or an empty Map
if the query's not parameterisedIterable
over the entities found by executing the query or an empty Iterable
if nothing
is found by the query, never null
RuntimeException
- If there's an issue executing the queryorg.neo4j.ogm.session.result.QueryStatistics execute(String cypherQuery)
cypherQuery
- The Cypher query to executeQueryStatistics
representing statistics about graph modifications as a result of the cypher execution.org.neo4j.ogm.session.result.QueryStatistics execute(String cypher, Map<String,Object> parameters)
Parameters may be scalars or domain objects themselves.
cypher
- The parametrisable cypher to execute.parameters
- Any parameters to attach to the cypher. These may be domain objects or scalars. Note that
if a complex domain object is provided only the properties of that object will be set.
If relationships of a provided object also need to be set then the cypher should reflect this
and further domain object parameters provided.QueryStatistics
representing statistics about graph modifications as a result of the cypher execution.long count(Class<?> entityClass)
entityClass
- The Class
representing the type of node entity to countCopyright © 2011-2015–2015 Pivotal Software, Inc.. All rights reserved.