您好我有一个接口和相应的实现类,如:
public interface IActor extends VertexFrame {
@Property(ActorProps.nodeClass)
public String getNodeClass();
@Property(ActorProps.nodeClass)
public void setNodeClass(String str);
@Property(ActorProps.id)
public String getId();
@Property(ActorProps.id)
public void setId(String id);
@Property(ActorProps.name)
public String getName();
@Property(ActorProps.name)
public void setText(String text);
@Property(ActorProps.uuid)
public String getUuid();
@Property(ActorProps.uuid)
public void setUuid(String uuid);
@Adjacency(label = RelClasses.CoActors, direction = Direction.OUT)
public Iterable<IActor> getCoactors();
}
我使用OrientDB,看起来像那样。我也和Neo4j有类似的实现:
Graph graph = new OrientGraph("remote:localhost/actordb");
FramedGraph<Graph> manager = new FramedGraphFactory().create(graph);
IActor actor = manager.frame(((OrientGraph)graph).getVertexByKey("Actor.uuid",uuid), IActor.class);
以上工作但问题是在这种情况下或类似情况下,因为类Actor的两个顶点之间存在关系,所以可能存在图形循环。有没有办法通过注释或其他方式(例如通过管理器)定义在特定的@Adjacency的x步骤后停止所以这不会永远消失?如果@GremlinGroovy(https://github.com/tinkerpop/frames/wiki/Gremlin-Groovy)注释是答案你能举个例子吗?
答案 0 :(得分:0)
我不确定我是否理解这个问题/问题。 (你说“可能”,但实际上并没有证明存在问题!)
根据我的理解,管道将lazy-load
个对象(仅在需要时加载)。帧(我想象)仅在请求时加载相邻帧。基本上,据我所知,没有问题。
// create some framed vertices
Person nick = createPerson(name: 'Nick')
Person michail = createPerson(name: 'Michail')
// create a recursive loop
nick.addKnows(michail)
michail.addKnows(nick)
// handles recursion = true!
Person nick2 = framedGraph.getVertex(nick.asVertex().id, Person)
assert nick2.knows.knows.knows.knows.knows.name == 'Michail'