7.6.4. Other Types of Queries

We’ll take a look at other types of queries. This query inserts a record:

  1. INSERT INTO AUTHOR
  2. (ID, FIRST_NAME, LAST_NAME)
  3. VALUES (100, 'Hermann', 'Hesse');

In jOOQ:

  1. dsl.insertInto(AUTHOR,
  2. AUTHOR.ID, AUTHOR.FIRST_NAME, AUTHOR.LAST_NAME)
  3. .values(100, "Hermann", "Hesse")
  4. .execute();

A query to update a record:

  1. UPDATE AUTHOR
  2. SET FIRST_NAME = 'Hermann',
  3. LAST_NAME = 'Hesse'
  4. WHERE ID = 3;

In jOOQ:

  1. dsl.update(AUTHOR)
  2. .set(AUTHOR.FIRST_NAME, "Hermann")
  3. .set(AUTHOR.LAST_NAME, "Hesse")
  4. .where(AUTHOR.ID.equal(3))
  5. .execute();

A query to delete a record:

  1. DELETE FROM AUTHOR
  2. WHERE ID = 100;

In jOOQ:

  1. dsl.delete(AUTHOR)
  2. .where(AUTHOR.ID.equal(100))
  3. .execute();

More complex update queries can be built in jOOQ, such as a MERGE query, for example.