Standard Naming Convention for DAO Methods

Tom Tucker picture Tom Tucker · Dec 7, 2013 · Viewed 13.9k times · Source

Is there a standard naming convention for DAO methods, similar to JavaBeans?

For example, one naming convention I've seen is to use get() to return a single entity and find() to return a List of entities.

If there isn't one, what's the one your team is using and why?

Answer

Angular University picture Angular University · Dec 7, 2013

I am aware of conventions like the following:

  • methods starting with find perform select operations, and method names containing the search criteria, like findById, findByUsername, findByFirstNameAndLastName, etc.

  • modification methods start with create, update, delete.

Check out the conventions used by Spring Data JPA. This is part of the Spring framework that writes the DAOs automatically based on among other things inspection of the method name based on naming conventions.

get() for single entities does not seem to be a good option, as get is associated by Java developers to a Java-bean getter.