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.
GraphRepositoryProduct repo =
directGraphRepositoryFactory.createGraphRepository(Product.class) // or declare
the repository via interfaces and add datagraph:repository ... to your config.
IterableProduct products =
repo.findAllByTraversal(product.getPersistentState(), traversalDescription);
from your entity you can do:
@GraphTraversal(builder = ProductsTraversalBuilder.class)
IterableProduct products;
or use the method on the entity:
IterableProduct 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 IteratorNode getProducts(){
TraversalDescription traversal = new TraversalDescriptionImpl()
.breadthFirst()
.relationships(withName(INTERESTED_IN), Direction.BOTH));
final org.neo4j.graphdb.traversal.Traverser traverser = traversal
.traverse(product.getPersistentState());
final IteratorNode it = traverser.nodes().iterator();
return it;
}
In simple words I want getProducts() method to return IteratorProduct
instead of IteratorNode. How do I convert Node to NodeBacked 'Product'?
Many Thanks,
Sambodhi
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user