I am using spring-data-neo4j-rest framework to access Neo4j Rest APIs(hosted on a remote server). How can I manage transaction while using this?
我使用spring-data-neo4j-rest框架来访问Neo4j Rest API(托管在远程服务器上)。如何在使用时管理交易?
My code is something like this. If query2 is failing, is there any way that I can rollback query1.
我的代码是这样的。如果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();
}
1 个解决方案
#1
Use @Transactional You missed tx.close() at the end
使用@Transactional你最后错过了tx.close()
You need to use 3.3.x with SpringCypherRestGraphDatabase in your config
您需要在配置中使用带有SpringCypherRestGraphDatabase的3.3.x.
#1
Use @Transactional You missed tx.close() at the end
使用@Transactional你最后错过了tx.close()
You need to use 3.3.x with SpringCypherRestGraphDatabase in your config
您需要在配置中使用带有SpringCypherRestGraphDatabase的3.3.x.