Skip to main content

Do you know what is a Composite View Object?

Oracle ADF Business Component stack offers something known as composite view object.Did you know that? The composite view objects help you to combine hierarchical results from two or more master detail view objects linked through a view link into a single composite view with flattened query retrieving the same result set.

For example, consider the Department and Employee hierarchies built using the Department and Employee view objects, linked through a view link. You can build a composite view object at runtime by combining these two view objects as shown in the following code snippet. This feature is explained in the Appendix of the book Oracle ADF Real World Developer’s Guide. You are free to download the Appendix from packtpub site. Yes, its absolutely free !!!

 //In application module implementation class   
  public void createCompositeDeptEmpVO() {  
     ViewDefImpl compVODef = (ViewDefImpl)createCompositeViewDef("DeptEmpDetail", "DeptEmpDetail");  
     compVODef.addViewUsage("Dept", "sample.adfguide.model.DepartmentVO");  
     compVODef.addViewUsage("Emp", "sample.adfguide.model.EmployeeVO",  
                 "sample.adfguide.model.DeptToEmpViewLink", "EmployeeVO", "Dept");  
     compVODef.addRowAttribute("EmployeeId", "Emp", "EmployeeId");  
     compVODef.addRowAttribute("FirstName", "Emp", "FirstName");  
     compVODef.addRowAttribute("LastName", "Emp", "LastName");  
     compVODef.addRowAttribute("EmpDepartmentId", "Emp", "DepartmentId");  
     compVODef.addRowAttribute("HireDate", "Emp", "HireDate");  
     ViewCriteria vc = compVODef.createViewCriteria();  
     ViewCriteriaRow vcr = vc.createViewCriteriaRow();  
     ViewCriteriaItem vcItem = vcr.ensureCriteriaItem("HireDate");  
     compVODef.putViewCriteria("DeptEmpDetailVC", vc);  
     compVODef.setOrderByClause("DepartmentName, FirstName");  
     ViewObjectImpl compDeptEmpVO = (ViewObjectImpl)createViewObject("DeptEmpDetail", compVODef.getFullName());  
     // If needed, retrieve the composite VO SQL statement  
     String sqlQueryStmt = compDeptEmpVO.getQuery();  
     System.out.println("sqlQueryStmt -" + sqlQueryStmt);  
     // If you want the data, iterate it like a normal view object.  
     while (compDeptEmpVO.hasNext()) {  
       Row r =;  
       System.out.println(r.getAttribute(0) + "-" + r.getAttribute(5));  
       // Process current row in whatever way is needed  

Well there many interesting stuff like this.
To learn more, you can download the Appendix of my book Oracle ADF Real World Developer’s Guide. This is absolutely free :)

Following are covered in the Appendix-
  • Life-cycle of an ADF Fusion web page with region 
  • Transaction management in Fusion web applications 
  • Building a dynamic model-driven UI with ADF 
  • Building composite view objects 
  • Building application modules with no database connection 
  • Looking up the UI component from the component tree at runtime 

To download the Appendix, click here



Siva said…
Hi Jobinesh,

Very useful post.


Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!