One, in the Java EE, often mention several objects (object), understanding their meaning can help us to better understand the object-oriented design thinking.
ORM is an abbreviation for Object Relational Mapping "Objects relational Mapping"
The popular point is that the object is bound to the relational database, and the object is used to represent the relational data. In the world of O/rmapping,
There are a series of important objects, common with Vo,po,dto,pojo,dao,bo.
1, Java various objects (Po,bo,vo,dto,pojo,dao,entity,javabean,javabeans) of the distinction
(i), POJO (plain old Java object): normal Java objects
- 1, different from the special Java objects (including inheritance constraints, etc.) and EJB. Pojo generally only has a series of properties and corresponding get, set methods.
- 2, simple Java object, is actually the ordinary JavaBeans, is to avoid and EJB confusion created by the abbreviation. By means of generic Java objects that do not use entity beans, Pojo can be used as an aid class to support business logic.
- 3, Ojo can be understood as a simple entity class, as the name implies that the role of Pojo class is convenient for programmers to use data tables in the database, for the vast number of programmers, can be very convenient to Pojo class as an object to use, of course, it is also convenient to call its Get,set method. The Pojo class also brings a lot of convenience to our configuration in the Struts framework.
- 4. Conversion:
- A Pojo is a PO after persistence
- It is the DTO that passes and passes directly through it.
- Directly used to correspond to the presentation layer is VO
(ii), PO (Persistant object): Persisted object
- 1, different from Pojo, must correspond to the entity in the database. A record for a PO corresponding database. The life cycle of a persisted object is closely related to the database and can only exist in connection, and the PO disappears when the connection is closed.
- 2, PO with respect to Pojo there are many different, such as PO will have to save the database entity state properties and methods. But ORM (object-relation mapping) pursues the goal is the PO and pojo consistent, so in the programmer's Daily development, is to use Pojo as a PO, and pojo into the PO function to the framework of hibernate and so on.
- 3, that is, in the ORM framework, each of the properties of Entity,po basically corresponds to a field in the database table. A pure Java object that conforms to the Java Bean Specification and does not add other properties and methods. Persistent objects are created by the Insert database and deleted by the database delete. Basically, the persistent object life cycle is closely related to the database.
(iii), DTO (Data Transfer object): Data transfer objects, formerly known as value Objects (Vo,value object)
- 1, the function is only to transfer data between the various subsystems of the application, display in the presentation layer. Unlike Pojo, a dto does not correspond to an entity, it may store only some of the attributes of the entity or join other properties that meet the transport requirements.
- 2, usually for the business layer between the data transfer, and PO is just like the data only. But it should be abstracted out of business objects that can correspond to tables, or not, depending on the needs of the business.
- 3, the Expression Layer object (View object), mainly corresponds to the display interface displays the data object, with a Vo object to encapsulate the entire interface to display the required object data.
- 4. DTO: Data Transfer object, which is a software application system for transferring data between design patterns. The goal of data transfer is often to retrieve data from the database. The difference between a data transfer object and an object or data Access object is a data (access and accessor) that does not have any behavior other than storing and retrieving it. Simply put, when we need an object 10 fields of content, but this object has a total of 20 fields, we do not need to transfer the entire PO object all fields to the client, but can be re-encapsulated with DTOs, passed to the client. At this point, if the object is used to display the corresponding interface, it is called VO.
(iv), DAO (data Access Object)
- 1, provide an abstract interface to access the database, or persistence mechanism, without exposing the internal details of the database. DAO provides a match from the program call to the persistence layer.
- 2, the data Access object is the first object-oriented database interface, is a data access interface (object). It can be pojo persistent into Po, with PO assembled out VO, DTO.
- 3. DAO mode is one of the standard Java EE design patterns. Developers use this pattern to separate the underlying data access operations from the business logic on top. A typical DAO implementation has the following components:
-
- A DAO factory class;
-
- A DAO interface;
-
- A concrete class to implement DAO interface;
-
- Data passing objects (sometimes called value objects).
- The specific DAO class contains the logic to access data from a particular data source, typically a DAO class and a table, with each operation associated with the transaction.
(v), BO (business object): the service object.
- 1, the main is to encapsulate the business logic as an object, the object can contain one or more other objects. For example, "Principal" (principal), has "Name", "age" and other attributes, and "employee" (employee) has a 1-to-many relationship, this "Principal" can be used as a business-related po.
- 2, encapsulates the business logic Java object, by invoking the DAO method, unifies the Po,vo carries on the business operation.
- 3, specific can see an example on the Internet: such as a resume, education experience, work experience, social relations and so on.
- We can have an education experience corresponding to a PO, work experience corresponding to a PO, social relations corresponding 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.
(vi), JavaBean
- 1, a reusable component, that is "one-time write, anywhere execution, reuse anywhere." Three conditions are met:
- The ① class must be concrete and public.
- ② with no parameter constructor
- ③ public methods that provide a consistent design pattern expose the member properties to the internal domain.
- 2. Main purpose: Can be used in function, processing, value, database access and jsp any object that can be created in Java code.
There are two kinds:
- One is the JavaBean with user interface (Ui,user Interface);
- One is that there is no user interface, mainly responsible for processing transactions (such as data operations, manipulating the database) JavaBean. The JSP typically accesses the latter type of JavaBean.
- 3, classification: usually have session bean,entity Bean,messagedrivenbean three categories
- Session Bean Sessions Widget is a short-lived object that runs on the server and performs some application logic processing, which is established by the client application and its data needs to be managed by itself. It is divided into stateless and stateful two kinds.
- Entity bean a solid component, which is a persistent object that can be called by other objects. Specifies a uniquely labeled identity when established, and allows the client to locate the beans instance based on the entity Bean identity. Multiple entities can access entity beans concurrently, and coordination between transactions is done by the container.
- The Messagedriven Bean Message widget is a specification (EIB2.0) that is designed to handle JMS (Java message System) messages. JMS is a vendor-agnostic API that accesses messaging services by accessing messaging systems and providing vendor-agnostic access methods. JMS clients can be used to send messages without waiting for a response.
(vii), JavaBeans:
- 1, JavaBeans in the narrow sense, refers to the JavaBeans specification is located in the Java.beans package of a set of APIs. Broadly speaking, JavaBeans refers to a collection of APIs, such as Enterprise JavaBeans.
Several objects in Java (Po,bo,vo,dto,pojo,dao,entity,javabean,javabeans)