Custom finders can also navigate relationships.
For example, if the repository’s domain type were Person and it had an Address field with ZipCode, we could write a custom finder that uses the ZipCode of the Entity Address to filter the Person entities containing that Address.
(Person->Address->ZipCode)
Which of the following allows you to filter the Person according to the ZipCode?
* findByAddressZipCode(ZipCode zipCode)
* findByAddressWithZipCode(ZipCode zipCode)
* findByAddress_ZipCode(ZipCode zipCode)
* findByAddress@ZipCode(ZipCode zipCode)
#spring #certificationquestion #vcp #springdata
Answer:
findByAddressZipCode is correct.
findByAddressWithZipCode throws an IllegalArgumentException.
findByAddress_ZipCode is correct.
findByAddress@ZipCode does not compile.
GitHub showcase: https://github.com/vinny59200/vv-spring-h2-custom-finder-relationship