Monday, 2 December 2019

How to create Query Based ViewObject in oracle ADF?

Query based ViewObject is used only to view data in ADF Application. This cannot be used to make any kind of data updations.

Let us take an example of a Query Based ViewObject to view the data of the Departments table.

Select ViewObect in the Menu. 


Here I have given the name "DepartmentDisplayVO". In the Data Source section select "Customer SQL Query" and click next.


Write the SQL query which will be used to show the records.


Here you can see the columns which were selected in the Query. You can select specific columns also in the query.





The Query-based ViewObject is created.


Now add an instance of ViewOject in Application Module.


Run the Application Module to see the results.


Below is the tester window showing records.


You will notice that the attributes of the data are grayed out, that means they cannot be modified. If you need to modify the column values then you need to create Entity based View Object.

What is a View Object in Oracle ADF??

View Object is used to view and update data in ADF Applications.

We need a database query to perform CRUD operation in the database, that query is represented by ViewObject in oracle ADF Application.

Analogy: In database if what has to perform CRUD operation, then what would you do? You will write a Query. Right?? That query is represented by ViewObject in ADF.

It basically contains database query to fetch or update the records.

View Object are basically of 4 types.

1. Entity based ViewObject

Entity based ViewObject is based on EntityObject of ADF application and can be used to create, read, update and delete or in short perform CRUD operation a database.

how to create an Entity based ViewObject??

2.  Query based ViewObject.

Query-based ViewObject is based on Query and can be used to view the record. 

3.  Static ViewObject.

Static ViewObject is based on the static Values defined in the ViewObject. This can be used to show static content.

4. Programmatic ViewObject.

Programmatic ViewObject is used where data is populated in the ViewObject programmatically. This data is populated by using the POJO class or some database Cursor or Procedure.

how to create a Programmatic ViewObject??