Re: Not able to 'addEdge' to 'CacheVertex'

David Pitera <piter...@...>

So I am not sure this will fix your problem, but please give it a try and let me know if it does:

When you instantiate a JanusGraph, [this transaction]( is opened for you. Rather than calling `JanusGraphTransaction tx = graph.newTransaction();`, why don't you emit that line and end your vertex/edge mutation code with `graph.tx().commit();`

I wonder if you have open, non-committed transactions running around; you can use [this method]( to explore that possibility.

On Fri, Jun 30, 2017 at 12:43 AM, Teena K <avidlea...@...> wrote:
    JanusGraph graph ="<path>/janusgraph/conf/");
    JanusGraphTransaction tx = graph.newTransaction();    
    GraphTraversalSource g = graph.traversal();

    <code to add vertices and edges>


    The transaction is committed after all the code is executed.

On Thursday, June 29, 2017 at 10:04:20 PM UTC+5:30, Jason Plurad wrote:
You've left out some context here. How are g` and `tx` initialized? Where is the transaction committed?

On Thursday, June 29, 2017 at 10:33:49 AM UTC-4, Teena K wrote:

down votefavorite

I have the below code in my java program that queries janusgraph to create vertices and edges if they don't exist already.

Vertex v1 = g.V().has(<key1>,<value1>).tryNext().orElseGet(()->
Vertex v2 = g.V().has(<key2>,<value2>).tryNext().orElseGet(()->

Vertices v1 and v2 get created if they don't exist.

..code to check if an edge exists between the two vertices..
..if there is no edge between the two, create an edge

If the vertices are newly created, the code works fine and the edge also gets created between the two vertices. But if the vertices already exist in the DB, the edge doesn't get created. The difference I could find between the two cases is that v1 and v2 are of 'StandardVertex' type when they are newly created and they are of 'CacheVertex' type when they already exist. 'addEdge' is a valid method in both cases. Yet the edge doesn't get created.

You received this message because you are subscribed to the Google Groups "JanusGraph developer list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Join to automatically receive all group messages.