title: update in orient db using document api
body: <p>I am trying to run an upsert using document api but was not able to find any method or easy way to do. Below is the code, every time I run, it inserts a new record everytime</p>
  
  <pre><code>   public class TestUpsert {
  
     public static void main(String[] args) {
            Object obj = new Object();
            obj.setRpstryId("ABC");
            obj.setObjId("123");
            obj.setObjIdCntxtCd("456");
            obj.setObjNm("XYZ");
            obj.setObjDesc("text");
            obj.setObjTypId("78901");
            createObject(obj);
     }
  
     public static void createObject(Object obj) {
  
            try (ODatabaseDocumentTx db = new ODatabaseDocumentTx(
                         "remote:localhost/abc").open("root", "admin");) {
  
                   ODocument obj = new ODocument("Object");
                   obj.field("rpstryId", obj.getRpstryId());
                   obj.field("objId", obj.getObjId());
                   obj.field("objIdCntxtCd", obj.getObjIdCntxtCd());
                   obj.field("objTypId", obj.getObjTypId());
                   obj.field("objNm", obj.getObjNm());
                   obj.field("objDesc", obj.getObjDesc());
                   System.out.println("Completed");
                   obj.save();                    
                   db.close();
            } catch (Exception exception) {                   
                   exception.printStackTrace();
  
            }
  
     }
  </code></pre>