Object terminology in Java (po/pojo/vo/bo/dao/dto) __java

Source: Internet
Author: User
Tags one table

after referring to a large amount of information about various O, record the understanding and application that I have summarized as correct:


1. PO (Persistant object) Persistent object

(interpreted as the DAO layer: The Received and returned Java Bean, which is typically written in the model package)

1. Sometimes also referred to as the data object, the corresponding database of entity, you can simply think of a PO corresponding to a database of records, multiple records can be set with the PO. 2. The concept of the O/R mapping occurs without the O/R mapping and there is no such concept. 3. The PO should not contain any operations on the database.

2, VO (Value object) value Objects /View Object Presentation Layer Object

(understood as the view layer: the Java bean used for display)

1. Main corresponding page display (Web page (jsp ...) /SWT, swing interface), so it can correspond to a table, or not (most of the case is a subset of all the field sets in a table), depending on the needs of the business. 2. The difference from the DTO is that the DTO is used for interface-free web service transmissions and Vo is used for the display of interfaces, and the DTO can be converted to VO for the foreground. 3. For example, in struts, using Actionform as VO requires a conversion because the PO is object-oriented and Actionform is corresponding to the view, which is to synthesize a actionform of the attributes to be displayed by several po. You can use the Beanutils copy method.


3. BO (business object) business Object

(understood as the service layer: Received and returned Java beans)

1. From the business model perspective, see the domain object in the UML component domain model. Java objects that encapsulate business logic, and combine PO,VO for business operations by invoking DAO methods. 2. According to business logic, the encapsulation business logic is an object, can include multiple po, usually need to convert Bo into a PO, in order to persist data, on the contrary, the PO from DB, need to be converted into Bo to be used at the business level. 3. There are three kinds of concepts about Bo 1. Contains only the properties of the business object; 2. contains only business methods; 3.   Both are included. In practical use, it is not important to think which concept is right, the key is to apply the actual application of the need for their own projects.

4, POJO (plain ordinary Java object) Simple irregular Java objects

(understood as each layer: the received and returned Java Bean collectively)

1. The unified concept of abstraction, an intermediate object, can be transformed into a po, a DTO, a VO (or a PO, a DTO is the name of a different specific stage of Pojo). 2. After the Pojo is persisted ==〉po (at run time, the Pojo is converted to Po,po by the cglib of the hibernate, and the properties and methods used to manage the Pojo state of the database are increased relative to entity. PO for programmer is completely transparent, because it is the runtime generated PO, so you can support incremental compilation, incremental debugging. ) 3. The Pojo transmission process ==〉dto 4. Pojo as the presentation layer ==〉vo

5. DAO (data Access Object)

1. Sun is a standard Java EE design pattern, this pattern has an interface is DAO, responsible for the PO persisted to the database, but also responsible for the database query result set map to PO. 2. Provides an interface for the business layer. This object is used to access the database (CRUD operations). Typically used in conjunction with PO, DAO contains various methods of operation of the database. By its method, combine the PO to carry on the related operation to the database. Sandwiched between business logic and database resources. With VO, Provides CRUD operations for the database.

6. DTO (Data Transfer object) data transfer Objects

(understood as the controller layer: Received and returned Java beans)

1. It should not contain business logic when it needs to be transmitted across processes or remotely. 2. For example, a table has 100 fields, then the corresponding PO has 100 attributes (in most cases, the data in the DTO comes from more than one table ). But the view layer only needs to display 10 fields, and there is no need to pass the entire PO object to the client, so we can use the DTO with only these 10 attributes to transfer the data to the client, which does not expose the server-side table structure. When the client is reached, if the object is used to display the interface, then its identity becomes VO.

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.