如何在OrientDb中使用sql添加嵌入式地图进行记录

时间:2016-03-23 12:39:07

标签: orientdb

我尝试添加嵌入式地图进行录制:

UPDATE #12:6941 set fieldWithEmbeddedMap ={
    "1": {
        "@type": "d",
        "@version": 0,
        "@class": "myClass",
        "myFiled": "ok"
    },
    "2": {
        "@type": "d",
        "@version": 0,
        "@class": "myClass",
        "myFiled": "ok"
    }
}

但结果是

{"1":"#17:9","2":"#17:10"}

设置嵌入字段的正确语法是什么?

1 个答案:

答案 0 :(得分:0)

我创建了一个具有属性名称(string)和fieldWithEmbeddedMap(embeddedMap)的类

enter image description here

我创建了Class2

类型的记录
insert into class2(name) values ("Alessandro")  // 14:0

在我使用你的代码之后

UPDATE #14:0 set fieldWithEmbeddedMap ={
    "1": {
        "@type": "d",
        "@version": 0,
        "@class": "myClass",
        "myFiled": "ok"
    },
    "2": {
        "@type": "d",
        "@version": 0,
        "@class": "myClass",
        "myFiled": "ok"
    }
}

结果如下

enter image description here

希望它有所帮助。

修改

Java代码

Map<String, Object> myEntries = new HashMap<String, Object>();
myEntries.put("key1",1);
myEntries.put("key2",2);
myEntries.put("key3",3);

ODocument doc = new ODocument("Test");
doc.field("mymap", myEntries, OType.EMBEDDEDMAP);
doc.save();

来自Studio

enter image description here

enter image description here