What is the DAO design pattern and what is the DAO factory pattern?

Updated on technology 2024-03-28
15 answers
  1. Anonymous users2024-02-07

    Introduction to Design Patterns.

    The full name of DAO is Data Access Object, database access object, the main function is used for data operations, and it belongs to the operation of the data layer in the standard development architecture of the program.

    2.Enterprise hierarchical architecture.

    Client: Because the BS development architecture is now adopted, it is generally accessed using a browser.

    Display Layer: Use JSP Servlet to display page effects.

    Business Layer: (Business Object): Combines multiple atomic DAO operations into a complete business logic.

    Data Layer (DAO): Provides multiple atomic DAO operations, such as adding, modifying, deleting, etc., all of which are atomic operations.

    In the whole DAO, the composition is actually based on the interface as the operation standard, that is, the client relies on the interface implemented by the DAO to operate, and the server needs to implement the interface specifically. A DAO consists of the following parts:

    1》 databaseconnection: a class that is responsible for opening and closing databases.

    2》VO: It is mainly composed of attributes, setters, and getter methods, and the attributes in the VO class correspond to the fields in the table, and the objects of each VO class represent every record in the table;

    3》DAO: The interface that mainly defines operations, defines a series of atomic operations of the database, such as: adding, modifying, deleting, querying by ID, etc.;

    4》IMPL: The real implementation class of the DAO interface, which completes specific database operations, but is not responsible for the opening and closing of the database;

    5》Proxy :** implements the class, which mainly completes the opening and closing of the database, and calls the operation of the real implementation class object;

    6》factory: factory class, get a DAO instantiation object through the factory class.

  2. Anonymous users2024-02-06

    Encapsulating the basic CRUD operations of an object into a DAO is the design pattern.

  3. Anonymous users2024-02-05

    Must be decoupled from other layers, you can use the ** mode, if the upper layer has a number of different classes to call the dao layer of multiple different objects, you can consider using the mediator mode, otherwise the call relationship is too complex will make the ** maintenance very troublesome.

  4. Anonymous users2024-02-04

    The DAO layer is the logical layer that deals with the database, which encapsulates some basic methods of database operations.

    The service layer is the business layer, and it is likely that you need to add a log to the log table when you register a user, so you can implement the service in the service and add transactions to the business. The benefits speak for themselves. If you're using UserDAO LogDao continuously on your C-layer, that's in case something goes wrong.

    It may cause the user to be added and the log not to be added.

  5. Anonymous users2024-02-03

    The client sends a request to the server.

    The server sends the request information to the servlet

    The servlet generates the response and passes it to the server.

    The response content is dynamically generated and is typically dependent on the client's request.

    The server returns the response to the client.

  6. Anonymous users2024-02-02

    Give specific entities to subclasses.

    Specific entity DAOs are specified, but no who they are.

    Only database-related operations are processed.

    No interface is provided at the service layer.

  7. Anonymous users2024-02-01

    General Province**.

    Easy to maintain. Generally, it is a unified save (new and updated), delete, get(id), getall(), etc., of course, inheriting the same class, you can also do more.

  8. Anonymous users2024-01-31

    public class userdaoimpl extends genericdaoimplimplements iuserdao

    Write a lot less**, increase type control automatic transformation, universal.

    GetBy like the one above, genericdaoimpl has been implemented, and the subclasses don't need to be written anymore and don't need to convert types.

  9. Anonymous users2024-01-30

    The DAO is only responsible for accessing the data, which is the model in the MVC

    Layer. But what data is accessed, in what order, and what result is returned, this is what the service layer does, corresponding to the controller layer in MVC.

  10. Anonymous users2024-01-29

    The DAO layer generally only adds, deletes, modifies and checks, operates the database, and has nothing else**, the service layer is the business logic layer, for example, user registration, the registration information is saved to the database, and the user information is designed to the business logic in the service layer, and it is necessary to judge whether there are duplicate usernames in the database before saving, if not, after encrypting the password, it is passed into the dao, and the dao is inserted in, so the **do not mix the business logic**, Receive the processed data from the service and save it. In this way, the layers are separated, it is easier to maintain, and the methods of the DAO layer are also easy to reuse.

  11. Anonymous users2024-01-28

    DAO is responsible for adding, deleting, modifying, and querying databases, and is responsible for single-table operations.

    Service calls DAOs to implement business logic operations, which involves multi-table operations, and sometimes a business logic operation calls methods from multiple DAOs.

    Therefore, the transaction is controlled in the service layer.

    For example: UserDao

    deptdao

    deptservice}

  12. Anonymous users2024-01-27

    The DAO is the data access layer, and the service is the business logic layer, which must be separated to reduce the degree of cohesion and facilitate maintenance.

  13. Anonymous users2024-01-26

    If you have to delete and check it, you can actually write it in one.,You don't even need to divide the layers.,The main reason for layering is to clarify your thoughts.,You can also expand it in the future! Developing good layering habits is good for future development! I'm also a beginner, so if I don't use it correctly, I just listen to what I say.

  14. Anonymous users2024-01-25

    The DAO layer is the data layer and the control layer, so it is logically clearer to separate.

  15. Anonymous users2024-01-24

    The DAO is only responsible for accessing the data, that is, the model layer in the MVC, but what data is accessed, in what order, and what result is returned, which is what the Service layer does, corresponding to the controller layer in MVC.

Related questions
8 answers2024-03-28

The adapter pattern transforms the interface of one class into another interface that the client expects, so that two classes that would otherwise not work together due to interface mismatch can work together. Also known as converter mode, transformer mode, wrapper mode (wrapping some existing classes so that they can have an interface that meets the needs). >>>More

6 answers2024-03-28

As for the design pattern, simply put, it is a kind of architecture for the structure of the entire system when developing a large system, such as module division, hierarchy, etc., which is a high-level topic, which is done by software architects, and will not be understood without certain development experience.

3 answers2024-03-28

A template method pattern defines the skeleton of an algorithm in an operation, while deferring some implementation steps into a subclass. Template methods allow subclasses to redefine certain steps in an algorithm without changing the structure of the algorithm. >>>More

5 answers2024-03-28

1.OSD (On Screen Display) is a screen window design that implements human-machine interface in display products. >>>More

10 answers2024-03-28

1. What is a cloud warehouse?

In fact, a cloud warehouse is a warehouse that integrates warehousing, logistics and distribution. Such a warehouse can meet the needs of merchants to place orders online, and cloud warehouses to sort and ship, which is more accurate and efficient. >>>More