Java – Dao class method naming

I'm using spring MVC and hibernate to build a small java web application. I'm confused about the naming of Dao class methods

For example, I have an invoicedao Java class, I think it should include the following methods:

Save(Invoice newInvoice);
Void(Invoice oldInvoice);
getInvoiceByID(Long invoideID);

But my boss said that the best practice said that I should have a method name in the Dao class, as follows:

add(Invoice newInvoice);
update(Invoice oldInvoice);

This doesn't make sense to me because I'm not sure how to name the invoice update?!!

Then someone can guide me and tell me whether my method is named incorrectly? In other words, I should only use add, update, or I can use any name, which is still considered a best practice

thank you

Solution

Canceling invoice is a business operation I would say that this logic exists in your service layer You update the invoice to mark it as invalid, and then pass it to the data layer for saving

The data layer should contain pure crud type methods, i.e. add / save / find

With many modern data frameworks, you don't even need to write a data layer... See, for example http://blog.springsource.org/2011/02/10/getting-started-with-spring-data-jpa/

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>