Standard Naming Convention for DAO Methods

后端 未结 2 797
后悔当初
后悔当初 2020-12-30 08:53

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 s

2条回答
  •  星月不相逢
    2020-12-30 09:09

    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.

提交回复
热议问题