PO/POJO/BO/DTO/VO

Source: Internet
Author: User
---------------------------------------------------------
Po: Persistent Object
1. It is also called a data object. It corresponds to the entity in the database and can be considered as a record in the database corresponding to a po.
2. The persistence framework of Hibernate is closely related to insert/delet operations.
3. The PO should not contain any operations on the database.
---------------------------------------------------------
Pojo: plain ordinary Java object no rule simple Java object
An intermediate object can be converted to Po, DTO, and vo.
1. pojo persistence ==> Po
(During the runtime, cglib in hibernate dynamically converts pojo to Po. Compared with pojo, Po will add some attributes and methods used to manage the entity status of the database. Po is completely transparent to programmer. It is generated during runtime, so it supports incremental compilation and incremental debugging .)
2. pojo => DTO during transmission
3. Use pojo as the presentation layer => Vo
Po and VO should both belong to it.
----------------------------------------------------------
Bo: Business Object
Encapsulate the business logic as an object (which can include multiple Po. It usually needs to convert Bo into Po to realize data persistence. Otherwise, the PO obtained from the DB, must be converted to Bo for use at the business layer ).
There are three main concepts about Bo:
1. Only the attributes of the business object are included;
2. Only business methods are included;
3. Both are included.
In actual use, it is not important to consider which concept is correct. The key is that it is suitable for your project in actual application.
----------------------------------------------------------
VO: value object/view object performance Layer object
1. It mainly corresponds to Data Objects displayed on pages (web Pages/swt and swing interfaces.
2. It can correspond to or not to the table, depending on the business needs.
Note: In struts, a conversion is required when ActionForm is used for VO, because PO is object-oriented and ActionForm corresponds to view, you can use the copy method of BeanUtils to combine the attributes of several PO to display into an ActionForm.
----------------------------------------------------------
DTO (TO): Data Transfer Object Data transmission Object
1. When cross-process or remote transmission is required, it should not contain the business logic.
2. For example, if a table has 100 fields, the corresponding PO has 100 attributes (in most cases, data in DTO comes from multiple tables ). However, the view layer only needs to display 10 fields, and there is no need to pass the entire PO object to the client. In this case, we can transmit data to the client with only the DTO of these 10 attributes, in this way, the server-side table structure will not be exposed. After the client is reached, if this object is used for display on the corresponding interface, then its identity will be changed to VO.
----------------------------------------------------------
DAO: data access object
1. It is mainly used to encapsulate access to DB (CRUD operation ).
2. By receiving data at the Business layer, POJO is permanently converted to PO.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.