Questions tagged [jooq]

jOOQ stands for JOOQ Object Oriented Querying. jOOQ effectively combines complex SQL, typesafety, source code generation, active records, stored procedures, advanced data types, and Java in a fluent, intuitive DSL.

What's jOOQ?

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

  • Code Generation:

    jOOQ generates a simple Java representation of your database schema. Every table, view, stored procedure, enum, and UDT is a class.

  • Active records:

    jOOQ implements an easy-to-use active record pattern. It is not an OR-mapper, but provides a 1:1 mapping between tables/views and classes, between columns and members.

  • Typesafe SQL:

    jOOQ allows for writing compile-time typesafe querying using its built-in DSL.

  • SQL standard:

    jOOQ supports all standard SQL language features including the more complex UNIONs, nested SELECTs, joins, and aliasing.

  • Vendor-specific feature support:

    jOOQ encourages the use of vendor-specific extensions such as stored procedures, UDTs, ARRAYs, and many more.

How does jOOQ help you?

  • Your database always comes FIRST! That's where the real schema is, not in Java code or some XML mapping file with syntax you're not familiar with.
  • You keep your code DRY.
  • You won't suffer from the Object-Relational impedance mismatch.
  • You won't have syntax errors in your query.
  • You won't forget to bind variables correctly. No SQL injection, either.
  • You don't need to know your database schema by heart when you develop. The schema is generated in Java. You can use auto-completion in your IDE!
  • You don't need to create value objects for your data. Use the generated artifacts instead.
  • You have automatic type mapping between SQL data types and Java types.
  • You change something in the database? Your Java code won't compile. You don't need to wait until runtime to notice.
  • You can forget about JDBC (especially useful when dealing with UDTs, ARRAYs and stored procedures).
  • You can port your SQL to a new database. jOOQ will generate SQL that works on any database.

When to use jOOQ

jOOQ is not an OR-mapper. jOOQ is low-level relational persistence abstraction. In principle, you could even write an OR-mapper on top of jOOQ. If you're aware of this, you can benefit most from jOOQ...

  • When you love your RDBMS of choice, including all its vendor-specific features.
  • When you love control over your code.
  • When you love the relational data model (read this interesting article).
  • When you love SQL.
  • When you love stored procedures.

See the examples for yourself. You'll be convinced in no time! :-)

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...

  • When you don't care about your database (or "persistence" as it is called).
  • When you don't really need SQL.
  • When you want to map your object-oriented domain model to a database and not vice versa.
  • When you need to write DDL statements. jOOQ only supports DML statements.

What databases are supported

Every RDMBS out there has its own little specialties. We consider those specialties as much as possible, while trying to standardise the behaviour in jOOQ. In order to increase the quality of jOOQ, we run unit tests for syntax and variable binding verification, as well as integration tests for any of these databases:

  • Access
  • Aurora for MySQL
  • Aurora for PostgreSQL
  • Azure SQL Database
  • Azure SQL Data Warehouse
  • CUBRID
  • DB2
  • Derby
  • Firebird
  • H2
  • HSQLDB
  • Informix
  • Ingres
  • MariaDB
  • MySQL
  • Oracle
  • PostgreSQL
  • Redshift
  • SQLite
  • SQL Server
  • Sybase Adaptive Server Enterprise
  • Sybase SQL Anywhere
  • Teradata
  • Vertica

Similar products

When you consider jOOQ for your project, you might also have considered any of these similar products:

  • Querydsl: Focusing on the DSL and abstracting "backend integrations", such as SQL, JPA, collections, etc. The "complete LINQ of Java".
  • JaQu: Writing SQL statements using actual Java expressions

And with database tools, such as

  • ActiveJDBC: A simple mapping tool implementing ActiveRecords in a Ruby-like way

And with OR-mapping tools, such as

  • Hibernate: The mother of all inspiration to Java persistence
  • JPA: The Java EE standard

License

jOOQ is dual-licensed under the Apache Software License 2.0 and commercially licensed.

2566 questions
75
votes
7 answers

java.util.stream with ResultSet

I have few tables with big amount of data (about 100 million records). So I can't store this data in memory but I would like to stream this result set using java.util.stream class and pass this stream to another class. I read about Stream.of and…
Iurii
  • 1,755
  • 8
  • 24
  • 38
43
votes
4 answers

UPSERT in PostgreSQL using jOOQ

I am trying to perform an UPSERT in PostgreSQL using the jOOQ library. For doing this I am currently trying to implement the following SQL statement in jOOQ: https://stackoverflow.com/a/6527838 My code looks like this so far: public class…
uldall
  • 2,458
  • 1
  • 17
  • 31
