Skip to main content

Explicitly enabling in-memory sorting for a view object

Sharing a tip that I learned while debugging an issue ;)
When you try to sort a UI component such as af:table bound to a view object, framework by default fire SQL ORDER BY clause if the selected column is not a transient one, otherwise framework will go for an in-memory sort by calling setSortCriteria(...) on the ViewObject.

You can override this default behavior by setting a custom property on the ViewObject. This make sense if your view object is a programmatic  or transient view object or if the view object contains uncommitted rows.To do this, you need to set a property named PROP_ALWAYS_USE_SORT to true (available in 11.1.1.7.0 release). When PROP_ALWAYS_USE_SORT is 'true', framework will always go for in-memory sorting.

Example:
empVO.setProperty(ViewObject.PROP_ALWAYS_USE_SORT, "true");

Warning: Note that when you enable in-memory sorting, framework will fetch all the records from the DB before performing the sort. So it makes sense only if you have limited number of rows.

Comments

Anonymous said…
hi Jobinesh,

May be this is what I was exactly looking for. But my ViewObject doesnot have that 'PROP_ALWAYS_USE_SORT' static variable. I am using Jdev 11.1.1.6.0.

In which version it is supported.

If you can , please see my forum thread. I need solution for this

https://forums.oracle.com/forums/thread.jspa?threadID=2531973&tstart=0


Regards,
Neha..
Jobinesh said…
Neha,
This property is available in 11.1.1.7.0
elliottbrown777 said…
Thanks for the info. I guess I am looking for a way to do this declaratively from ADF Faces. From what I can gather from section 27.5, I see a way to sort in memory if I am writing the code to interact with the view object. But I am trying to use af:table and data binding and not write the low-level code. Since the rich-client af:table has a sorting capability built-in, I want to have a way to tell the framework to sort in memory. To get more info please visit http://researchpapergiant.com/research-paper-examples/.
BradW said…
You can also use the view to set the query mode.

vo.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);

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…