OrientDB不一致的顶点在使用MMAPI删除边后保留
考虑以下代码:OrientDB不一致的顶点在使用MMAPI删除边后保留,orientdb,orientdb3.0,Orientdb,Orientdb3.0,考虑以下代码: private void testMMAPIinLab() { OrientDB orientDB = new OrientDB("remote:localhost",OrientDBConfig.defaultConfig()); OrientDBConfigBuilder poolCfg = OrientDBConfig.builder(); poolCfg.addConfig(OGlobalConfiguration.D
private void testMMAPIinLab() {
OrientDB orientDB = new OrientDB("remote:localhost",OrientDBConfig.defaultConfig());
OrientDBConfigBuilder poolCfg = OrientDBConfig.builder();
poolCfg.addConfig(OGlobalConfiguration.DB_POOL_MIN, 5);
poolCfg.addConfig(OGlobalConfiguration.DB_POOL_MAX, 10);
//poolCfg.addConfig(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD, -1);
ODatabasePool dbPool = new ODatabasePool(orientDB,"lab", "root", "toor", poolCfg.build());
ODatabaseSession db = dbPool.acquire();
db.begin();
System.out.println("creando el vértice....");
OVertex v1 = db.newVertex();
v1.save();
System.out.println("save rid: "+v1.getIdentity().toString());
OVertex v2 = db.newVertex();
v2.save();
System.out.println("v2 save rid: "+v2.getIdentity().toString());
System.out.println("crear un edge.");
OEdge oe = v1.addEdge(v2);
v1.save();
System.out.println("llamando a commit...");
db.commit();
db.close();
System.out.println("configuración grabada:");
System.out.println("v1: "+v1.getIdentity().toString());
System.out.println("v2: "+v2.getIdentity().toString());
System.out.println("edge: "+oe.getFrom()+" --> "+oe.getTo());
// abrir otra transacción
db = dbPool.acquire();
db.begin();
System.out.println("crear v3");
OVertex v3 = db.newVertex();
v3.save();
System.out.println("v3 save rid: "+v3.getIdentity().toString());
System.out.println("modificar v1...");
v1.setProperty("value", "test");
System.out.println("borrar relación con v2");
// borrar el edge anterior
Iterator<OEdge> toRemove = v1.getEdges(ODirection.OUT).iterator();
while (toRemove.hasNext()) {
OEdge removeEdge = toRemove.next();
//removeEdge = (OEdge) edge;
removeEdge.delete();
removeEdge.save();
}
System.out.println("agregar una relación de v1 a v3");
OEdge oe2 = v1.addEdge(v3);
v1.save();
// crera en edge nuevo a v3
db.commit();
System.out.println("v1 edges: "+v1.getEdges(ODirection.OUT));
System.out.println("v3 post-commit rid: "+v3.getIdentity().toString());
System.out.println("oe2: "+oe2.getFrom()+" --> "+oe2.getTo());
db.close();
}
private void testMMAPIinLab(){
OrientDB OrientDB=新的OrientDB(“远程:本地主机”,OrientDBConfig.defaultConfig());
OrientDBConfigBuilder poolCfg=OrientDBConfig.builder();
poolCfg.addConfig(OGlobalConfiguration.DB\u POOL\u MIN,5);
poolCfg.addConfig(OGlobalConfiguration.DB_POOL_MAX,10);
//poolCfg.addConfig(OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD,-1);
ODatabasePool dbPool=新的ODatabasePool(orientDB,“lab”,“root”,“toor”,poolCfg.build());
ODatabaseSession db=dbPool.acquire();
db.begin();
System.out.println(“creando el vértice…”);
OVertex v1=db.newVertex();
v1.save();
System.out.println(“保存rid:+v1.getIdentity().toString());
OVertex v2=db.newVertex();
v2.save();
System.out.println(“v2 save rid:+v2.getIdentity().toString());
System.out.println(“crear-un-edge”);
OEdge oe=v1.加差(v2);
v1.save();
System.out.println(“llamando a commit…”);
db.commit();
db.close();
System.out.println(“configuración grabada:”);
System.out.println(“v1:+v1.getIdentity().toString());
System.out.println(“v2:+v2.getIdentity().toString());
System.out.println(“边缘:+oe.getFrom()+”-->“+oe.getTo());
//阿布里尔·奥特拉·transacción
db=dbPool.acquire();
db.begin();
System.out.println(“crear v3”);
OVertex v3=db.newVertex();
v3.save();
System.out.println(“v3保存rid:+v3.getIdentity().toString());
System.out.println(“modificar v1…”);
v1.设置属性(“值”、“测试”);
System.out.println(“borrar relación con v2”);
//前边缘
迭代器toRemove=v1.getEdges(ODirection.OUT).Iterator();
while(toRemove.hasNext()){
OEdge removeEdge=toRemove.next();
//removeEdge=(OEdge)边;
removedge.delete();
removedge.save();
}
System.out.println(“agregar una relación de v1 a v3”);
OEdge oe2=v1.加差(v3);
v1.save();
//crera en edge新锐a v3
db.commit();
System.out.println(“v1边缘:+v1.getEdges(ODirection.out));
System.out.println(“v3 post-commit-rid:+v3.getIdentity().toString());
System.out.println(“oe2:+oe2.getFrom()+”-->“+oe2.getTo());
db.close();
}
当你运行它时,你会得到一个有两条边的V1。一个带有删除边的EdgeRID,另一个指向V3。
我在删除的边上单击它显示{},并报告404错误。顶点被持久化,因此错误在数据库中
错误出现在删除边的过程中。如果使用边引用,它可以工作,但在实际代码中,我不知道顶点有多少条边
V2和V3在引用中具有正确的格式
如何修复此问题?这取决于不同数据库会话之间共享顶点的事实 一个简单的修复方法是在第二个会话中使用顶点之前,按ID重新加载顶点:
// abrir otra transacción
db = dbPool.acquire();
db.begin();
//RELOAD THE VERTEX BEFORE USING IT AGAIN!
v1 = db.load(v1.getIdentity());