Google News
logo
JPA - Interview Questions
What all rules should we follow while declaring the custom methods in a repository?
Well that would be a pretty vast discussion. But for examples :
 
All the fetch methods must start with findBy (case-sensitive*). After that we need to give the Entity property name by which we want to fetch the result.
 
For example :
 
* If we have it in the Entity class, then findByName(String anyName) will work.
 
* But If the Employee Entity does not have property like String name; , and we declare the method findByName, then it will throw an exception.
Advertisement