findTop3ByCategoryAndInStockTrueOrderByPriceAscString
findTop3ByCate... is an example of a Spring Data JPA derived query method. Methods in Spring Data repositories can encode the query logic in the method name. The Top3 part indicates that the method should return at most three results, while the By introduces the filtering criteria. The remainder specifies the property path used for filtering, such as category, categoryId, or categoryName. Such methods are declared in a repository interface that typically extends JpaRepository or a related interface, and Spring generates the implementation at runtime.
How it works: Spring analyzes the method name and translates it into a JPQL or SQL query.
Return types and ordering: The typical return type is List<T>, since the result is limited to three
Limitations and usage notes: The method name must map to existing entity properties; overly long or complex
Practical use: This pattern is useful for showing featured, trending, or preview items within a category, such