Philosophy

SQL was never meant to be abstracted. To be confined in the narrow boundaries of heavy mappers, hiding the beauty and simplicity of relational data. SQL was never meant to be object-oriented. SQL was never meant to be anything other than... SQL!

What does jOOQ code look like?

It's simple. With the jOOQ DSL, SQL looks almost as if it were natively supported by Java. For instance, get all books published in 2011, ordered by title

  SELECT * FROM BOOK
   WHERE PUBLISHED_IN = 2011
ORDER BY TITLE
create.selectFrom(BOOK)
      .where(PUBLISHED_IN.equal(2011))
      .orderBy(TITLE)

jOOQ also supports more complex SQL statements. get all authors' first and last names, and the number of books they've written in German, if they have written more than five books in German in the last three years (from 2011), and sort those authors by last names limiting results to the second and third row, then lock first and last names columns for update

  SELECT FIRST_NAME, LAST_NAME, COUNT(*)
    FROM AUTHOR
    JOIN BOOK ON AUTHOR.ID = BOOK.AUTHOR_ID
   WHERE LANGUAGE = 'DE'
     AND PUBLISHED > '2008-01-01'
GROUP BY FIRST_NAME, LAST_NAME
  HAVING COUNT(*) > 5
ORDER BY LAST_NAME ASC NULLS FIRST
   LIMIT 2
  OFFSET 1
     FOR UPDATE
      OF FIRST_NAME, LAST_NAME
create.select(FIRST_NAME, LAST_NAME, count())
      .from(AUTHOR)
      .join(BOOK).on(Author.ID.equal(Book.AUTHOR_ID))
      .where(LANGUAGE.equal("DE"))
      .and(PUBLISHED.greaterThan(parseDate("2008-01-01")))
      .groupBy(FIRST_NAME, LAST_NAME)
      .having(count().greaterThan(5))
      .orderBy(LAST_NAME.asc().nullsFirst())
      .limit(2)
      .offset(1)
      .forUpdate()
      .of(FIRST_NAME, LAST_NAME)

What is jOOQ?

jOOQ stands for Java Object Oriented Querying. It combines these essential features:

How does jOOQ help you?

Or in short:

When to use jOOQ

When not to use jOOQ

On the other hand, many people like the ease of use of Hibernate or other products, when it comes to simply persisting any domain model in any database. You should not use jOOQ...

What databases are supported

Every RDMBS out there has its own little specialties. jOOQ considers those specialties as much as possible, while trying to standardise the behaviour in jOOQ. In order to increase the quality of jOOQ, some 70 unit tests are run for syntax and variable binding verification, as well as some 130 integration tests with an overall of around 900 queries for any of these databases:

These platforms have been observed to work as well, but are not integration-tested

Planned (Contributions and suggestions are very welcome!)

Other requirements

jOOQ runs with Java 1.6+

License

jOOQ is licensed under the Apache Software License 2.0

Thanks

YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.


Fork me on GitHub
The jOOQ Logo