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

Shaping the DAO design pattern and using jOOQ

Let's assume that we have a bunch of SQLs written in jOOQ for the SALE table, and we want to shape a simple DAO implementation around them. This is quite simple because all we have to do is to follow Figure 4.1 from the previous section.

First of all, the model is provided as POJOs by the jOOQ generator (we can have user-defined POJOs as well), therefore, we already have the Sale POJO. Next, we write SaleRepository:

@Repository
@Transactional(readOnly=true)
public interface SaleRepository {
  public List<Sale> findSaleByFiscalYear(int year);
  public List<Sale> findSaleAscGtLimit(double limit);    
}

SaleRepositoryImpl provides a jOOQ implementation for these two methods:

@Repository
public class SaleRepositoryImpl implements SaleRepository {
  private final DSLContext ctx;
  public SaleRepositoryImpl(DSLContext ctx) {
    this...
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