daiyue daiyue - 1 year ago 104
Java Question

How to use batching in OrientDB using Java

I am new to

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


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

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

Answer Source

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