39
votes
6 answers

How to disable JooQ's self-ad message in 3.4+?

I'm a big fan of JooQ, but unfortunately since upgrading from 3.3 it prints a very annoying message to the console each time before my code exits: Feb 02, 2015 7:28:06 AM org.jooq.tools.JooqLogger info INFO:…
fge
  • 119,121
  • 33
  • 254
  • 329
37
votes
8 answers

Replacing a full ORM (JPA/Hibernate) by a lighter solution : Recommended patterns for load/save?

I'm developing a new Java web application and I'm exploring new ways (new for me!) to persist the data. I mostly have experience with JPA & Hibernate but, except for simple cases, I think this kind of full ORM can become quite complex. Plus, I don't…
electrotype
  • 8,342
  • 11
  • 59
  • 96
34
votes
4 answers

Comparing Querydsl, jOOQ, JEQUEL, activejdbc, iciql and other query DSLs

Can someone point me to some resources about the performance comparison among the different Query DSL libraries available for using with Java, like: Querydsl, jOOQ, JEQUEL, activejdbc, iciql and etc... Background: I m using Spring JDBC template, but…
manikanta
  • 8,100
  • 5
  • 59
  • 66
31
votes
1 answer

JOOQ vs Hibernate

When I chat to stackoverflowers on chat and read other tutorials about database with Java then they are guide me to use JOOQ instead of HIBERNATE. I am totally aware about ORM with Hibernate and I prefer to use Hibernate and now aware almost about…
Gopal00005
  • 2,061
  • 4
  • 35
  • 54
31
votes
5 answers

How to write Count Query In jOOQ

I am converting Pure SQL to jOOQ now I have this ("SELECT Count(*) Count From Table "); I have to write this in jOOQ how can we write it? selectQueryRecord.addSelect(Here Count Function ); selectQueryRecord.addFrom(Table);
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
29
votes
8 answers

JOOQ and Spring

Has anyone tried using JOOQ with the Spring framework or am I breaking new ground? http://www.jooq.org
donaldh
  • 833
  • 1
  • 8
  • 14
26
votes
3 answers

Java: JOOQ persistence framework performance and feed back

I've stumbled over a nice SQL builder framework, called JOOQ. BTW, in Russian JOOQ sounds like noun meaning "bug" (as an insect), "beetle" ;) If you have any feedback about JOOQ, it's performance and such, please share. Links to blogs about JOOQ…
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
26
votes
2 answers

jOOQ can I fetch a join of two tables into the respective POJOs

In jOOQ if I want to fetch a row of a table into a jOOQ autogenerated POJOs I do, for instance: dsl.selectFrom(USER) .where(USER.U_EMAIL.equal(email)) .fetchOptionalInto(User.class); Now, suppose that I want to do a…
mat_boy
  • 12,998
  • 22
  • 72
  • 116
22
votes
5 answers

Technical difference between Spring Boot with JOOQ and Spring Data JPA

When would you use Spring Data JPA over Spring Boot with JOOQ and vice versa? I know that Spring Data JPA can be used for completing basic CRUD queries, but not really for complex join queries while using JOOQ makes it easier? EDIT: Can you use both…
ph-quiett
  • 431
  • 1
  • 5
  • 18
20
votes
2 answers

jOOQ and autogeneration, how to avoid UDT Records inside table POJOs

I define a type T and a view V in a PostgreSQL database. CREATE TYPE my_type AS ( mt_column1 smallint NOT NULL ); CREATE VIEW my_view AS SELECT some_column_id integer ARRAY(SELECT ROW(an_int)::my_type FROM a_table ) AS…
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
19
votes
2 answers

How can one see the SQL statements that jOOQ executes?

I use jOOQ to query/insert/update data from/into a table. Is there a way to see the SQL statements that JOOQ executes?
user1455204
  • 199
  • 1
  • 1
  • 3
18
votes
0 answers

Postgresql connection marked as broken by Hikari

I have Spring application that regularly inserts records in a PostgreSQL-DB. Now, after a scheduled set of imports is done it takes a few seconds until I get the following warning: com.zaxxer.hikari.pool.ProxyConnection : HikariPool-1 - Connection…
fhueser
  • 599
  • 3
  • 16
18
votes
1 answer

How to get all the result columns from database with other custom(concat, sum, count) columns in Jooq

I have a table Table1 with 6 columns. Here is the sql statement that i need to map. Select *,count(ID) as IdCount from Table1; Now, the sql query result will be 7 columns ( 6 Table1 columns and 1 IdCount column). But when i implement the same in…
Shekhar
  • 787
  • 2
  • 7
  • 18
1
2 3
99 100