Great Reasons for Using jOOQ
Our customers spend most time on their business-logic.
Because jOOQ takes care of all their Java/SQL infrastructure problems.
Database First
Tired of ORMs driving your database model?
Whether you design a new application or integrate with your legacy, your database holds your most important asset: your data.
jOOQ is SQL-centric. Your database comes "first".
Typesafe SQL
Fed up with detecting SQL syntax errors in production?
SQL is a highly expressive and type safe language with a rich syntax. jOOQ models SQL as an internal DSL and uses the Java compiler to compile your SQL syntax, metadata and data types.
Code Generation
Bored with renaming table and column names in your Java code?
jOOQ generates Java classes from your database metadata. Your Java compiler will tell you when your code is out of sync with your schema.
Active Records
Annoyed by the amount of SQL you write for CRUD?
jOOQ lets you perform CRUD and POJO mapping directly on Active Records, which are also generated from the code generator.
Multi-Tenancy
Worried about multi-schema or shared-schema multi-tenancy?
jOOQ lets you configure database schema and table overrides at runtime and also supports row-level security.
Standardisation
Overwhelmed by the subtle differences in SQL dialects?
jOOQ performs SQL transformation to transform common SQL expressions into your database's closest match. Write SQL that works on all your databases.
Query Lifecycle
Irritated by your ORM's mysterious SQL generation?
jOOQ lets you hook into its SQL generation lifecycle, for logging, transaction handling, ID generation, SQL transformation and much more.
Procedures
Surprised by your ORM's lack of support for stored procedures?
Stored Procedures are an essential feature of modern SQL databases. jOOQ lets you embed stored function calls into your SQL statements.
Examples
With the jOOQ DSL, SQL looks almost as if it were natively supported by Java.
SELECT TITLE FROM BOOK WHERE BOOK.PUBLISHED_IN = 2011 ORDER BY BOOK.TITLE
create.select(BOOK.TITLE) .from(BOOK) .where(BOOK.PUBLISHED_IN.eq(2011)) .orderBy(BOOK.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
SELECT AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, COUNT(*) FROM AUTHOR JOIN BOOK ON AUTHOR.ID = BOOK.AUTHOR_ID WHERE BOOK.LANGUAGE = 'DE' AND BOOK.PUBLISHED > DATE '2008-01-01' GROUP BY AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME HAVING COUNT(*) > 5 ORDER BY AUTHOR.LAST_NAME ASC NULLS FIRST LIMIT 2 OFFSET 1
create.select(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME, count()) .from(AUTHOR) .join(BOOK).on(AUTHOR.ID.equal(BOOK.AUTHOR_ID)) .where(BOOK.LANGUAGE.eq("DE")) .and(BOOK.PUBLISHED.gt(date("2008-01-01"))) .groupBy(AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME) .having(count().gt(5)) .orderBy(AUTHOR.LAST_NAME.asc().nullsFirst()) .limit(2) .offset(1)
Typesafety Examples
SQL is a very type safe language. So is jOOQ. jOOQ uniquely respects SQL's row value expression typesafety. jOOQ will use your Java compiler to type-check the following:
Predicates
jOOQ type-checks simple comparison predicates and predicates with subqueries.
select().from(t).where(t.a.eq(select(t2.x).from(t2)); // Type-check here: ---------------> ^^^^ select().from(t).where(t.a.eq(any(select(t2.x).from(t2))); // Type-check here: -------------------> ^^^^ select().from(t).where(t.a.in(select(t2.x).from(t2)); // Type-check here: ---------------> ^^^^
Set Operations
jOOQ type-checks degree and data types of union subselects.
select(t1.a).from(t1).unionAll(select(t2.a).from(t2)); // Type-check here: ----------------> ^^^^ select(t1.a, t1.b).from(t1).union(select(t2.a, t2.b).from(t2)); // Type-check here: -------------------> ^^^^^^^^^^
Some more sophisticated examples show type-checks on row value expressions:
SELECT * FROM t WHERE (t.a, t.b) = (1, 2) SELECT * FROM t WHERE (t.a, t.b) OVERLAPS (date1, date2) SELECT * FROM t WHERE (t.a, t.b) IN (SELECT x, y) UPDATE t SET (a, b) = (SELECT x, y FROM t2 WHERE ...) INSERT INTO t (a, b) VALUES (1, 2)
select().from(t).where(row(t.a, t.b).eq(1, 2)); // Type-check here: -----------------> ^^^^ select().from(t).where(row(t.a, t.b).overlaps(date1, date2)); // Type-check here: ------------------------> ^^^^^^^^^^^^ select().from(t).where(row(t.a, t.b).in(select(t2.x, t2.y))); // Type-check here: -------------------------> ^^^^^^^^^^ update(t).set(row(t.a, t.b), select(t2.x, t2.y).where(...)); // Type-check here: --------------> ^^^^^^^^^^ insertInto(t, t.a, t.b).values(1, 2); // Type-check here: ---------> ^^^^
Some of our customers
More customers
Testimonials
Thousands of happy jOOQ users aren't just using jOOQ. They love jOOQ.
With jOOQ, writing SQL in Java is fun and productive. Here's what some of our users say:
Using jOOQ has been a joy, it's made life much easier for us.
Ilkka Halila - Boomlagoon Ltd.
The level of support from the jOOQ team was nothing short of excellent. They were extremely easy to talk to, and had my problem solved in less than an hour on Skype. I would recommend jOOQ support services to anyone.
Paul Woodland - ABC Information Solutions Pty Ltd
Thanks to jOOQ we are in control of our SQL which helps to be in control of our project.
Marco Dubacher - Ergon Informatik AG
The ability to trivially add SQL functions in a single line of a single method is fantastic! Honestly, we’ve gotten away using your documentation, examples, and source and never had to bug you guys with “How do I …?” You blog, manual, etc, all combine together with a simple library to make a great product that let’s us do some insane SQL *really really easily*.
Daniel Owens - DanielSecurities
We successfully deploy jOOQ in a range of projects with clients from various sectors, such as construction companies, telecom or security services companies: jOOQ offers us the necessary flexibility to satisfy their different requirements.
Gabrio Rivera - OneOverZero GmbH