1. Basic definition
PO (Persistence object persistence) is a Java Bean that works directly with a persistent layer database (Model,entity,bean and so on), except for the private member variable, only its corresponding Set/get method,
And its variables are generally the same as the columns in the database table (except for the names).
VO (Value object) in addition to the exact same variables as the PO, Set/get method, but also can have other variables, but do not have to deal with the database, you can use the object as stateless object.
2. Why use VO instead of a PO instead?
First, the PO is a persistent class, and its property changes are likely to lead directly to data changes in the database, without knowing why (why is the data in my database changing?). )。 After the introduction of VO can be very good
To solve similar problems, it will even help you to solve the direct and convenient interaction between the page (jsp,freemarker,asp,aspx) and the control layer without worrying about the changes in the various properties that will result in the database
Data changes, which are of great benefit to the persistence, transients, and de-tubes that occur when using hibernate to control its operational data.
3, the use of VO should pay attention to the problems
After using VO to be aware of its scope of activities to be controlled in the service layer, controller layer, presentation layer, not into the DAO layer or even the database (it is not generally possible to affect the database), the same PO Also
Can only appear in the DAO Layer and database (database directly and PO interaction), but not in the service layer, controller layer, presentation layer.
As a result, both Po and Vo appear on the service layer and are converted appropriately in the service.
Considerations for using PO and VO in Java EE