本文整理汇总了Java中org.skife.jdbi.v2.Transaction类的典型用法代码示例。如果您正苦于以下问题:Java Transaction类的具体用法?Java Transaction怎么用?Java Transaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transaction类属于org.skife.jdbi.v2包,在下文中一共展示了Transaction类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics invoices and payments for account " + businessContextFactory.getAccountId());
// Recompute the account record
final BusinessAccountModelDao bac = bacFactory.createBusinessAccount(businessContextFactory);
// Recompute invoice, invoice items and invoice payments records
final Map<UUID, BusinessInvoiceModelDao> invoices = new HashMap<UUID, BusinessInvoiceModelDao>();
final Multimap<UUID, BusinessInvoiceItemBaseModelDao> invoiceItems = ArrayListMultimap.<UUID, BusinessInvoiceItemBaseModelDao>create();
final Multimap<UUID, BusinessPaymentBaseModelDao> invoicePayments = ArrayListMultimap.<UUID, BusinessPaymentBaseModelDao>create();
createBusinessPojos(businessContextFactory, invoices, invoiceItems, invoicePayments);
// Delete and recreate all items in the transaction
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(bac, invoices, invoiceItems, invoicePayments, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics invoices and payments for account " + businessContextFactory.getAccountId());
}
示例2: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics account for account " + businessContextFactory.getAccountId());
// Recompute the account record
final BusinessAccountModelDao bac = bacFactory.createBusinessAccount(businessContextFactory);
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(bac, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics account for account " + businessContextFactory.getAccountId());
}
示例3: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics subscriptions for account " + businessContextFactory.getAccountId());
// Recompute the account record
final BusinessAccountModelDao bac = bacFactory.createBusinessAccount(businessContextFactory);
// Recompute all invoices and invoice items
final Collection<BusinessSubscriptionTransitionModelDao> bsts = bstFactory.createBusinessSubscriptionTransitions(businessContextFactory);
// Recompute the bundle summary records
final Collection<BusinessBundleModelDao> bbss = bbsFactory.createBusinessBundles(businessContextFactory, bsts);
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(bac, bbss, bsts, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics subscriptions for account " + businessContextFactory.getAccountId());
}
示例4: getOrAddSource
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
@Override
public int getOrAddSource(final String source, final CallContext context) throws UnableToObtainConnectionException, CallbackFailedException {
final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() {
@Override
public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception {
return getOrAddWithRetry(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
final MeterInternalTenantContext internalTenantContext = createInternalTenantContext(context);
final MeterInternalCallContext internalCallContext = createInternalCallContext(context);
Integer sourceId = transactional.getSourceRecordId(source, internalTenantContext);
if (sourceId == null) {
transactional.addSource(source, internalCallContext);
sourceId = transactional.getSourceRecordId(source, internalTenantContext);
}
return sourceId;
}
});
}
});
return result;
}
示例5: getOrAddEventCategory
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
@Override
public int getOrAddEventCategory(final String eventCategory, final CallContext context) throws UnableToObtainConnectionException, CallbackFailedException {
final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() {
@Override
public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception {
return getOrAddWithRetry(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
final MeterInternalTenantContext internalTenantContext = createInternalTenantContext(context);
final MeterInternalCallContext internalCallContext = createInternalCallContext(context);
Integer eventCategoryId = transactional.getCategoryRecordId(eventCategory, internalTenantContext);
if (eventCategoryId == null) {
transactional.addCategory(eventCategory, internalCallContext);
eventCategoryId = transactional.getCategoryRecordId(eventCategory, internalTenantContext);
}
return eventCategoryId;
}
});
}
});
return result;
}
示例6: getOrAddMetric
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
@Override
public synchronized int getOrAddMetric(final Integer eventCategoryId, final String metric, final CallContext context) throws UnableToObtainConnectionException, CallbackFailedException {
final Integer result = delegate.inTransaction(new Transaction<Integer, TimelineSqlDao>() {
@Override
public Integer inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception {
return getOrAddWithRetry(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
final MeterInternalTenantContext internalTenantContext = createInternalTenantContext(context);
final MeterInternalCallContext internalCallContext = createInternalCallContext(context);
Integer metricId = transactional.getMetricRecordId(eventCategoryId, metric, internalTenantContext);
if (metricId == null) {
transactional.addMetric(eventCategoryId, metric, internalCallContext);
metricId = transactional.getMetricRecordId(eventCategoryId, metric, internalTenantContext);
}
return metricId;
}
});
}
});
return result;
}
示例7: executeInTransaction
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void executeInTransaction(final Transaction<Void, BusinessAnalyticsSqlDao> transaction) {
// In REPEATABLE READ, every lock acquired during a transaction is held for the duration of the transaction.
// In READ COMMITTED the locks that did not match the scan are released after the STATEMENT completes.
// We need to make sure to use READ COMMITTED here, to avoid MySQL deadlocks under high load. This should
// not have any impact in these transactions as we only delete & re-insert rows on a per account basis,
// and accounts are not updated in parallel (not enforced, but we try hard not to).
sqlDao.inTransaction(TransactionIsolationLevel.READ_COMMITTED, transaction);
}
示例8: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics custom fields for account " + businessContextFactory.getAccountId());
final BusinessModelDaosWithAccountAndTenantRecordId<BusinessFieldModelDao> fieldModelDaos = bFieldFactory.createBusinessFields(businessContextFactory);
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(fieldModelDaos, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics custom fields for account " + businessContextFactory.getAccountId());
}
示例9: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics tags for account " + businessContextFactory.getAccountId());
final BusinessModelDaosWithAccountAndTenantRecordId<BusinessTagModelDao> tagModelDaos = bTagFactory.createBusinessTags(businessContextFactory);
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(tagModelDaos, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics tags for account " + businessContextFactory.getAccountId());
}
示例10: update
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
public void update(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
logService.log(LogService.LOG_DEBUG, "Starting rebuild of Analytics account transitions for account " + businessContextFactory.getAccountId());
final Collection<BusinessAccountTransitionModelDao> businessAccountTransitions = bosFactory.createBusinessAccountTransitions(businessContextFactory);
executeInTransaction(new Transaction<Void, BusinessAnalyticsSqlDao>() {
@Override
public Void inTransaction(final BusinessAnalyticsSqlDao transactional, final TransactionStatus status) throws Exception {
updateInTransaction(businessAccountTransitions, transactional, businessContextFactory.getCallContext());
return null;
}
});
logService.log(LogService.LOG_DEBUG, "Finished rebuild of Analytics account transitions for account " + businessContextFactory.getAccountId());
}
示例11: insertTimelineChunk
import org.skife.jdbi.v2.Transaction; //导入依赖的package包/类
@Override
public Long insertTimelineChunk(final TimelineChunk timelineChunk, final CallContext context) throws UnableToObtainConnectionException, CallbackFailedException {
final Long result = delegate.inTransaction(new Transaction<Long, TimelineSqlDao>() {
@Override
public Long inTransaction(final TimelineSqlDao transactional, final TransactionStatus status) throws Exception {
final MeterInternalTenantContext internalTenantContext = createInternalTenantContext(context);
final MeterInternalCallContext internalCallContext = createInternalCallContext(context);
transactional.insertTimelineChunk(timelineChunk, internalCallContext);
final long timelineChunkId = transactional.getLastInsertedRecordId(internalTenantContext);
return timelineChunkId;
}
});
return result;
}