@Override public void rollback() { delegate.rollback(); }
@Override public void rollback(boolean force) { delegate.rollback(force); }
@Override public void doClose() { // rollback when session is dirty so that no statement leaks from one use of the DbSession to another // super.close() would do such rollback before actually closing **if autocommit is true** // we are going to assume autocommit is true and keep this behavior if (dirty) { getDelegate().rollback(); } }
@Test public void openSession_with_caching_returns_DbSession_that_does_not_roll_back_on_close_if_any_mutation_call_was_followed_by_rollback_with_parameters() throws SQLException { boolean force = random.nextBoolean(); DbSession dbSession = openSessionAndDoSeveralMutatingAndNeutralCalls(); dbSession.rollback(force); dbSession.close(); verify(myBatisDbSession, times(1)).rollback(force); verify(myBatisDbSession, times(0)).rollback(); }
@After public void deleteData() { dbSession.rollback(); }
@Test public void openSession_with_caching_returns_DbSession_that_does_not_roll_back_on_close_if_any_mutation_call_was_followed_by_rollback_without_parameters() throws SQLException { DbSession dbSession = openSessionAndDoSeveralMutatingAndNeutralCalls(); dbSession.rollback(); dbSession.close(); verify(myBatisDbSession, times(1)).rollback(); }
@Override protected void after() { if (session != null) { session.rollback(); session.close(); } db.stop(); started = false; }
@Test public void openSession_with_caching_returns_DbSession_that_does_not_roll_back_on_close_if_any_mutation_call_was_followed_by_commit() throws SQLException { DbSession dbSession = openSessionAndDoSeveralMutatingAndNeutralCalls(); COMMIT_CALLS[random.nextBoolean() ? 0 : 1].consume(dbSession); dbSession.close(); verify(myBatisDbSession, times(0)).rollback(); }
@Test public void openSession_with_caching_returns_DbSession_that_rolls_back_on_close_if_any_mutation_call_was_not_followed_by_commit_nor_rollback() throws SQLException { DbSession dbSession = openSessionAndDoSeveralMutatingAndNeutralCalls(); dbSession.close(); verify(myBatisDbSession).rollback(); }
protected void remove(DbSession dbSession, CeQueueDto queueDto, CeActivityDto activityDto) { String taskUuid = queueDto.getUuid(); CeQueueDto.Status expectedQueueDtoStatus = queueDto.getStatus(); dbClient.ceActivityDao().insert(dbSession, activityDto); dbClient.ceTaskInputDao().deleteByUuids(dbSession, singleton(taskUuid)); int deletedTasks = dbClient.ceQueueDao().deleteByUuid(dbSession, taskUuid, new DeleteIf(expectedQueueDtoStatus)); if (deletedTasks == 1) { dbSession.commit(); } else { Loggers.get(CeQueueImpl.class).debug( "Remove rolled back because task in queue with uuid {} and status {} could not be deleted", taskUuid, expectedQueueDtoStatus); dbSession.rollback(); } }
@Override public void rollback() { super.rollback(); reset(); }
@Override public void rollback(boolean force) { super.rollback(force); reset(); }