advancedScenario Questions
Scenario 13: A @PostFilter-protected endpoint listing 'my transactions' has become extremely slow as the transactions table grew into the millions.
@PostFilter runs AFTER the annotated method already fetched the FULL result set, filtering it down in memory afterward — at scale this means fetching millions of rows just to discard most of them. Fix by pushing the filtering condition (e.g., WHERE owner_id = :currentUserId) into the actual repository query, so the database only returns rows the user is allowed to see in the first place.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response