the O/R Mapping is an abbreviation for the Object 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/R mapping, there are two basic and important things to understand, namely Vo,po.
Their relationship should be independent of each other, a VO can be just a PO part, can also be a number of PO composition, the same can also be equated to a PO (refers to their attributes). In this way, the PO is independent, the data persistence layer is independent, it will not be interfered by any business, the business logic layer is independent, it will not be affected by the data persistence layer, the business layer is concerned about business logic processing, but if we do not use the data persistence layer, or do not use hibernate , then Po and VO can also be the same thing, although this is not good.
VO, a value object, a PO, a persistent object (Persisent objects), which are made up of a set of properties and properties of the get and set methods. Structurally, they are nothing different. But it is completely different from its meaning and nature:
First: Vo is created with the New keyword and is reclaimed by the GC. The PO is created when new data is added to the database, and is eliminated when data in the database is deleted. And it can only survive in a database connection, and the disconnection is destroyed.
Second: Vo is a value object, the precise point is that it is a business object, is living in the business layer, is used by business logic, it is the purpose of survival is to provide a place for the data to survive. The PO is stateful, and each property represents its current state. It is the object representation of the physical data. Using it, we can decouple our programs from physical data and simplify the transformation between the object data and the physical data.
Third: The properties of VO are different depending on the current business, that is, each of its properties corresponds to the name of the data required for the current business logic. The properties of the PO correspond to the field one by one of the database table.
PO (Persistant object) persistent objects, usually corresponding to the data Model (database), itself also has some processing of the business logic. Can be seen as a Java object mapped to a table in the database. The simplest PO is a record in a table in the corresponding database, and multiple records can be used with a collection of PO. The PO should not contain any operations on the database.
VO (Value object) value objects, typically used for data passing between business tiers, are just like the PO and contain only data. But it should be abstracted out of business objects that can correspond to tables, or not, depending on the needs of the business. Individuals feel the same DTO (data transfer object) that is passed on the web.
to (Transfer object), a data transfer object that transmits objects between different relationships in the application.
BO business object, from the business model perspective, see the domain objects in the UML component Domain model. A Java object that encapsulates the business logic, by invoking the DAO method and combining Po,vo for business operations.
POJO (Plain ordinary Java object) simple, non-regular Java objects are purely traditional Java objects. In some object/relation mapping tools, the Persisent object that maintains database table records is a pure Java object that conforms to the Java Bean Specification and does not add other properties and methods. My understanding is the most basic Java Bean, only attribute fields and setter and getter methods.
DAO (Data Access Object), the most important is to access the data class, a DAO corresponding to a Pojo object, is a sun's standard Java EE design pattern, this pattern has an interface is DAO, it negative persistence layer operation, provide interface for the business layer , which is used to access the database, usually in conjunction with the PO, the DAO contains various methods of operation of the database. Through its method, combine the PO to carry on the related operation to the database. Sandwiched between business logic and database resources. With Vo, provides a crud operation of the database.
A DTO (data Transfer object) Data transfer object, rarely used, is basically put into DAO, and it just plays the role of transition. It is mainly used for remote calls, etc. where large quantities of objects need to be transferred. For example, if we have 100 fields in a table, then the corresponding PO has 100 attributes. However, as long as we display 10 fields on the interface, the client uses the Web service to fetch the data, and there is no need to pass the entire PO object to the client, we can pass the result to the client with a DTO with only these 10 attributes, thus not exposing the service-side table structure. After reaching the client, if the object is used to display the corresponding interface, then its identity will be converted to VO.
PO VO DAO DTO BO to concept and difference