Problems with VO, DTO, BO, PO, DO

  • PO is the abbreviation of Persistant Object, which is used to represent the java object mapped to a record in the database. PO is only used to represent data without any data operations. Usually follows the Java Bean specification and has getter/setter methods.
  • DAO is the abbreviation of Data Access Object, used to represent a data access object. Use DAO to access the database, including insert, update, delete, query and other operations, used together with PO. DAO is generally in the persistence layer, completely encapsulating database operations, and the external exposure method prevents upper-layer applications from paying attention to any information related to the database.
  • VO is the abbreviation of Value Object, which is used to represent a java object that interacts with the front end. Some friends may have questions, can PO be used to transfer data here? In fact, the VO here only contains the data that the front end needs to display. For the data that the front end does not need, such as data creation and modification time and other fields, for the purpose of reducing the amount of transmitted data and protecting the database structure from leakage, It should not be reflected in VO. Usually follows the Java Bean specification and has getter/setter methods.
  • DTO is the abbreviation of Data Transfer Object, used to represent a data transfer object. DTOs are often used for data transfer between different services or different layers of services. DTO is similar in concept to VO, and usually the fields are basically the same. However, there are some differences between DTO and VO. This difference is mainly due to design concepts. For example, the DTO that an API service needs to use may be different from VO. Usually follows the Java Bean specification and has getter/setter methods.
  • BO is the abbreviation of Business Object and is used to represent a business object. BO includes business logic, often encapsulates calls to DAO, RPC, etc., and can convert between PO and VO/DTO. BO is usually located in the business layer and must be distinguished from the service layer that directly provides services to the outside world: BO provides basic business operations for basic business units and is designed to be an object called by the service layer business process. A business process may need to call multiple BOs. To be done.
  • POJO is the abbreviation of Plain Ordinary Java Object, which represents a simple java object. The PO, VO, and DTO mentioned above are all typical POJOs. DAO and BO are generally not POJOs and only provide some calling methods.

The following picture is more intuitive:
Insert image description here
Now you should know how to use it

Guess you like

Origin blog.csdn.net/hsadfdsahfdsgfds/article/details/130860375