Search in sources :

Example 1 with DefaultTransactionProvider

use of org.jooq.impl.DefaultTransactionProvider in project keywhiz by square.

the class ServiceModule method readonlyJooqContext.

@Provides
@Singleton
@Readonly
DSLContext readonlyJooqContext(@Readonly ManagedDataSource dataSource) throws SQLException {
    DSLContext dslContext = DSLContexts.databaseAgnostic(dataSource);
    org.jooq.Configuration configuration = dslContext.configuration();
    // Disable support for nested transactions via savepoints (required for MySQL)
    // See: https://groups.google.com/forum/#!topic/jooq-user/zG0U6CkxI5o
    configuration.set(new DefaultTransactionProvider(configuration.connectionProvider(), false));
    return dslContext;
}
Also used : DefaultTransactionProvider(org.jooq.impl.DefaultTransactionProvider) DSLContext(org.jooq.DSLContext) Readonly(keywhiz.service.config.Readonly) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Readonly (keywhiz.service.config.Readonly)1 DSLContext (org.jooq.DSLContext)1 DefaultTransactionProvider (org.jooq.impl.DefaultTransactionProvider)1