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...