The distinction of various Java objects (PO, BO, VO, DTO, POJO, DAO, Entity, JavaBean, JavaBeans)

PO: persistent object , po (persistent object) is the Entity in the Object/Relation Mapping framework, and each attribute of po basically corresponds to a field in the database table. It is a pure Java object that conforms to the Java Bean specification, without adding other properties and methods. Persistent objects are created by insert database and deleted by database delete. Basically persistent object life cycle and database are closely related.


VO: Value Object , usually used for data transfer between business layers. Like PO, it only contains data. But it should be an abstracted business object, which can correspond to a table or not, depending on the needs of the business.

The presentation layer object (View Object) mainly corresponds to the data object displayed on the display interface, and a VO object is used to encapsulate the object data required for the entire interface display.


BO: Abbreviation for business object layer (Business Object) , a java object that encapsulates business logic, and performs business operations in combination with PO and VO by calling DAO methods. You can see an example online:

For example, a resume, with educational experience, work experience, social relations, etc.
We can map educational experience to a PO, work experience to a PO, and social relationships to a PO.
Create a BO object corresponding to the resume to process the resume, and each BO contains these POs.
When dealing with business logic in this way, we can deal with BO.


DTO: Data Transfer Object is a software application system for transferring data between design patterns. The data transfer target is often a data access object to retrieve data from a database. The difference between a data transfer object and a data interaction object or data access object is that one does not have any behavior other than storing and retrieving data (accessors and accessors). To put it simply, when we need the content of an object with 10 fields, but this object has a total of 20 fields, we do not need to transfer all the fields of the entire PO object to the client, but can repackage it with DTO and pass it to the client . At this time, if this object is used to display the corresponding interface, it is called VO.


JavaBean: A reusable component , that is, "write once, execute anywhere, reuse anywhere". Satisfies three conditions: ① the class must be concrete and public ② has a no-argument constructor ③ provides a public method consistent with the design pattern to expose the member properties of the internal field.

Main usage: Can be used in functions, processes, values, database access, and JSPs for any object that can be created with Java code.

There are two kinds: one is a JavaBean with a user interface (UI, User Interface); the other is a JavaBean without a user interface, which is mainly responsible for processing transactions (such as data operations , manipulating databases). JSP usually access is the latter JavaBean.

Classification: There are usually three categories: Session bean, Entity bean, and MessageDrivenBean

——Session bean Session component is a short-lived object that runs on the server and performs some application logic processing. It is established by the client application and its data needs to be managed by itself. There are two types: stateless and stateful.
- Entity bean entity component is a persistent object that can be called by other objects. Specify a uniquely identified identifier at build time and allow client programs to locate instances of beans based on entity bean identifiers. Multiple entities can access entity beans concurrently, and the coordination between transactions is done by the container.
——MessageDriven Bean消息构件,是专门用来处理JMS(Java Message System)消息的规范(EIB2.0)。JMS是一种与厂商无关的API,用来访问消息收发系统,并提供了与厂商无关的访问方法,以此来访问消息收发服务。JMS客户机可以用来发送消息而不必等待回应。

JavaBeans:JavaBeans 从狭义来说,指的是 JavaBeans 规范也就是位于 java.beans 包中的一组 API。从广义上来说,JavaBeans 指的是 API 集合,比如 Enterprise JavaBeans。 


POJO:POJO(Plain Ordinary Java Object)简单的Java对象,实际就是普通JavaBeans,是为了避免和EJB混淆所创造的简称。通指没有使用Entity Beans的普通java对象,可以把POJO作为支持业务逻辑的协助类。

POJO实质上可以理解为简单的实体类,顾名思义POJO类的作用是方便程序员使用数据库中的数据表,对于广大的程序员,可以很方便的将POJO类当做对象来进行使用,当然也是可以方便的调用其get,set方法。POJO类也给我们在struts框架中的配置带来了很大的方便。
一个POJO持久化以后就是PO
直接用它传递、传递过程中就是DTO
直接用来对应表示层就是VO

DAO: 数据访问对象是第一个面向对象的数据库接口,是一个数据访问接口(Data Access Object)。它可以把POJO持久化为PO,用PO组装出来VO、DTO。
DAO模式是标准的J2EE设计模式之一.开发人员使用这个模式把底层的数据访问操作和上层的商务逻辑分开.一个典型的DAO实现有下列几个组件:
1. 一个DAO工厂类;
2. 一个DAO接口;
3. 一个实现DAO接口的具体类;
4. 数据传递对象(有些时候叫做值对象).
具体的DAO类包含了从特定的数据源访问数据的逻辑,一般一个DAO类和一张表对应,每个操作要和事务关联。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324823636&siteId=291194637