public T delegateWork()

in neo4j/src/main/java/org/hibernate/ogm/datastore/neo4j/remote/bolt/transaction/impl/BoltNeo4jResourceLocalTransactionCoordinator.java [144:181]


		public <T> T delegateWork(WorkExecutorVisitable<T> work, boolean transacted) throws HibernateException {
			if ( !transacted ) {
				log.cannotExecuteWorkOutsideIsolatedTransaction();
			}
			Driver dataBase = ( (BoltNeo4jClient) provider.getClient() ).getDriver();
			Session session = null;
			try {
				session = dataBase.session();
				Transaction tx = session.beginTransaction();
				try {
					// Neo4j does not have a connection object, I'm not sure what it is best to do in this case.
					// In this scenario I expect the visitable object to already have a way to connect to the db.
					Connection connection = null;
					T result = work.accept( new WorkExecutor<T>(), connection );
					tx.success();
					tx.close();
					return result;
				}
				catch (Exception e) {
					try {
						tx.failure();
						tx.close();
					}
					catch (Exception re) {
						log.unableToRollbackTransaction( re );
					}
					if ( e instanceof HibernateException ) {
						throw (HibernateException) e;
					}
					else {
						throw log.unableToPerformIsolatedWork( e );
					}
				}
			}
			finally {
				close( session );
			}
		}