private void deleteAnalysisDuplications(List<List<String>> snapshotUuidsPartitions) { profiler.start("deleteAnalysisDuplications (duplications_index)"); snapshotUuidsPartitions.forEach(purgeMapper::deleteAnalysisDuplications); session.commit(); profiler.stop(); }
@Override public Connection getConnection() { return delegate.getConnection(); }
private static void flushSession(DbSession dbSession) { dbSession.flushStatements(); dbSession.commit(); }
dbSession.rollback(); verify(myBatisDbSession).rollback(); }); verifyDelegation(batchOrRegular, (myBatisDbSession, dbSession) -> { boolean flag = random.nextBoolean(); dbSession.rollback(flag); verify(myBatisDbSession).rollback(flag); }); dbSession.commit(); verify(myBatisDbSession).commit(); }); verifyDelegation(batchOrRegular, (myBatisDbSession, dbSession) -> { boolean flag = random.nextBoolean(); dbSession.commit(flag); verify(myBatisDbSession).commit(flag); }); dbSession.selectOne(str); verify(myBatisDbSession).selectOne(str); }); verifyDelegation(batchOrRegular, (myBatisDbSession, dbSession) -> { String str = randomAlphabetic(10); Object object = new Object(); dbSession.selectOne(str, object); verify(myBatisDbSession).selectOne(str, object); }); dbSession.selectList(str);
/** * Remove a group from all templates (used when removing a group) */ public void deleteByGroup(DbSession session, int groupId) { session.getMapper(PermissionTemplateMapper.class).deleteByGroupId(groupId); }
@Override public void execute() { try (DbSession dbSession = dbClient.openSession(true); CloseableIterator<DefaultIssue> issues = issueCache.traverse()) { IssueMapper mapper = dbSession.getMapper(IssueMapper.class); IssueChangeMapper changeMapper = dbSession.getMapper(IssueChangeMapper.class); while (issues.hasNext()) { DefaultIssue issue = issues.next(); boolean saved = persistIssueIfRequired(mapper, issue); if (saved) { IssueStorage.insertChanges(changeMapper, issue); } } dbSession.flushStatements(); dbSession.commit(); } }
public void close(ThreadLocal<DelegatingDbSessionSupplier> dbSessionThreadLocal, String label) { DelegatingDbSessionSupplier delegatingDbSessionSupplier = dbSessionThreadLocal.get(); boolean getCalled = delegatingDbSessionSupplier.isPopulated(); if (getCalled) { try { DbSession res = delegatingDbSessionSupplier.get(); res.close(); } catch (Exception e) { LOG.error(format("Failed to close %s connection in %s", label, currentThread()), e); } } }
@Test public void unzip_report() throws Exception { logTester.setLevel(LoggerLevel.DEBUG); File reportFile = generateReport(); try (InputStream input = FileUtils.openInputStream(reportFile)) { dbTester.getDbClient().ceTaskInputDao().insert(dbTester.getSession(), TASK_UUID, input); } dbTester.getSession().commit(); dbTester.getSession().close(); underTest.execute(new TestComputationStepContext()); // directory contains the uncompressed report (which contains only metadata.pb in this test) File unzippedDir = reportDirectoryHolder.getDirectory(); assertThat(unzippedDir).isDirectory().exists(); assertThat(unzippedDir.listFiles()).hasSize(1); assertThat(new File(unzippedDir, "metadata.pb")).hasContent("{metadata}"); assertThat(logTester.logs(LoggerLevel.DEBUG)).anyMatch(log -> log.matches("Analysis report is \\d+ bytes uncompressed")); }
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(); } }
@Test public void shouldOpenBatchSession() { underTest.start(); try (DbSession session = underTest.openSession(false)) { assertThat(session.getConnection(), notNullValue()); assertThat(session.getMapper(RuleMapper.class), notNullValue()); } } }
@Override public void select(String statement, Object parameter, ResultHandler handler) { delegate.select(statement, parameter, handler); }
@Override public void rollback(boolean force) { delegate.rollback(force); }
@Override public List<BatchResult> flushStatements() { return delegate.flushStatements(); }
public void deleteIfKeyNotIn(DbSession dbSession, Collection<String> keys) { checkArgument(keys.size() < DatabaseUtils.PARTITION_SIZE_FOR_ORACLE, "too many rule repositories: %s", keys.size()); dbSession.getMapper(RuleRepositoryMapper.class).deleteIfKeyNotIn(keys); } }
@Override public void close() { try { iterator.close(); } finally { DatabaseUtils.closeQuietly(stmt); session.close(); } }
@Override public void select(String statement, ResultHandler handler) { delegate.select(statement, handler); }
@Override public void rollback() { delegate.rollback(); }