Performance: Custom query methods by naming convention
This affects how quickly the database queries are generated and executed, impacting page load and response times.
Jump into concepts and practice - no test required
List<User> findByNameContaining(String name);
List<User> findByNameContainingIgnoreCaseOrderByAgeDesc(String name);
| Pattern | Query Parsing Cost | Query Execution Cost | Startup Impact | Verdict |
|---|---|---|---|---|
| Complex method names with many keywords | High | Variable (depends on query) | Medium | [!] OK |
| Simple, clear method names | Low | Low | Low | [OK] Good |
findByLastName do?findBy in Spring Data JPA means it will search and return matching records.LastName as the property to filter by, so it finds records with that lastName.countBy.countByAge to count users filtered by age.existsByEmailAndStatus(String email, String status), what will it return if a user with email "test@example.com" and status "active" exists?existsBy returns a boolean indicating if any record matches the criteria.And.List<User> findByNameOr(int age, String name);