Search in sources :

Example 6 with ORecordSerializerBinary

use of com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary in project orientdb by orientechnologies.

the class SQLUpdateMapTest method testMapPut.

@Test
public void testMapPut() {
    ODatabaseDocument db = new ODatabaseDocumentTx("memory:" + SQLUpdateMapTest.class.getSimpleName());
    try {
        ((ODatabaseDocumentTx) db).setSerializer(new ORecordSerializerBinary());
        db.create();
        db.command(new OCommandSQL("create class vRecord")).execute();
        ODocument ret = db.command(new OCommandSQL("insert into vRecord (title) values('first record')")).execute();
        ODocument ret1 = db.command(new OCommandSQL("insert into vRecord (title) values('second record')")).execute();
        db.command(new OCommandSQL("update " + ret.getIdentity() + " put attrs = 'test1', " + ret1.getIdentity())).execute();
        db.close();
        db.open("admin", "admin");
        db.getLocalCache().clear();
        db.command(new OCommandSQL("update " + ret.getIdentity() + " put attrs = 'test', 'test value' ")).execute();
        ret.reload();
        assertEquals(2, ((Map) ret.field("attrs")).size());
        assertEquals("test value", ((Map) ret.field("attrs")).get("test"));
        assertEquals(ret1.getIdentity(), ((Map) ret.field("attrs")).get("test1"));
    } finally {
        db.drop();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) ORecordSerializerBinary(com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

ORecordSerializerBinary (com.orientechnologies.orient.core.serialization.serializer.record.binary.ORecordSerializerBinary)6 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)5 Test (org.testng.annotations.Test)3 OIntentMassiveInsert (com.orientechnologies.orient.core.intent.OIntentMassiveInsert)2 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)2 OrientMonoThreadTest (com.orientechnologies.orient.test.database.base.OrientMonoThreadTest)2 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 OSecurity (com.orientechnologies.orient.core.metadata.security.OSecurity)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 BeforeClass (org.testng.annotations.BeforeClass)1 BeforeMethod (org.testng.annotations.BeforeMethod)1