Search in sources :

Example 1 with EntityWrapper

use of org.structr.bolt.wrapper.EntityWrapper 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();
        }
    }
}
Also used : TransientException(org.neo4j.driver.v1.exceptions.TransientException) EntityWrapper(org.structr.bolt.wrapper.EntityWrapper) RetryException(org.structr.api.RetryException)

Aggregations

TransientException (org.neo4j.driver.v1.exceptions.TransientException)1 RetryException (org.structr.api.RetryException)1 EntityWrapper (org.structr.bolt.wrapper.EntityWrapper)1