【问题标题】:Transaction Management in Spring Neo4j RestSpring Neo4j Rest 中的事务管理
【发布时间】:2015-07-25 01:17:46
【问题描述】:

我正在使用 spring-data-neo4j-rest 框架来访问 Neo4j Rest API(托管在远程服务器上)。使用时如何管理事务?

我的代码是这样的。 如果 query2 失败,有什么方法可以回滚 query1。

Transaction tx = neo4jTemplate.getGraphDatabase().beginTx();
try {
    Result<Map<String, Object>> results1 = neoTemplate.query(query1, null);
    Result<Map<String, Object>> results2 = neoTemplate.query(query2, null);
    Result<Map<String, Object>> results3 = neoTemplate.query(query3, null);
    tx.success();
}
catch(Exception e){
    tx.failure();
}

【问题讨论】:

    标签: neo4j spring-data-neo4j graph-databases


    【解决方案1】:

    使用@Transactional 你最后错过了 tx.close()

    您需要在配置中使用 3.3.x 和 SpringCypherRestGraphDatabase

    【讨论】:

      猜你喜欢
      • 2016-09-10
      • 1970-01-01
      • 2015-07-16
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      相关资源
      最近更新 更多