The Concept, Use and Use of VO, DTO, DO, PO and POJO
Concept:
-
VO: value object value object/view object presentation layer object -
DTO (TO): Data Transfer Object -
DO: Domain Object is a tangible or intangible business entity abstracted from the real world. -
PO: persistent object -
POJO: plain ordinary java object -
BO: business object -
DAO: data access object
Working model:
The user sends a request (possibly filling in a form), and the form data is matched as VO in the presentation layer.
The presentation layer converts the VO into the DTO required by the corresponding method of the service layer and transmits it to the service layer.
The service layer first constructs (or reconstructs) a DO according to the data of the DTO, and calls the business method of the DO to complete the specific business.
The service layer converts the DO into the PO corresponding to the persistence layer (you can use the ORM tool or not), calls the persistence method of the persistence layer, passes the PO to it, and completes the persistence operation.
A reverse operation, such as reading data, is converted and transferred in a similar way.
Simple diagram:
Simple memory method: take SSM as an example
Controller layer: public List<UserVO> getUsers(UserDTO userDto); Service layer: List<UserDTO> getUsers(UserDTO userDto); DAO layer: List<UserDTO> getUsers(UserDO userDo);