Search code examples
javaorientdb

How to use batching in OrientDB using Java


I am new to OrientDB, and I am wondering how to use batch and massive write/insert in the Java native driver. I couldn't find any examples in Java.

UPDATE

Since I am using Document API, so using the massive insertions is simply

db.declareIntent(new OIntentMassiveInsert());
//your code here....
db.declareIntent(null);

Solution

  • Here's a small example

    OrientGraph g=new OrientGraph(yourPath); 
    
        String cmd = "begin\n";
        cmd += "LET source = SELECT FROM V WHERE id = 'zz'\n";
        cmd += "LET target = SELECT FROM V WHERE id = 'yy'\n";
        cmd += "LET edge = CREATE EDGE RELATION FROM $source TO $target\n";
        cmd += "commit";
    
    g.command(new OCommandScript("sql", cmd)).execute();
    

    Hope it helps