AuftragsCacheService.ktAuftragDO), order positions (AuftragsPositionDO), and payment schedules (PaymentScheduleDO) using native JPQL tuple queries. Avoids full entity hydration and lazy-loading overhead by selecting only the columns needed for list rendering and cache population.
The class is annotated with @Service and depends on PfPersistenceService via @Autowired. All methods use runIsolatedReadOnly to execute queries in a fresh persistence context, preventing pollution of the caller's session cache.
| Dependency | Type | Role |
|---|---|---|
PfPersistenceService | Framework | Provides isolated read-only JPA contexts for fast tuple queries |
selectAuftragsList(): List<AuftragDO>Returns all orders (including deleted) with a curated column set. Maps each Tuple to a partially-populated AuftragDO using TupleUtils getter helpers. Foreign keys (kundeId, projektId, contactPersonId) are resolved via em.getReference() to avoid additional queries — Hibernate returns a lazy proxy without hitting the database.
selectNonDeletedAuftragsPositions(): List<AuftragsPositionDO>Returns non-deleted order positions. Similar tuple mapping pattern with an additional performance optimization: bemerkung (comment) is abbreviated to 30 characters via abbreviate(30), reducing memory footprint for list views. The task reference (taskId) creates a stub TaskDO with only the ID set.
selectNonDeletedPaymentSchedules(): List<PaymentScheduleDO>Returns non-deleted payment schedules, creating stub AuftragDO objects (ID-only) for the foreign key reference auftragId.
Three JPQL queries are defined as private val constants in the companion object, using ${AuftragDO::class.simpleName} interpolation for type-safe entity references:
| Constant | Target Entity | Filter |
|---|---|---|
SELECT_ORDERS | AuftragDO | None (all records, including deleted) |
SELECT_POSITIONS | AuftragsPositionDO | WHERE deleted = false |
SELECT_PAYMENTS_SCHEDULES | PaymentScheduleDO | WHERE deleted = false |
em.getReference() creates lazy proxies for FK associations, avoiding JOINs.runIsolatedReadOnly ensures each call has a clean persistence context, preventing interference with the caller's active transaction.abbreviate(30) call on bemerkung minimizes heap pressure for large comment fields during list rendering.AuftragsCache — uses these tuple results to build the in-memory order book cacheTupleUtils — type-safe tuple column accessors (getLong, getString, getBigDecimal, etc.)PfPersistenceService — framework persistence abstraction868d6abb7 2025 -> 2026 49b1d6b8d Forecast and orderbook: forecast-Type for orders/positions added (current month or following month) 7163b8c4e WIP: Order book snapshots, ForecastExport fixed (customer and project name were missing) 63081666f Source file headers: 2024-> 2025. ae2c04ee0 Migration stuff in progress... (all tests of all packages: OK). 89ea9a532 Migration stuff in progress... (all tests of all packages: OK).