Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

README.md

Introduction

This is a rough stab at integrating JOOQ into Dropwizard, as an alternative to the recommended JDBI solution

Justification

JDBI works okay for simple queries like select id from person, but quickly becomes cumbersome when you want to create more complex queries with dynamic order by and where clauses.

Also the documentation for JDBI is thin on the ground and hard to dig through.

Status

This is very early code and has no unit tests right now. I would not recommend this for production code unless you really know what you are doing

Building

gradle clean jar

Optionally you can publish this to your local maven repo

gradle publishToMavenLocal

I currently have no idea how to get the JAR up to maven central.

Usage

In your application's run method (remember to change SQLDialect to your DBMS of choice if not using Postgres)

@Override
public void run(ExampleConfiguration config,
				Environment environment) throws ClassNotFoundException {
    final JooqDSLContextFactory dslContextFactory = new JooqDSLContextFactory();
    this.dslContext = dslContextFactory.build(environment, config.getDataSourceFactory(), SQLDialect.POSTGRES);
	final UserDAO dao =  new UserDAO(dslContext);
	// other application code...
}

A DAO can be something like this

public class UserDAO {
  private final DSLContext dslContext;
  
  public UserDAO(final DSLContext dslContext) {
	this.dslContext = dslContext;
  }

  public String findNameById(int id) {
	return this.dslContext.select(field("name")).from("users").where(field("id").equal(id)).fetch();
  }
}

Outstanding tasks

About

JOOQ integration for Dropwizard

Resources

License

Releases

No releases published
You can’t perform that action at this time.