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.