Please disable your adblock and script blockers to view this page

Search this blog

Wednesday 13 December 2017

Use ViewObject Query Mode for In-Memory Sorting of data in Oracle ADF

Hello All

Previously I have posted about In-Memory filtering of ViewObject by changing ViewCriteria's query execution mode, Now this post is about In-Memory sorting of records in viewObject. By default sorting and filtering in viewObject works on the rows retrieved from DB

We can change ViewObject Query mode as per our requirement, There are 3 different SQL query mode

QUERY_MODE_SCAN_DATABASE_TABLES - Default query mode of ViewObject, Only rows from the database.

QUERY_MODE_SCAN_VIEW_ROWS - Use the rows in memory (DB n New rows).

QUERY_MODE_SCAN_ENTITY_ROWS - Use entity objects rows, valid for entity-based view objects)

Here I am taking Departments table of HR Schema to prepare model

Dropped Departments ViewObject as table on page and CreateInsert operation as button

Created a new row with DepartmentId 300 and after sorting on DepartmentId column we can see that only DB records are sorted

For In-Memory sorting of records added a button on page and created a method in managed bean that changes VO query mode- performs sorting - execute viewObject

import javax.faces.event.ActionEvent;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCIteratorBinding;

import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;

import oracle.jbo.ViewObject;

     * Generic Method to call operation binding
     * **/
    public BindingContainer getBindingsCont() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();

     * Generic Method to execute operation Binding
     * */
    public OperationBinding executeOperation(String operation) {
        OperationBinding createParam = getBindingsCont().getOperationBinding(operation);
        return createParam;

    /**Method to sort in-memory records by changing ViewObject Query Mode
     * @param actionEvent
    public void sortUsingDeptIdAction(ActionEvent actionEvent) {
        //Get Iterator of Departments table
        DCIteratorBinding iter = (DCIteratorBinding) getBindingsCont().get("Departments1Iterator");
        //Get ViewObject from iterator
        ViewObject vo = iter.getViewObject();
        //Change ViewObject query mode
        //Perform sorting
        vo.setSortBy("DepartmentId desc");
        //Execute ViewObject

And after clicking on InMemory Sort button

Cheers :) Happy Learning

1 comment :

  1. Excellent weblog here! after reading, i decide to buy a sleeping bag ASAP 1tb external hard disk