Initially the db saves the contents of tyrionDoc properly after the 
fromJSON method.  However, the query returns a document with modified 
values in the contact field.  Specifically, the contact value included the 
rid of another document, and is replaced by the values of the document but 
no longer contains the rid of the document. It is not clear what is trigger 
the data modification.

import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import java.util.List;


class InnerDoc {

public static void main(String[] args) {

ODatabaseDocumentTx db = new ODatabaseDocumentTx(
"remote:localhost/amazingorient");
db.open("admin", "admin");

ODocument jaimeDoc = new ODocument("PersonTest");
jaimeDoc.field("name", "jaime");
jaimeDoc.save();

ODocument tyrionDoc = new ODocument("PersonTest");
tyrionDoc
.fromJSON("{\"@type\":\"d\",\"name\":\"tyrion\",\"emergency_contact\":[{\"relationship\":\"brother\",\"contact\":"
+ jaimeDoc.toJSON() + "}]}");
tyrionDoc.save();

System.out.println(db.load(tyrionDoc.getIdentity()).toJSON());

List<ODocument> result = db.query(
      new OSQLSynchQuery<ODocument>("select from " + 
tyrionDoc.getIdentity()));

System.out.println(result.get(0).toJSON());
 db.close();

}
}

-- 

--- 
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.

Reply via email to