use of org.neo4j.driver.v1.exceptions.TransientException in project structr by structr.
the class SessionTransaction method getStrings.
public QueryResult<String> getStrings(final String statement, final Map<String, Object> map) {
final long t0 = System.currentTimeMillis();
try {
final StatementResult result = tx.run(statement, map);
final Record record = result.next();
final Value value = record.get(0);
return new QueryResult<String>() {
@Override
public void close() {
result.consume();
}
@Override
public Iterator<String> iterator() {
return value.asList(Values.ofString()).iterator();
}
};
} catch (TransientException tex) {
closed = true;
throw new RetryException(tex);
} catch (NoSuchRecordException nex) {
throw new NotFoundException(nex);
} catch (ServiceUnavailableException ex) {
throw new NetworkException(ex.getMessage(), ex);
} finally {
logQuery(statement, map, t0);
}
}
use of org.neo4j.driver.v1.exceptions.TransientException in project structr by structr.
the class SessionTransaction method close.
@Override
public void close() {
if (!success) {
// be sure that they contain the correct values after a rollback.
for (final EntityWrapper entity : modifiedEntities) {
entity.stale();
}
} else {
// so that the relationship caches are rebuilt.
for (final EntityWrapper entity : modifiedEntities) {
entity.clearCaches();
}
}
// mark this transaction as closed BEFORE trying to actually close it
// so that it is closed in case of a failure
closed = true;
try {
tx.close();
session.close();
} catch (TransientException tex) {
// transient exceptions can be retried
throw new RetryException(tex);
} finally {
// so that the relationship caches are rebuilt.
for (final EntityWrapper entity : modifiedEntities) {
entity.onClose();
}
// make sure that the resources are freed
if (session.isOpen()) {
session.close();
}
}
}
Aggregations