我尝试添加嵌入式地图进行录制:
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"}
设置嵌入字段的正确语法是什么?
答案 0 :(得分:0)
我创建了一个具有属性名称(string)和fieldWithEmbeddedMap(embeddedMap)的类
我创建了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"
}
}
结果如下
希望它有所帮助。
修改强>
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