Configuring jOOQ to generate DAOs
If you are familiar with Spring Data JPA/JDBC, then you're already used to relying on a DAO layer that wraps the queries. Both Spring Data JDBC and JPA provide a built-in DAO that exposes a set of CRUD operations and can be extended via user-defined repositories.
jOOQ code generation can produce similar DAOs. Basically, for each table of the database, jOOQ can generate an org.jooq.DAO
implementation that exposes methods such as findById()
, delete()
, findAll()
, insert()
, and update()
.
In Maven, this feature can be enabled via the following configuration in the <generator>
tag:
<generator> ... <generate> <daos>true</daos> </generate> ... </generator>
jOOQ DAOs make use of POJOs; therefore, jOOQ will implicitly generate POJOs as well. Since we are in Spring Boot, it will be nice to have the generated DAOs annotated with @Repository...