Neo4J创建关系在远程挂起,但节点创建成功

时间:2013-02-17 20:06:55

标签: java neo4j

我的关系创建挂起,但下面的节点设法保留到我的远程客户端。

public class Baz 
{  
    private static enum CustomRelationships implements RelationshipType {
        CATEGORY
    }

     public void foo()  
     {    
         RestGraphDatabse db = new RestGraphDatabase("http://remoteIp:7474/db/data",username,password);
         Transaction tx = db.beginTx();
         try{  
         Node a = db.createNode();
            a.setProperty("foo", "foo");  // finishes
            Node b = db.createNode();
            b.setProperty("bar", "bar"); //finishes
            a.createRelationshipTo(b, CustomRelationships .CATEGORY); // hangs
            System.out.println("Finished relationship");
            tx.success();
        } finally {
            tx.finish();
        }
     }  
}  

我无法弄清楚原因。没有堆栈,连接没有超时。

a.createRelationshipTo(b, DynamicRelationshipType.withName("CATEGORY"));

也挂起

此查询从管理员shell正确执行:

  

start first = node(19),second = node(20)first first- [r:RELTYPE {   联系:first.Baz +'< - >' + second.BazCat}] - >第二次返回r

然而,当以这种方式运行时:

ExecutionResult result = engine.execute("start first=node("
                    + entityNode.getId() + "), second=node("
                    + categoryNode.getId() + ") "
                    + " Create first-[r:RELTYPE { linkage : first.Baz"
                    + " + '<-->' +  second.BazCat" + " }]->second return r");

还挂了。

1 个答案:

答案 0 :(得分:1)

  1. 休息时没有真正的交易。
  2. Java-Rest-Binding中的一个错误是内部线程未作为守护程序线程启动。它实际上并没有挂起只是程序没有结束。 您可以System.exit(0)结束程序作为解决方法。