@Override public synchronized <R> R inTransaction(final InTransaction<R> operation) { closeRunners(); final R result; boolean ok = false; beginTransaction(); try { result = operation.run(this); commit(); ok = true; } finally { closeRunners(); if (!ok) { rollback(); } } return result; }
@NotNull @Override public synchronized <S> BaseQueryRunner<S> query(@NotNull final String queryText, @NotNull final ResultLayout<S> layout) { SqlQuery<S> query = new SqlQuery<S>(queryText, layout); return this.query(query); }
@Override public <R> R inSession(final InSession<R> operation) { if (operation == null) throw new IllegalArgumentException("The operation is null"); if (!isConnected()) throw new DBIsNotConnected("Facade is not connected."); final R result; final IntegralIntermediateSession interSession = instantiateIntermediateSession(); try { final BaseSession session = new BaseSession(interSession); result = operation.run(session); session.closeRunners(); } finally { interSession.close(); } return result; }
/** * Wraps the given integral intermediate session with a new instance of DBSession. * @param intermediateSession an intermediate session to wrap. * @return new instance of DBSession. */ @NotNull public static DBLeasedSession wrap(@NotNull final IntegralIntermediateSession intermediateSession) { if (intermediateSession.isClosed()) throw new DBSessionIsClosedException("The session is closed."); return new BaseSession(intermediateSession); }
public synchronized void close() { closeRunners(); myInterSession.close(); }
@Override public void inSession(final InSessionNoResult operation) { if (operation == null) return; if (!isConnected()) throw new DBIsNotConnected("Facade is not connected."); final IntegralIntermediateSession interSession = instantiateIntermediateSession(); try { final BaseSession session = new BaseSession(interSession); operation.run(session); session.closeRunners(); } finally { interSession.close(); } }
@Override public synchronized DBLeasedSession leaseSession() { final IntegralIntermediateSession interSession = instantiateIntermediateSession(); final BaseSession baseSession = new BaseSession(interSession); return new DBLeasedSessionWrapper(baseSession); }
@Override public synchronized void inTransaction(final InTransactionNoResult operation) { closeRunners(); boolean ok = false; beginTransaction(); try { operation.run(this); commit(); ok = true; } finally { closeRunners(); if (!ok) { rollback(); } } }