Fetch the summary slices' to-one associations and count instead of scanning

Performancekamo-shared-library
Shipped
August 12, 2026 at 8:46 PM UTC
Author
Kamo
Commit
2badd29

The Overview's attention and recent slices read a title per row off a LAZY @ManyToOne, costing up to 16 extra selects per block under open-session-in-view. All four slices now LEFT JOIN FETCH it. The fetch join is safe beside the Pageable because both associations are *-to-ONE: Hibernate falls back to in-memory pagination (HHH90003004) only for COLLECTION fetches, which multiply rows and would cut an entity in half under a SQL LIMIT. A to-one join is row-preserving, so the Pageable stays a real LIMIT. These repositories have no Spring-context parse gate, so HrSummaryQueryShapeTest now reads the @Query text by reflection and pins both halves: the to-one fetch is present, AND no plural association was ever added beside it. The second assertion is the one that matters later. Also: - averageScoreForOrg: one AVG over GRADED_STATES, replacing a 200-row sample the Overview drew on DELIVERY date while printing a pass rate that was org-wide. Two figures side by side describing different populations, with the sample drawn on an axis that correlates with nothing about scoring. - GRADED_STATES = {PASSED, FAILED_FINAL}, so the mean's WHERE clause and the pass rate's denominator read one constant and cannot drift apart by edit. FAILED_RETAKE_ALLOWED is scored but not graded — attempts remain. - countByOrgIdAndTrackingModeNot, so the tracked headcount stops loading every employment row in the tenant to produce one integer on a card. - countOverdueForOrg's javadoc now names OPEN_STATES by identifier, symmetric with the training twin's REMINDABLE_STATES. The two domains pass DIFFERENT sets on purpose and the difference must be legible from either side. The overdue predicate split is untouched: legal OPEN_STATES, training REMINDABLE_STATES, AWAITING_GRADING never overdue. No entity changes and the version stays 1.5.0.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing