A Spring Data repository is an interface-based data-access abstraction for an underlying SQL or NoSQL store. In a filtering scenario, a repository method can retrieve records matching both a search term and the authenticated user. section 12.3
Apply repository-level filtering in two ways:
- Use @PreFilter or @PostFilter; @PostFilter works but can retrieve every matching record before filtering, creating memory and performance risks. section 12.3
- Put authorization conditions directly in the repository query so the data store returns only permitted records. section 12.3
Owner-filtered product search
A ProductRepository can search product names while restricting results to authentication.name. A request from nikolai returns candy; a request from julien returns chocolate. Replacing @PostFilter with a query condition avoids loading unauthorized products into application memory. section 12.3

