Differences between entity, JavaBean, model, POJO and domain

The difference between entity, JavaBean, model, POJO and domain. Java bean, POJO, entity and VO are actually Java objects, but they are only used in different occasions.

According to the spring MVC hierarchy:

JavaBean: presentation layer entity: service layer Dao: data access layer.

Entity is close to the original data, model is close to the business object ~ entity: it is dedicated to ef operations on database tables. Model: it provides data and data verification for pages, so the two can coexist. POJO: POJO is the abbreviation of plain ordinaryjava object, which is good, but it generally refers to ordinary Java objects that do not use entity beans, POJO can be used as an assistance class to support business logic. Domain: domain is often used in many foreign projects. It literally means domain.

In essence, POJO can be understood as a simple entity class. As the name suggests, the function of POJO class is to facilitate programmers to use the data table in the database. For most programmers, it is convenient to use POJO class as an object. Of course, it is also convenient to call its get and set methods.

- JavaBean: let's talk about JavaBean first. JavaBean is more a specification, that is, a Java object containing a set of set and get methods.

- POJO: ordinary Java objects generally implement the JavaBean standard for attributes. In addition, they can also contain some simple business logic (Methods).

- Po: the embodiment of POJO in the persistence layer. After the POJO is persisted, it becomes a PO. Po is more related to the database design level. Generally, Po corresponds to the data table. A PO is a record corresponding to the data table. - Dao: Po persistence to the database requires related database operations (cruq). These methods for database operations will be unified into a Java object, which is Dao.

Bo: POJO is embodied in the business layer. For business operations, it is more about wrapping objects from the business. For example, a user's Bo may include name, age, sex, privilege, group, etc. these attributes may be in multiple tables in the database, because each table corresponds to a PO, Our Bo needs these POS to be combined (or reassembled) to become a complete object in business.

- VO (value object / view object): the embodiment of POJO in the presentation layer. When we finish processing the data and need to show it, the POJO passed to the presentation layer becomes vo. It is used to present data.

- dto (data transfer object): when POJOs are transferred between systems. When we need to transfer data between two systems, one way is to serialize the POJO and transfer it. The POJO in the transfer state is dto.

- EJB (enterprise JavaBean): I think it is a collection of "function" JavaBeans. As mentioned above, JavaBeans are Java objects that implement a specification. EJB is a group of JavaBeans, which means that this group of JavaBeans are combined to realize the business logic of an enterprise group. A group of JavaBeans here are not randomly combined. They should meet the collocation that can realize a certain business function. For example, for a dress, including a hat, a dress, a pair of trousers and two shoes, it is EJB---------------------

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>