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


arunab...@...
 

Thank you Robert! This helps :)

Arunabh


On Monday, July 17, 2017 at 4:32:23 PM UTC-7, Robert Dale wrote:
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 <aru...@...> 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-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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