Alternative Approaches to Writing SQL in Java

Using SQL mostly boils down to two approaches:

Domain model centric vs. Relational model centric

Some assumptions:

Java code drives database design vs. Database design drives Java code
CRUD is performed more often than complex querying vs. CRUD is performed as often as complex querying
Data is often hierarchical vs. Data is mostly relational
One application mostly accesses the same data vs. Several applications access the same data

Good tools to use for each approach:

Hibernate has served the Java and .NET ecosystem for many years and still makes for an awesome tool for domain model centric applications.

jOOQ focuses on relational model centric applications and embraces SQL as a language, itself.

jOOQ is a good alternative to Hibernate, where SQL and the relational model are critical to a system.

jOOQ can also work together with Hibernate, if no clean line between the two approaches can be drawn.

jOOQ is a modern internal DSL modeling typesafe SQL in a fluent Java API with a powerful code generator.

jOOQ is the best way to write SQL in Java.