What happens when a View Object is Executed ?

I am sure you would learn something new from this blog , thats the main intention of this blog 

What are View Objects : 

 
   View Objects are the  business components  that collect data from data source and the data can be modified/shape the data accordingly.
 
   Their are two types of View Objects :
One is Read-Only and the other is Updatable ViewObject which is based on Entity Object . 
 
 Lets us see the internal architectural understanding of View Object and what happens when we execute a query : 
 
     Internally before the view object hits the data source , it goes through few other stages which are as follows : 
 
   RowSets :  VO uses a special data structure known as RowSet to manage the collection of rows from a query on data source(Database). It has a default rowset or primary rowset ,So when ever for the first time if we execute the VO it first hits the default rowset.  
                    
Example : Lets us take a VO based on a query where it has a bind variable as DEPTID. So the query can have a bind vairable and each time you pass a value lets say DEPTID=10 
and again we pass DEPTID =20 . So each time you pass a variable it stores them in a rowset . If they already have a same rowset , it will consider the same rowset instead of creating new one . For example if DEPTID =10 is already their as rowset , it will consider the same instead of creating new one . 
 
  
Query Collection : 
   
   Query Collection is mainly used for caching the result of the executed query VO . A VO can have multiple query collections depending on the rowsets.
 
Example : If we have 2 rowsets where DEPTID =10 and DEPTID=20 . So the results of the executed VO with these bind variables are stored in Query Collection .
 
  
Now we understood what are the other layers that are to be used before hitting the data source . Now let us see how will it be executed with a example : 
 
 Example :  Lets consider a java code snippet where we execute a vo and retrieve the values 
     
          ViewObject vo = ApplicationModule.findViewObject(“EmployeesVO”);
           vo.executeQuery(); 
           Row row = vo.first();                                          // gets the first row
 
    Steps involved in excuting this VO are as follows : 
 
Image
 
1) ADF client starts interaction with the Application Module .
 
2) ADF Client looks for the requested View Object (EmployeesVO) instance in AM.
 
3) Now before executing the VO , it does as below  : 
       a) Checks for revelant Query Collection for Search Parameters (Bind Varibles ) ,                 If available uses the existing querycollection.
       b) If not present created a new Query Collection based on the Search                                 Parameters.
  
4) Once the QC is initialized , the new Rowset instance calls the                                           prepareRowSetQuery() on VO . This is used for placing your customcode before           Querycollection . (Eg: the Query for the rowset with the bind variable
 
5) This is followed by executeQueryForCollection() , which delegates the call for                query collection instance and JDBC call for particular Database . 
 
6) Now when a client tries to get the first row in result set by calling first() , as the            result set retrieves the first row it displays the first row .
 
What if the ViewObject is Based on Entity Object ?
 
  When the ViewObject is based on EO , an entity Instance will be created  and added to corresponding entity cache. 
 
Hope this helps ….. 
 
     
This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to What happens when a View Object is Executed ?

  1. Narasimha says:

    nice one sashank….

  2. Revathi says:

    Thanks a lot sashank

  3. Guru Tata says:

    Very Nice post sashank..
    I have a small doubt over here on Query Collection, if in my View Object i have 4 View Criterias, for suppose these view criteria are having 4 bind variables, if i executed these 4 view criteria, then will the query collection maintains 4 separate collection of data, if so how it can hold separate Query Collection, is that based on Bind variables you mean or anything different?
    Please let me know the answer,
    Thanking you in anticipation,

    • sashankpappu says:

      Hi Guru Tata ,

      Here I wanted to know you are mentioning 4 bind variables mean 4 values of a bind variable or 4 different variables. According to your question , we have one bind variable and different values assigned to it . If thats the case the query collection is completely based on the bind variable value .
      For Eg: for a bindvariable with value 10 has some results returned and in the same way for the same bindvariable with value 20 has some other results returned . these both are stored in 2 query collections . If the bind variable value , lets say 20 is already executed the result of it is retrieved from the existing query collections.
      Is this what you are thinking about ?

      regards ,
      Sashank P

      • Guru Tata says:

        ThankQ.. for reply,
        Here i have four different bind variables for suppose deptid,salary,manager like that i have different bind variables and different View Criterias, so each view criteria is haivng different bind variables applied, Then according to your explanation it will have four Query Collections if suppose department number is changing means for each department id that we pass dynamically will create separate QueryCollection right, now my doubt is cleared but, if suppose i have morethan 1000 departments in my organization let us assume for the different department id what we pass dynamically will create different query collection or it will use the existing one.. thats my doubt actually..

Leave a comment