如何使用文档 api 在 OrientDB 中存储嵌入式地图?
How to store an embedded map in OrientDB with document api?
我试过:
Map<String, ODocument> myEntries = new HashMap<>();
//fill the map
...
doc.field("mymap", myEntries, OType.EMBEDDEDMAP);
但它给了我:
java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to java.util.List
我做错了什么?
我使用的是 OrientDb 2.1.11,它可以工作
ODatabaseDocumentTx db = new ODatabaseDocumentTx(path);
db.open("root","root");
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();
来自工作室
我试过:
Map<String, ODocument> myEntries = new HashMap<>();
//fill the map
...
doc.field("mymap", myEntries, OType.EMBEDDEDMAP);
但它给了我:
java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to java.util.List
我做错了什么?
我使用的是 OrientDb 2.1.11,它可以工作
ODatabaseDocumentTx db = new ODatabaseDocumentTx(path);
db.open("root","root");
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();
来自工作室