Java differences in the PO and VO

What is PO

PO (Persistence Object persistent objects) are directly dealing with the persistence layer database java Bean (model, entity, bean and other popular name are possible), which in addition to the private member variables, only the corresponding set / get method,
and its variable is usually almost (except the name) with the same database table columns.

What is VO

VO (Value Object Object value) in addition to the PO can tell exactly the same variable, set / get method, there can be other variables, but do not have to deal with that database, you can put the object as the object stateless.

Why separate use?

PO is the first persistent class, change its properties is likely to lead directly to data changes in the database without knowing the reason (Why change my data in the database?). Well after the introduction of VO
to solve similar problems, and even help you solve a good page (JSP, freemarker, asp, aspx ) and interact directly facilitate the control layer, without worrying about its various properties will change does not cause the database
data changes, then use it to hibernate control occur when the operation data persistence, transient, detached are of great benefit.

Note the use of VO

After using VO pay attention to the scope of activities to be controlled in the service layer, controller layer, presentation layer, but do not enter the dao layer and even database (usually can not affect the database), the same PO is also
only appear in the dao layer and databases (direct and interactive PO), not to appear in the service layer, Controller layer, presentation layer.
Therefore, PO and VO will appear in the service layer, but also the appropriate conversion service.

Guess you like

Origin www.cnblogs.com/jichi/p/11401341.html