Reader small image

You're reading from  jOOQ Masterclass

Product typeBook
Published inAug 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800566897
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Anghel Leonard
Anghel Leonard
author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard

Right arrow

Exploring jOOQ query types

jOOQ distinguishes between two main types of queries:

  • DML (INSERT, UPDATE, DELETE, and MERGE, among others) and DDL (CREATE, ALTER, DROP, RENAME, and similar) queries that produce a modification in the database
  • DQL (SELECT) queries that produce results

DML and DDL queries are represented in jOOQ by the org.jooq.Query interface, while DQL queries are represented by the org.jooq.ResultQuery interface. The ResultQuery interface extends (among others) the Query interface.

For instance, the following snippet of code contains two jOOQ queries:

Query query = ctx.query("DELETE FROM payment 
  WHERE customer_number = 103");
Query query = ctx.deleteFrom(PAYMENT)
  .where(PAYMENT.CUSTOMER_NUMBER.eq(103L));  

These queries can be executed via jOOQ and they return the number of affected rows:

int affectedRows = query.execute();

And, here are two result queries: first, a plain SQL query –...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
jOOQ Masterclass
Published in: Aug 2022Publisher: PacktISBN-13: 9781800566897

Author (1)

author image
Anghel Leonard

Anghel Leonard is a Chief Technology Strategist and independent consultant with 20+ years of experience in the Java ecosystem. In daily work, he is focused on architecting and developing Java distributed applications that empower robust architectures, clean code, and high-performance. Also passionate about coaching, mentoring and technical leadership. He is the author of several books, videos and dozens of articles related to Java technologies.
Read more about Anghel Leonard