当前位置: 首页>>代码示例>>Java>>正文


Java Transaction类代码示例

本文整理汇总了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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:24,代码来源:BusinessInvoiceAndPaymentDao.java

示例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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:17,代码来源:BusinessAccountDao.java

示例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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:22,代码来源:BusinessSubscriptionTransitionDao.java

示例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;
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:25,代码来源:DefaultTimelineDao.java

示例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;
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:25,代码来源:DefaultTimelineDao.java

示例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;
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:25,代码来源:DefaultTimelineDao.java

示例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);
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:9,代码来源:BusinessAnalyticsDaoBase.java

示例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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:16,代码来源:BusinessFieldDao.java

示例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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:16,代码来源:BusinessTagDao.java

示例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());
}
 
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:16,代码来源:BusinessAccountTransitionDao.java

示例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;
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:16,代码来源:DefaultTimelineDao.java


注:本文中的org.skife.jdbi.v2.Transaction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。