Spring Neo4j Rest中的事务管理
我正在使用spring-data-neo4j-rest框架访问远程服务器上的neo4j rest。使用此工具时如何管理事务 我的代码是这样的。 如果query2失败,有没有办法回滚query1Spring Neo4j Rest中的事务管理,neo4j,spring-data-neo4j,graph-databases,Neo4j,Spring Data Neo4j,Graph Databases,我正在使用spring-data-neo4j-rest框架访问远程服务器上的neo4j rest。使用此工具时如何管理事务 我的代码是这样的。 如果query2失败,有没有办法回滚query1 Transaction tx = neo4jTemplate.getGraphDatabase().beginTx(); try { Result<Map<String, Object>> results1 = neoTemplate.query(query1, null)
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();
}
使用@Transactional
最后你错过了tx.close
您需要在配置中将3.3.x与SpringCypherRestGraphDatabase一起使用