Guice-persist extension for using jOOQ based persistence layer
Latest commit 9275955 Jan 20, 2017 @supercargo committed on GitHub Updated notes for latest release
Failed to load latest commit information.

Guice Persist / jOOQ Integration

A simple integration between Guice's persistence extensions and jOOQ. Follows closely in the pattern of the JPA persistence extension written by Dhanji R. Prasanna (

Maven Coordinates

The project is deployed to Maven Central:


Basic Usage

See Guice Persist and Transactions and Units of Work for a reference on the basic semantics of the Guice Persist extension.

In your module, install a new com.adamlewis.guice.persist.jooq.JooqPersistModule and then provide bindings for javax.sql.DataSource and org.jooq.SQLDialect. Optionally, a binding for org.jooq.Configuration can be provided, to customize the creation of the org.jooq.DSLContext instance. Then write @Injectable DAOs which depend on org.jooq.DSLContext.


Here is an example Guice module written to connect guice-persist-jooq up to the Dropwizard connection factory:

import javax.sql.DataSource;

import org.jooq.SQLDialect;

import com.adamlewis.guice.persist.jooq.JooqPersistModule;
import com.yammer.dropwizard.db.DatabaseConfiguration;
import com.yammer.dropwizard.db.ManagedDataSource;
import com.yammer.dropwizard.db.ManagedDataSourceFactory;

public class MyPersistenceModule extends AbstractModule {

	private final DatabaseConfiguration configuration;
	public MyPersistenceModule(final DatabaseConfiguration configuration) {
		this.configuration = configuration;
	protected void configure() {
		install(new JooqPersistModule());

	@Provides ManagedDataSource dataSource(final ManagedDataSourceFactory factory) throws ClassNotFoundException {
	public SQLDialect dialect() {
		//TODO read from DB configuration
		return SQLDialect.POSTGRES;
	// Optional, for full customization of the creation.
	public Configuration configuration(DataSource dataSource, SQLDialect dialect) {
	        return new DefaultConfiguration()
                    .set(new MaybeCustomMapperProvider())

And here is an example of what a DAO might look like:

public class UserDao {

	private final DSLContext create;
	public UserDao(final DSLContext dsl) {
		this.create = dsl;
	public List<String> getUsernames() {
		return create.selectDistinct(User.USER.NAME).from(User.USER).fetch(User.USER.NAME);