What is the best practice to update a Vertex after is detached from DB with Tinkerpop Frames?

走远了吗. 提交于 2019-12-13 04:43:37

问题


Let's exemplify

  1. I receive a Vertex with Tinkerpop Blueprint, then I use Frames to convert it in an entity.
  2. I close the database (so from now the node is detached from the DB)
  3. and I show the node on a web page to let the user modify it.

The user makes some modifications, then I shoud persist the changes.

The problem is that the Instance of the database is already closed, so the entity is detached from the database: What is the best practice (considering performance and memory usage too) to update the node?

This may be the code example:

 FramedGraph<OrientGraph> graph = factory.getFramedGraph();
 User user = graph.addVertex(null, User.class);
 graph.shutdown();

then I want to update later the node:

 user.name = "Donald Duck";
 user.... ?

Thank you, Andrea


回答1:


I found this way, that seems quite efficient:

public User persistUser(User user){

    FramedGraph<OrientGraph> graph = factory.getFramedGraph();

    user = graph.frame(user.asVertex(), User.class);
    factory.persist();
    graph.shutdown();

So the framework automatically merge back the entity to the database. Then you have to persist.



来源:https://stackoverflow.com/questions/26187415/what-is-the-best-practice-to-update-a-vertex-after-is-detached-from-db-with-tink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!