Shaping the generic DAO design pattern and using jOOQ
Trying to implement the generic DAO from Figure 4.2 starts with the generic interface, ClassicModelsRepository
:
@Repository @Transactional(readOnly = true) public interface ClassicModelsRepository<T, ID> { List<T> fetchAll(); @Transactional void deleteById(ID id); }
While ClassicModelsRepository
contains the common query methods, SaleRepository
extends it to add specific query methods, as follows:
@Repository @Transactional(readOnly = true) public interface SaleRepository extends ClassicModelsRepository<Sale, Long> { public List<Sale> findSaleByFiscalYear(int year); public List<Sale> findSaleAscGtLimit(double limit); }
The implementation of SaleRepository
provides implementations for methods from both interfaces:
@Repository public class SaleRepositoryImpl implements SaleRepository...