Reputation: 4685
I try to add embedded map to record:
UPDATE #12:6941 set fieldWithEmbeddedMap ={
"1": {
"@type": "d",
"@version": 0,
"@class": "myClass",
"myFiled": "ok"
},
"2": {
"@type": "d",
"@version": 0,
"@class": "myClass",
"myFiled": "ok"
}
}
But result is
{"1":"#17:9","2":"#17:10"}
What is correct syntax to set embedded field?
Upvotes: 1
Views: 1210
Reputation: 3570
I have created a class with the property name(string) and fieldWithEmbeddedMap(embeddedMap)
I have create a record of type Class2
insert into class2(name) values ("Alessandro") // 14:0
and after I have used your code
UPDATE #14:0 set fieldWithEmbeddedMap ={
"1": {
"@type": "d",
"@version": 0,
"@class": "myClass",
"myFiled": "ok"
},
"2": {
"@type": "d",
"@version": 0,
"@class": "myClass",
"myFiled": "ok"
}
}
The result is the following
Hope it helps.
EDIT
Java code
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();
From Studio
Upvotes: 1