2016-02-25 25 views
0

我想:如何使用document API在OrientDB中存储嵌入式地图?

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不能转换到java.util中。列表

我在做什么错?

回答

4

我用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(); 

来自Studio

enter image description here

+0

这一切ok与orientdb,是我的错地方 – zella

相关问题