Java 类org.jooq.TransactionalRunnable 实例源码

项目:killbill-easytax-plugin    文件:JooqEasyTaxDao.java   
@Override
public void saveTaxCodes(final Iterable<EasyTaxTaxCode> taxCodes) throws SQLException {
    final DateTime now = new DateTime();
    execute(dataSource.getConnection(), new WithConnectionCallback<Void>() {
        @Override
        public Void withConnection(final Connection conn) throws SQLException {
            DSL.using(conn, dialect, settings).transaction(new TransactionalRunnable() {
                @Override
                public void run(final Configuration configuration) throws Exception {
                    final DSLContext dslContext = DSL.using(configuration);
                    for (EasyTaxTaxCode taxCode : taxCodes) {
                        DateTime date = taxCode.getCreatedDate() != null
                                ? taxCode.getCreatedDate()
                                : now;
                        saveTaxCodeInternal(taxCode, date, dslContext);
                    }
                }
            });
            return null;
        }
    });
}