2V0-72.22PSE · Question #96
Refer to the exhibit. Which two methods will be implemented at runtime if declared in a Spring Data JPA Repository? (Choose two.)
The correct answer is C. public Customer findByEmail(String email); D. public Customer findFirstByOrderDateBetween(Date d1, Date d2). Spring Data JPA automatically implements repository methods whose names follow its derived query naming convention: find[Subject]By[Property]Keyword. Options C and D are correct because findByEmail(String email) cleanly maps to a WHERE email = ? query, and…
Question
Refer to the exhibit. Which two methods will be implemented at runtime if declared in a Spring Data JPA Repository? (Choose two.)
Exhibit
Options
- Apublic Customer getsingle(Long id);
- Bpublic Customer findFirstOrderDateMax();
- Cpublic Customer findByEmail(String email);
- Dpublic Customer findFirstByOrderDateBetween(Date d1, Date d2);
- Epublic Customer findCustomerByName(String name);
How the community answered
(40 responses)- A15% (6)
- B3% (1)
- C78% (31)
- E5% (2)
Explanation
Spring Data JPA automatically implements repository methods whose names follow its derived query naming convention: find[Subject]By[Property][Keyword](params). Options C and D are correct because findByEmail(String email) cleanly maps to a WHERE email = ? query, and findFirstByOrderDateBetween(Date d1, Date d2) correctly uses the First limiter and the Between keyword with two matching parameters - both are recognized patterns Spring Data JPA can parse and implement at runtime.
Why the distractors fail:
- A (
getsingle): Missing theByseparator;singleis not a recognized Spring Data keyword, so the framework cannot parse it. - B (
findFirstOrderDateMax): Also missingBybeforeOrderDate, soMaxis treated as part of an unrecognized property name rather than as an aggregation keyword. - E (
findCustomerByName): The Customer entity shown in the exhibit does not have anamefield (likely hasfirstName/lastNameor similar), so this method would throw aPropertyReferenceExceptionat startup.
Memory tip: Think of the formula as find + [optional limiter like First/Top] + By + [exact field name] + [keyword like Between/Like/GreaterThan]. If the part after By doesn't match an actual entity field, Spring Data will reject it at application startup - not silently at runtime.
Topics
Community Discussion
No community discussion yet for this question.
