View Objects and View Links
- View Objects are used when we want some data to be displayed on page.
- View Objects are used just for displaying purpose.
- View Objects access the result set of a SQL statement, it can be either based on the Entity Object or plain SQL query.
- All the view objects ends with the VO
- When we create the View Object (VO) one subclass will generate with setters and getters method.
We have four types of View Objects and they are:
1) Manual VO
2) Automatic VO
3) Validation VO
4) Property VO
Manual VO: If we are writing our own SQL query then it will be called as Manual VO.
Automatic VO: Automatic VO is when we select an Entity Object automatically it will select the Query.
Difference between Manual and Automatic VO is:
- If we want to perform DML operations then we can go for VO that should be based on Entity Object.
- We go for Manual VO if we are using simple SELECT statement.
NOTE: Note that when we create VO (View Object) all the table columns will be converted into attributes, hence here we call columns as attributes.
Validation VO:Validating the data in the Data Base, example using WHERE condition in the SELECT statement.
Property VO:Attributes / columns without Data Base columns comes under property VO. These attributes are also called as Transient attributes.
Example: Suppose there is a table which holds student marks so therefore it contains 6 columns to hold six subject marks for each student. There is no total column in the table to store the total marks of the student separately. Now in the output for display purpose we are taking TOTAL attribute, hence which is not from Data Base table and this TOTAL attribute is called Transient attribute.
Relationship between two View Objects having one common column in both the VO’s is called View Link. All the View Link objects end with the VL
Note that if we want to display Master Detail data then we go for View Links, where as if we want to perform DML operations on Master Detail data we go for Entity Association.
The below figure shows that how View Objects and View Links are interacting with Data Base, VO interacts with Data Base Directly or VO interacts with Data Base through the EO.