在Java HashMap中获取LINKMAP属性的内容

在Java HashMap中获取LINKMAP属性的内容,java,orientdb,Java,Orientdb,我正在尝试使用链接映射属性 假设我们有如下Vertex口袋妖怪大师 PokemonMaster { name, (STRING) age, (INTEGER) pokemons, (LINKMAP) of Pokemon } 包含口袋妖怪的链接地图 Pokemon { name, (STRING) } 下面的代码正在创建一个PokemonMaster,给他一些Pokemon: Map<String, ODocument> pokemons = new HashMap&l

我正在尝试使用链接映射属性

假设我们有如下Vertex口袋妖怪大师

PokemonMaster
{
 name, (STRING)
 age, (INTEGER)
 pokemons, (LINKMAP) of Pokemon
}
包含口袋妖怪的链接地图

Pokemon
{
  name, (STRING)
}
下面的代码正在创建一个PokemonMaster,给他一些Pokemon:

Map<String, ODocument> pokemons = new HashMap<>();
ODocument pikachu = new ODocument("Pokemon");
pikachu.field("name", "Pikachu");
pikachu.save();
ODocument raichu = new ODocument("Pokemon");
raichu.field("name", "Raichu");
raichu.save();
pokemons.put("pikachu", pikachu);
pokemons.put("raichu", raichu);
graph.addVertex("class:PokemonMaster", "name", "Sacha", "age", "42", "pokemons", pokemons);
对萨迦来说,15:42和15:43是皮卡丘和莱丘的山脉

我的问题是: 我无法将此映射转换为Java HashMap

我的意思是,我希望能够做到:

{"pikachu":"#15:42","raichu":"#15:43"}
Vertex v = graph.getVertex(id); // getting the instance of Sacha
Map<String, ODocument> map = v.getProperty("pokemons");
System.out.println(map.get("pikachu").getIdentity());
System.out.println(map.get("raichu").getIdentity());
因此,我尝试了如下定向:

Vertex v = graph.getVertex(id); // getting the instance of Sacha
OrientElementIterable<Element> test = v.getProperty("pokemons");
for (Element elem : test) {
 System.out.println(elem.getProperty("name"));
}
然后我们可以很容易地得到地图:

Map<String, ORecordId> map = doc.field("pokemons");
Map=doc.field(“口袋妖怪”);

然后,密钥包含口袋妖怪的名称,该值表示其实例的id。

谢谢!以类似的方式,它可以用于链接列表和其他链接类型的此解决方案。
Vertex v = graph.getVertex(id); // getting the instance of Sacha
OrientElementIterable<Element> test = v.getProperty("pokemons");
for (Element elem : test) {
 System.out.println(elem.getProperty("name"));
}
ODocument doc = new ODocument(new ORecordId(v.getId().toString()));
Map<String, ORecordId> map = doc.field("pokemons");