Reputation: 3107
Let's exemplify
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
Upvotes: 0
Views: 446
Reputation: 3107
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.
Upvotes: 1