jooby icon indicating copy to clipboard operation
jooby copied to clipboard

add jooq-module for jooby 2.x

Open moh-sushi opened this issue 2 years ago • 1 comments

Hi,

i have ported the jooq-module from jooby v1 into jooby v2.

@advortsov : Can you test it? in #2410 you have asked for this jooq module. steps for local tests:

  • clone my jooby fork, branch j00q-module
  • execute from project root dir : mvn clean source:jar-no-fork install -DskipTests
  • add following dependency into your test project
    <dependency>
      <groupId>io.jooby</groupId>
      <artifactId>jooby-jooq</artifactId>
      <version>2.11.1-SNAPSHOT</version>
    </dependency>
  • see javadoc in class JOOQModule for usage

@jknack : i ask you for a code review. Is anything more to do for accepting this merge request? Further documentation?

moh-sushi avatar Nov 19 '21 09:11 moh-sushi

in my own local test project, jooq module initializsation and its usage were successfully.

instead of getting the entries via hibernate , i have used jooq: code snippet :

public class TodosApp extends Jooby {
  {
    install(new HikariModule());
    install(new JOOQModule("db"));

    get("/", ctx -> {
        try (DSLContext dsl = require(DSLContext.class, "db")) {
          return dsl.transactionResult(conf -> {
            return dsl.select().from("TodoBackendEntry").fetch().map(record -> {
              TodoBackendEntry entry = new TodoBackendEntry();
              entry.setId(record.getValue("ID", Long.class));
              entry.setUrl(record.getValue("URL", String.class));
              entry.setTitle(record.getValue("TITLE", String.class));
              entry.setOrder(record.getValue("order", Long.class));
              entry.setCompleted(record.getValue("COMPLETED", Boolean.class));
              return entry;
            });
          });
        }
    });
}

moh-sushi avatar Nov 19 '21 09:11 moh-sushi