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

332 views
Skip to first unread message

aa5186

unread,
Jul 17, 2017, 7:12:38 PM7/17/17
to JanusGraph users list
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!

Robert Dale

unread,
Jul 17, 2017, 7:32:23 PM7/17/17
to aa5186, JanusGraph users list
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

--
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.

arunab...@gmail.com

unread,
Jul 17, 2017, 7:50:19 PM7/17/17
to JanusGraph users list, arunab...@gmail.com
Thank you Robert! This helps :)

Arunabh

Robert Dale

To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages