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
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();
}
}
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.