POJO,JAVABEAN,ENTITY,DOMAIN,DTO,EJB differences

Source: Internet
Author: User

After searching the internet for definitions of all nouns, I summed up the following table

Some of the object abbreviations in Java should be understood.

2018.04.21

definitions and roles of many Java object abbreviations, differences and linkages
Type Defined Role Other
Pojo (Plain ordinary Java object) Simple Java objects Common JavaBeans, which can sometimes be used as VO (value-object) or DTO (Data Transfer object)
JavaBean To write JavaBean, the class must be concrete and public, and have a parameterless constructor. The simple thing is pojo, the complicated thing is EJB.
Ejb EJB (Enterprise JavaBean), defined for developing component-based enterprise multi-application standards Java's core code is the reply bean (Session bean), the entity bean, and the message-driven bean (Messagedriven bean)
Domain Domain is the scope, the boundary, and is used to batch the valid scope of a variable Also use this word to make a package, and then put some DAO class files inside. Net.baidu.domain.AddUserDao
Dto Data transfer objects (data Transfer object), which are objects that transfer data between design patterns The goal of data transfer is often to retrieve data from the database and transfer the value from the PO.
Entity Entity beans, typically used for ORM Object Relational mappings An entity is mapped into a single table, with no business logic code in common.
Po Persistant Object Persistent Objects The most vivid understanding is that a PO is a record in the database, such as a persistent object in hibernate
Vo ViewObject Presentation Layer Objects The data object that the main interface displays. For a Web page, use a Vo object to correspond to the value of the entire interface.
Dao Data Access Object Information It is mainly used to encapsulate access to the database, including the operation methods of various databases. It can be pojo to the PO, with PO assembled VO, DTO
Bo Business Object The main role is to encapsulate the business logic as an object. This object can include one or more other objects.

BO:business Object

The main role is to encapsulate the business logic as an object. This object can include one or more other objects. such as a resume, educational experience, work experience, relationships and so on.
We can have an education experience corresponding to a PO, the work experience corresponds to a PO, the relationship corresponds to a PO.
Create a CV-based Bo object to process resumes, each BO containing these po. When we handle business logic like this, we can deal with Bo.

DTO : Data Transfer Object data transfer objects, mainly used for remote calls and other places where a large number of objects need to be transferred.
For example, if we have 100 fields in a table, then the corresponding PO has 100 attributes. But we just show 10 fields on the interface,
The client uses the Web service to get the data, and there is no need to pass the entire PO object to the client.
At this point we can pass the result to the client with a DTO with only these 10 attributes, and this will not expose the service-side table structure. After the client is reached, if the interface is displayed with this object, then its identity will be converted to VO.


  The difference between VO, PO, Formbean :

Vo is a standalone Java object, and the PO is the one that hibernate incorporates into its entity Map.

The PO represents the Hibernata entity that corresponds to a record in the database, and the changes to the PO are reflected in the actual database when the transaction is committed.

Formbean is only the encapsulation of forms in HTML, in order to weaken the function of storing data in request and to convert the Get () method of the request object into the access value of the object.

VO and Po are structurally look, there is no difference. But in essence it is completely different.

Vo is created by the New keyword and reclaimed by GC. The PO is created when new data is added to the database, deleted when the data in the database is removed, and it can only survive in a database connection and is destroyed when the connection is disconnected.

Vo is a business object, used by business logic, and its survival is to provide a place for the data to survive. The PO is the representation of the data object, which simplifies the conversion of the object data to the physical data.

The properties of VO differ depending on the current business. The properties of the PO correspond to the field one by one of the database table. The PO object needs to implement the serialization interface.


In Hibernate, the core concept is the state management of the PO . There are three statuses for a PO:
1. The non-persisted VO, at this point is a memory object Vo, which is managed by the JVM for the life cycle.
2. The PO has been persisted, and during the session life cycle, the database connection is mapped at this time, and the lifecycle is managed by the database.
3. has been persistent, but now and the session has been hosted (detached), as Vo running. It can also go to another session to continue PO State management.

It is important to note that the PO is best used only in the persistence layer, and if it is used everywhere from the persistence layer, it will bring a small PO object maintenance overhead to hibernate.

POJO,JAVABEAN,ENTITY,DOMAIN,DTO,EJB differences

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.