Orientdb 带OrientGraph的嵌套事务

Orientdb 带OrientGraph的嵌套事务,orientdb,Orientdb,我试图将嵌套事务与OrientGraph一起使用,但它似乎无法正常工作 我的设想是 function1(){ OrientGraph db = factory.openDatabase() ; // which will give active graph on current thread db.begin(); function2(); // save some data db.commit(); } function2(){ Ori

我试图将嵌套事务与OrientGraph一起使用,但它似乎无法正常工作 我的设想是

function1(){
    OrientGraph db = factory.openDatabase() ; // which will give active graph on current thread
    db.begin();

    function2();

    // save some data 
    db.commit();
}

function2(){

    OrientGraph db = factory.openDatabase() ; // which will give active graph on current thread
    db.begin();

    // save some data 

    db.commit(); // this commit is saving the data into db 

}
function2中的提交保存数据,但它是嵌套事务的一部分,应该在外部事务上发生提交时提交

我做错什么了吗

注意:我正在执行db.setautostartx(false);使其不会自动启动事务

编辑

在函数2之后尝试使用
db.getRawGraph().activateOnCurrentThread()

function1(){
    OrientGraph db = factory.openDatabase() ; // which will give active graph on current thread
    db.begin();

    function2();

    db.getRawGraph().activateOnCurrentThread();

    // save some data 
    db.commit();
}

您应该使用相同的数据库实例对象。
为了自动化这个过程(并提高性能),我建议您使用com.orientechnologies.orient.core.db.OPartitionedDatabasePool类。此外,我始终建议您使用此池,因为它可以最大限度地减少获取新集合所需的时间,并在多核H/w上很好地扩展。

不,它不起作用,因为没有db.activateOnCurrentThread();在OrientGraph上,我使用了db.getRawGraph().activateOnCurrentThread()是的,我使用的是OrientGraphFactory(它在内部创建OPartitionedDatabasePool),两个函数中的db实例是相同的,但嵌套事务功能仍然不起作用此处提供了示例代码,函数2中的提交提交在外部事务(函数1)中创建的数据。如果我做错了什么,请告诉我。非常感谢。如果我做这样的事情,它会起作用