generally you can use graphDatabaseContext.createEntityFromStoredType(node)
or graphDatabaseContext.createEntityFromState(node, type)
But normally you wouldn't do that but rather pass your traversal description to
a repository or your entity.
GraphRepository<Product> repo =
directGraphRepositoryFactory.createGraphRepository(Product.class) // or declare
the repository via interfaces and add <datagraph:repository ...> to your config.
Iterable<Product> products =
repo.findAllByTraversal(product.getPersistentState(), traversalDescription);
from your entity you can do:
@GraphTraversal(builder = ProductsTraversalBuilder.class)
Iterable<Product> products;
or use the method on the entity:
Iterable<Product> products = product.findAllByTraversal(Product.class,
traversalDesc);
HTH
Michael
Am 23.08.2011 um 02:18 schrieb sambodhi sagi:
> Hi!
>
> I am facing a small problem with Spring Graph database APIs. I am not sure
> how to get a NodeBacked object from Node. For example, say I created a
> traversal description, as a result I get Node object and not the NodeBacked
> entity, which in my case is Product
>
> @NodeEntity
> public class Product {
> String id;
> ....
> }
> public Iterator<Node> getProducts(){
> TraversalDescription traversal = new TraversalDescriptionImpl()
> .breadthFirst()
> .relationships(withName("INTERESTED_IN"), Direction.BOTH));
> final org.neo4j.graphdb.traversal.Traverser traverser = traversal
> .traverse(product.getPersistentState());
> final Iterator<Node> it = traverser.nodes().iterator();
> return it;
> }
>
> In simple words I want getProducts() method to return Iterator<Product>
> instead of Iterator<Node>. How do I convert Node to NodeBacked 'Product'?
>
> Many Thanks,
> Sambodhi
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user