diff --git a/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/request/BoltRequest.java b/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/request/BoltRequest.java index ba7ac7e890..3868a6ac28 100644 --- a/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/request/BoltRequest.java +++ b/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/request/BoltRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2016 "Neo Technology," + * Copyright (c) 2002-2017 "Neo Technology," * Network Engine for Objects in Lund AB [http://neotechnology.com] * * This product is licensed to you under the Apache License, Version 2.0 (the "License"). @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.neo4j.driver.v1.StatementResult; import org.neo4j.driver.v1.exceptions.ClientException; +import org.neo4j.driver.v1.exceptions.ServiceUnavailableException; import org.neo4j.ogm.drivers.bolt.response.GraphModelResponse; import org.neo4j.ogm.drivers.bolt.response.GraphRowModelResponse; import org.neo4j.ogm.drivers.bolt.response.RestModelResponse; @@ -34,13 +35,7 @@ import org.neo4j.ogm.model.GraphRowListModel; import org.neo4j.ogm.model.RestModel; import org.neo4j.ogm.model.RowModel; -import org.neo4j.ogm.request.DefaultRequest; -import org.neo4j.ogm.request.GraphModelRequest; -import org.neo4j.ogm.request.GraphRowListModelRequest; -import org.neo4j.ogm.request.Request; -import org.neo4j.ogm.request.RestModelRequest; -import org.neo4j.ogm.request.RowModelRequest; -import org.neo4j.ogm.request.Statement; +import org.neo4j.ogm.request.*; import org.neo4j.ogm.response.EmptyResponse; import org.neo4j.ogm.response.Response; import org.neo4j.ogm.transaction.TransactionManager; @@ -161,6 +156,12 @@ private StatementResult executeRequest(Statement request) { return tx.nativeBoltTransaction().run(request.getStatement(), parameterMap); } catch (CypherException|ConnectionException ce) { throw ce; + } catch (ServiceUnavailableException ce) { + tx = (BoltTransaction) transactionManager.getCurrentTransaction(); + if (tx != null) { + tx.rollback(); + } + throw new ConnectionException("Unable to access the database " + ce.getMessage(), ce); } catch (ClientException ce) { tx = (BoltTransaction) transactionManager.getCurrentTransaction(); if (tx != null) {