service layer and Dao have anything to do

Dao layer: The main job is to do data persistence layer, is responsible for some liaison tasks are encapsulated in this database, design DAO DAO layer interface design is first, and then you can call this interface module for data services treatment without concern for this particular interface implementation class is which class, it is very clear structure, data source DAO layer configuration.

dao layer Code Example:

 

 

service layer: mainly responsible for business logic of the application module design, service Service layer implementation to be called to the specific business logic interface to encapsulate Service layer DAO layer defined in favor of the independence of the common business logic and reusability, the program is very simple.  

service layer Code Example:

 

 

dao layer and the service layer relations: method often call dao layer, service layer data CRUD operations, real development, business operations involve manipulating data, while data manipulation often use the database, so the service layer method will often call dao layer.

Extended Information

Service level is based on the DAO layer, DAO layer can be established only after the establishment Service layer , and the layer is under the Service Controller layer , thereby Service Interface layer should call both DAO layer, it is just in the middle of a position of the layer . Each model has a Service interfaces each encapsulate a respective service processing method.

In the actual development mostly DAO layer is a tables were CRUD, are some of the fixed sentence , unless it comes to more complex business logic service layer, it may be more complex method of DAO layer to be added.

 

Guess you like

Origin www.cnblogs.com/111testing/p/11669352.html