Hi,
you can see the attachments and test the code
I put the condition of the upsert on the field ObjId
Regards,
Alessandro
--
---
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.
package ProveCommunity.upsert;
public class MyObject {
private String RpstryId;
private String ObjId;
private String ObjIdCntxtCd;
private String ObjNm;
private String ObjDesc;
private String ObjTypId;
public MyObject() {
super();
}
public String getRpstryId() {
return RpstryId;
}
public void setRpstryId(String rpstryId) {
RpstryId = rpstryId;
}
public String getObjId() {
return ObjId;
}
public void setObjId(String objId) {
ObjId = objId;
}
public String getObjIdCntxtCd() {
return ObjIdCntxtCd;
}
public void setObjIdCntxtCd(String objIdCntxtCd) {
ObjIdCntxtCd = objIdCntxtCd;
}
public String getObjNm() {
return ObjNm;
}
public void setObjNm(String objNm) {
ObjNm = objNm;
}
public String getObjDesc() {
return ObjDesc;
}
public void setObjDesc(String objDesc) {
ObjDesc = objDesc;
}
public String getObjTypId() {
return ObjTypId;
}
public void setObjTypId(String objTypId) {
ObjTypId = objTypId;
}
}
package ProveCommunity.upsert;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.OCommandSQL;
public class Main {
public static void main(String[] args) {
MyObject obj = new MyObject();
obj.setRpstryId("ABC");
obj.setObjId("128");
obj.setObjIdCntxtCd("456");
obj.setObjNm("XYZ");
obj.setObjDesc("text");
obj.setObjTypId("78901");
createObject(obj);
}
public static void createObject(MyObject obj) {
try (ODatabaseDocumentTx db = new ODatabaseDocumentTx(
"remote:localhost/abc2").open("root", "root");) {
System.out.println("ENTRATO");
String query="update Object set"
+ " rpstryId = '" + obj.getRpstryId() + "',"
+ " objId='"+ obj.getObjId() + "',"
+ " objIdCntxtCd='"+ obj.getObjIdCntxtCd() + "',"
+ " objTypId='"+ obj.getObjTypId() + "',"
+ " objNm='"+ obj.getObjNm() + "',"
+ " objDesc='"+ obj.getObjId() + "',"
+ " objId='"+ obj.getObjDesc() + "' upsert where"
+ " objId='"+ obj.getObjId() + "'";
System.out.println(query);
db.command(new OCommandSQL(query)).execute();
db.close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
}