Spring Data Neo4j

org.springframework.data.neo4j.aspects.core
Interface NodeBacked

All Superinterfaces:
GraphBacked<org.neo4j.graphdb.Node,NodeBacked>, ManagedEntity<org.neo4j.graphdb.Node,NodeBacked>

public interface NodeBacked
extends GraphBacked<org.neo4j.graphdb.Node,NodeBacked>

Interface introduced to objects annotated with @NodeEntity by the Neo4jNodeBacking aspect. annotation, to hold underlying Neo4j Node state.

Author:
Rod Johnson

Method Summary
<T> Iterable<T>
findAllByQuery(String query, Class<T> targetType, Map<String,Object> params)
           
 Iterable<Map<String,Object>> findAllByQuery(String query, Map<String,Object> params)
           
<T> Iterable<T>
findAllByTraversal(Class<T> targetType, org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
          Perform a traversal from this entity's underlying node with the given traversal description.
<S extends NodeBacked,E extends NodeBacked>
Iterable<EntityPath<S,E>>
findAllPathsByTraversal(org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
          Perform a traversal from this entity's underlying node with the given traversal description.
<T> T
findByQuery(String query, Class<T> targetType, Map<String,Object> params)
           
 Long getNodeId()
           
<R extends RelationshipBacked>
R
getRelationshipTo(NodeBacked target, Class<R> relationshipClass, String type)
          Finds the relationship of the specified type, from this entity's underlying node to the target entity's underlying node.
 org.neo4j.graphdb.Relationship getRelationshipTo(NodeBacked target, String type)
          Finds the relationship of the specified type, from this entity's underlying node to the target entity's underlying node.
<T extends NodeBacked>
T
persist()
          Attach the entity inside a running transaction.
<T extends NodeBacked>
T
projectTo(Class<T> targetType)
          Reify this entity as another node backed type.
<R extends RelationshipBacked,N extends NodeBacked>
R
relateTo(N target, Class<R> relationshipClass, String relationshipType)
          delegates to relateTo with allowDuplicates set to false
<R extends RelationshipBacked,N extends NodeBacked>
R
relateTo(N target, Class<R> relationshipClass, String relationshipType, boolean allowDuplicates)
           Creates a relationship to the target node, returning a relationship entity representing the created relationship.
 org.neo4j.graphdb.Relationship relateTo(NodeBacked target, String type)
          delegates to relateTo with allowDuplicates set to false
 org.neo4j.graphdb.Relationship relateTo(NodeBacked target, String type, boolean allowDuplicates)
          Creates a relationship to the target node entity with the given relationship type.
 void removeRelationshipTo(NodeBacked target, String relationshipType)
          Removes the all relationships of the given type between this entity's underlying node and the target entity's underlying node.
 
Methods inherited from interface org.springframework.data.neo4j.aspects.core.GraphBacked
getPersistentState, hasPersistentState, remove, setPersistentState
 
Methods inherited from interface org.springframework.data.neo4j.mapping.ManagedEntity
getEntityState
 

Method Detail

persist

<T extends NodeBacked> T persist()
Attach the entity inside a running transaction. Creating or changing an entity outside of a transaction detaches it. It must be subsequently attached in order to be persisted.

Specified by:
persist in interface ManagedEntity<org.neo4j.graphdb.Node,NodeBacked>
Returns:
the attached entity

relateTo

<R extends RelationshipBacked,N extends NodeBacked> R relateTo(N target,
                                                               Class<R> relationshipClass,
                                                               String relationshipType,
                                                               boolean allowDuplicates)

Creates a relationship to the target node, returning a relationship entity representing the created relationship.

Example:

 public class Person {
     ...
     public Friendship knows(Person p) {
         return relateTo(p, Friendship.class, "knows");
     }
     ...
 }
 

Parameters:
target - other entity
relationshipClass - relationship entity class
relationshipType - type of relationship to be created
allowDuplicates - duplication relationships of the same type are allowed between two entities
Returns:
relationship entity of specified relationshipClass

relateTo

<R extends RelationshipBacked,N extends NodeBacked> R relateTo(N target,
                                                               Class<R> relationshipClass,
                                                               String relationshipType)
delegates to relateTo with allowDuplicates set to false


projectTo

<T extends NodeBacked> T projectTo(Class<T> targetType)
Reify this entity as another node backed type. The same underlying node will be used for the new entity.

Parameters:
targetType - type to project to
Returns:
new instance of specified type, sharing the same underlying node with this entity

getNodeId

Long getNodeId()
Returns:
underlying node ID, or null if there is no underlying node

findAllByTraversal

<T> Iterable<T> findAllByTraversal(Class<T> targetType,
                                   org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
Perform a traversal from this entity's underlying node with the given traversal description. The found nodes are used as underlying nodes for new entities of the specified type. provided target type

Parameters:
targetType - node entity type for new entities
traversalDescription - traversal description used
Returns:
Lazy Iterable over the traversal results, converted to the expected node entity instances

findAllPathsByTraversal

<S extends NodeBacked,E extends NodeBacked> Iterable<EntityPath<S,E>> findAllPathsByTraversal(org.neo4j.graphdb.traversal.TraversalDescription traversalDescription)
Perform a traversal from this entity's underlying node with the given traversal description. The found paths are used to create the wrapping entity paths.

Parameters:
traversalDescription - traversal description used
Returns:
Lazy Iterable over the traversal result paths, wrapped as entity paths @{link EntityPath} entity instances

removeRelationshipTo

void removeRelationshipTo(NodeBacked target,
                          String relationshipType)
Removes the all relationships of the given type between this entity's underlying node and the target entity's underlying node. Note that this is handled automatically by RelatedTo fields, single-relationship non-annotated fields, and RelatedToVia fields.

Parameters:
target - other node entity
relationshipType - type to be removed

getRelationshipTo

<R extends RelationshipBacked> R getRelationshipTo(NodeBacked target,
                                                   Class<R> relationshipClass,
                                                   String type)
Finds the relationship of the specified type, from this entity's underlying node to the target entity's underlying node. If a relationship is found, it is used as state for a relationship entity that is returned.

Parameters:
target - end node of relationship
relationshipClass - class of the relationship entity
type - type of the sought relationship
Returns:
Instance of the requested relationshipClass if the relationship was found, null otherwise

findAllByQuery

<T> Iterable<T> findAllByQuery(String query,
                               Class<T> targetType,
                               Map<String,Object> params)

findAllByQuery

Iterable<Map<String,Object>> findAllByQuery(String query,
                                            Map<String,Object> params)

findByQuery

<T> T findByQuery(String query,
                  Class<T> targetType,
                  Map<String,Object> params)

getRelationshipTo

org.neo4j.graphdb.Relationship getRelationshipTo(NodeBacked target,
                                                 String type)
Finds the relationship of the specified type, from this entity's underlying node to the target entity's underlying node.

Parameters:
target - end node of relationship
type - type of the sought relationship
Returns:
requested relationship if it was found, null otherwise

relateTo

org.neo4j.graphdb.Relationship relateTo(NodeBacked target,
                                        String type,
                                        boolean allowDuplicates)
Creates a relationship to the target node entity with the given relationship type.

Parameters:
target - entity
type - neo4j relationship type for the underlying relationship
allowDuplicates - duplication relationships of the same type are allowed between two entities
Returns:
the newly created relationship to the target node

relateTo

org.neo4j.graphdb.Relationship relateTo(NodeBacked target,
                                        String type)
delegates to relateTo with allowDuplicates set to false


Spring Data Neo4j

Copyright © 2012 SpringSource. All Rights Reserved.