nerdexam
Broadcom-VMware

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…

Data Access

Question

Refer to the exhibit. Which two methods will be implemented at runtime if declared in a Spring Data JPA Repository? (Choose two.)

Exhibit

2V0-72.22PSE question #96 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)
  • A
    15% (6)
  • B
    3% (1)
  • C
    78% (31)
  • E
    5% (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 the By separator; single is not a recognized Spring Data keyword, so the framework cannot parse it.
  • B (findFirstOrderDateMax): Also missing By before OrderDate, so Max is 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 a name field (likely has firstName/lastName or similar), so this method would throw a PropertyReferenceException at 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

#Spring Data JPA#Query Method Derivation#Repository Interface#Method Naming Conventions

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice