Re: Exception: IllegalStateException: The vertex or type is not associated with this transaction


Robert Dale <rob...@...>
 

Don't mix the Graph API and the Traversal API.  Prefer the Traversal API.

// in two traversals
newNode = g.addV("B").property("x",x).property("y",y).property("z",z).property("w", w).next()
g.V().hasLabel("A").has("x",x).has("y").addE("rt").to(V(newNode)).iterate()

// In one traversal
g.addV("B").property("x",x).property("y",y).property("z",z).property("w", w).as("newNode").V().hasLabel("A").has("x",x).has("y").addE("rt").to("newNode").iterate()

g.tx().commit()



Robert Dale

On Mon, Jul 17, 2017 at 6:53 PM, aa5186 <arunab...@...> wrote:
Hi all,

I am trying to add a new vertex and associate a new edge from it to an existing vertex. It doesn't allow me to add the edge and throws the exception:
java.lang.IllegalStateException: The vertex or type is not associated with this transaction [v[16552]]

```
List<Vertex> nodes = g.V().hasLabel("A").
has("x",x).
has("y",y).toList();
Vertex newNode = tx.addVertex(T.label,"B",
"x",x,
"y",y,
"z",z,
"w",w);
for(Vertex node: nodes){

node.addEdge("rt",newNode);
}
graph.tx().commit();
```
From what I understand, the "nodes" are not part of the tx transaction (...?) and therefore, the edge between "node" and "newNode" is not possible.
Can someone please point me in the right direction as I am new to Graph databases?

Thanks!

--
You received this message because you are subscribed to the Google Groups "JanusGraph users list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.