Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
J

jOOQ

> 数据库
Open source

jOOQ is the best way to write SQL in Java

6.8K stars0 likes3 views
WebsiteGitHub

About

jOOQ is the best way to write SQL in Java

jOOQ

jOOQ is an internal DSL and source code generator, modelling the SQL language as a type safe Java API to help you write better SQL.

Its main features include:

  • The source code generator
  • The DSL API for type safe query construction and dynamic SQL

Secondary features include:

  • DAOs
  • Data export and import
  • Data type conversion
  • DDL statement support
  • DML statement support
  • Diagnostics
  • Dialect agnosticism for 30+ RDBMS
  • Embedded types
  • Formatting and pretty printing
  • Implicit joins
  • Kotlin support
  • Mapping
  • Meta data API
  • Mocking API for JDBC
  • Model API for use in traversal and replacement
  • MULTISET and ROW nested collections and records
  • Multitenancy
  • Parser (and translator)
  • Pattern based transformation
  • Plain SQL templating
  • Policies
  • Procedural logic API
  • Reactive support via R2DBC
  • Readonly columns
  • Scala support
  • Schema diff
  • SQL transformation
  • SQL translation
  • Stored procedure support
  • Transaction API
  • UpdatableRecords for simplified CRUD, with opt-in optimistic locking
  • And much more

Examples

Typesafe, embedded SQL

jOOQ's main feature is typesafe, embedded SQL, allowing for IDE auto completion of SQL syntax...

... as well as of schema meta data:

This allows for preventing errors of various types, including typos of identifiers:

Or data type mismatches:

The examples are from the code generation blog post.

A more powerful example using nested collections

For many more examples, please have a look at the demo. A key example showing jOOQ's various strengths is from the MULTISET operator announcement blog post:

Given these target DTOs:

java
record Actor(String firstName, String lastName) {}
record Film(
  String title,
  List<Actor> actors,
  List<String> categories
) {}

You can now write the following query to fetch films, their nested actors and their nested categorise in a single, type safe query:

java
List<Film> result =
dsl.select(
      FILM.TITLE,
      multiset(
        select(
          FILM.actor().FIRST_NAME, 
          FILM.actor().LAST_NAME)
        .from(FILM.actor())
      ).as("actors").convertFrom(r -> r.map(mapping(Actor::new))),
      multiset(
        select(FILM.category().NAME)
        .from(FILM.category())
      ).as("categories").convertFrom(r -> r.map(Record1::value1))
   )
   .from(FILM)
   .orderBy(FILM.TITLE)
   .fetch(mapping(Film::new));

The query is completely type safe. Change a column type, name, or the target DTO, and it will stop compiling! Trust only your own eyes:

And here you see the nested result in action from the logs:

How does it work? Look at this annotated example:

…

The generated SQL query might look like this, in PostgreSQL:

…

This particular example is explained more in detail in the MULTISET operator announcement blog post. For many more examples, please have a look at the demo.

Issues· 2117 open

View all issuesOpen on GitHub
  • #19662

    Wrong value returned from Record.get(TABLE.UDT.ATTRIBUTE) when there's a conflicting TABLE.ATTRIBUTE column

    T: DefectC: FunctionalityP: MediumT: Incompatible changeE: All EditionsUpdated Sep 21, 2026
  • #20253

    Add an inclusive variant of the synthetic SEEK clause (>= instead of >)

    T: EnhancementC: FunctionalityP: LowE: All EditionsUpdated Sep 21, 2026
  • #16401

    TransactionPublisher shouldn't stream intermediary results prior to committing the transaction

    T: DefectC: FunctionalityP: MediumE: All EditionsUpdated Sep 10, 2026
  • #18291

    UpdatableRecord merge not supported with optimistic locking enabled

    T: DefectC: FunctionalityP: MediumE: All EditionsUpdated Sep 10, 2026
  • #20199

    Add a way for a transactionPublisher to stream uncommitted intermediary output

    T: DefectC: FunctionalityP: HighE: All EditionsUpdated Sep 9, 2026
  • #6310

    Add support for function-based indexes in code generator

    T: EnhancementC: FunctionalityC: Code GenerationP: HighE: All EditionsUpdated Sep 8, 2026
  • #15292

    Wrong or missing runtime meta data for indexes with DESC column expressions

    T: DefectC: FunctionalityC: Code GenerationP: MediumE: All EditionsUpdated Sep 8, 2026
  • #20181

    Implicit path join elimination doesn't happen with many-to-many relationships when the unnecessary parent table is in a one-to-one relationship with a child table

    T: DefectC: FunctionalityP: MediumE: All EditionsUpdated Sep 7, 2026
  • #20163

    Add implicit join specific error message when path root is not declared

    T: EnhancementC: FunctionalityP: MediumE: All EditionsUpdated Sep 7, 2026
  • #20157

    AbstractName::equalsIgnoreCase should not call Name::getName, which incurs a String[] allocation

    T: DefectC: FunctionalityP: MediumE: All EditionsUpdated Sep 7, 2026

> Tags

Javacode-generatordatabasedb2hibernate

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 23, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库