Dynamic QueryDSL builder
Change a condition and the API queries sample meter data with the same filter and sort rules as the aptERP metering query, and the matching QueryDSL code is generated alongside.
In production this pattern cut the metering query from about 10 seconds to 3 to 4 seconds, measured in the browser network tab. See the AptERP project
Filters
// RangeCondition
// filterByUsageRange
// filterByStatus / PrintOrderCode
Results
0 rows
| Block | Unit | Usage | Status | Print order |
|---|---|---|---|---|
| No rows for these filters | ||||
MeterRepository.javaLIVE
// QueryDSL generated live from the current filtersqueryFactory.select(Projections.constructor(MeterReadingDto.class, ...)).from(unit).leftJoin(record).on(...).where(unit.complexCode.eq(dto.getComplexCode()),unit.useYn.eq("Y"),buildRangeFilter(dto), // RangeCondition reuse// blockNo >= "101" AND blockNo <= "103"// filterByUsageRange(dto) ← no usage filter// filterByStatus(dto) ← fetch all).orderBy(new OrderSpecifier<>(ASC, unit.blockNo),PrintOrderCode.FLOOR_ASC.getSortPath() // floor asc).fetch();