我创建了一个数据库...
ODatabaseObjectTx db = new ODatabaseObjectTx("memory:testt").create();
db.getEntityManager().registerEntityClass(Vertex.class);
db.getEntityManager().registerEntityClass(Edge.class);
db.getEntityManager().registerEntityClass(ChemicalGraph.class);
db.getEntityManager().registerEntityClass(Subgraph.class);
ChemicalGraph
包含String
,ArrayList<object>
,ArrayList<Object>
,并且在将其保存在db中时可以。但它对Subgraph不起作用。
ChemicalGraph类是......
这是子图类
import java.util.ArrayList;
public class Subgraph {
public String gid = "";
public int numV = 0;
public int numE = 0;
public ArrayList<ArrayList<Edge>> sgList = new ArrayList<ArrayList<Edge>>();
public Subgraph()
{
}
public Subgraph(ChemicalGraph g)
{
gid = g.gid;
numV = g.vertices.size();
numE = g.edges.size();
sgList = g.decomposite();
}
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append("Gid = ").append(gid).append(", ");
sb.append("NumV =").append(numV).append(", ");
sb.append("NumE=").append(numE).append(", ");
sb.append("SubgraphList=").append(sgList.toString()).append(" ");
return sb.toString();
}
}
我将其保存在数据库中
Subgraph s = new Subgraph(graph);
db.save(s);
我收到了以下错误
Exception in thread "main" java.lang.IllegalArgumentException: Type LINK must be a multi value type (collection or map)
at com.orientechnologies.orient.core.serialization.serializer.object.OObjectSerializerHelper.multiValueToStream(OObjectSerializerHelper.java:752)
at com.orientechnologies.orient.core.serialization.serializer.object.OObjectSerializerHelper.typeToStream(OObjectSerializerHelper.java:654)
at com.orientechnologies.orient.core.serialization.serializer.object.OObjectSerializerHelper.multiValueToStream(OObjectSerializerHelper.java:763)
at com.orientechnologies.orient.core.serialization.serializer.object.OObjectSerializerHelper.typeToStream(OObjectSerializerHelper.java:654)
at com.orientechnologies.orient.core.serialization.serializer.object.OObjectSerializerHelper.toStream(OObjectSerializerHelper.java:577)
at com.orientechnologies.orient.core.db.object.ODatabaseObjectTx.pojo2Stream(ODatabaseObjectTx.java:435)
at com.orientechnologies.orient.core.db.object.ODatabaseObjectTx.save(ODatabaseObjectTx.java:226)
at com.orientechnologies.orient.core.db.object.ODatabaseObjectTx.save(ODatabaseObjectTx.java:200)