ADF Bussiness Components: In-Memory Sorting and Filtering
来源:互联网 发布:沭阳12345网络问政 编辑:程序博客网 时间:2024/06/03 15:47
When we work with the ADF Business Components, we work with the View Objects that retrieves its rows from database. This is the default behavior we may need to change sometimes. It is much efficient to work with the data in the memory in such cases which promotes reuse. Once we have the view object with the rows populated from the database, we can work with the existing rows in memory, we can sort, filter, search the existing view object rows without re-querying the database. This will greatly help us to minimize the database round-trip.
View objects has SQL MODE that determines whether to use existing rows in memory or retrieve data from the database each time it is referenced. The view object has 3 different SQL mode;
QUERY_MODE_SCAN_DATABASE_TABLES - Get the rows from database. This is the default mode.
QUERY_MODE_SCAN_VIEW_ROWS - Use the existing rows.
QUERY_MODE_SCAN_ENTITY_ROWS - Use entity objects rows (rows in the entity cache, valid only for entity-based view objects)
We can use setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS) method to set the View Object SQL mode to use the existing rows in memory. After we change the SQL mode, new setting will take effect the next time we call the executeQuery() method.In order to do in-memory sorting filtering we must first set the SQL Query Mode ViewObject.QUERY_MODE_SCAN_VIEW_ROW for a view object. This will make sure the existing view object rows will be using without re-querying the database.
We can use the setSortBy("attributeName desc") method to do in memory sorting. This will take effect next time we invoke executeQuery() method on the view object.
In order to do filtering on view objects row we can use applyViewCriteria() or findByViewCriteria() methods, again the changes will take effect after executeQuery(). Both methods can be executed to retrieve rows from database or to use the existing rows of View Object instance. Below is the flags that is used to set the CRITERIA MODE mode which is set by setCriteriaMode() method on the ViewCriteria object;
ViewCriteria.CRITERIA_MODE_QUERY // Uses database.
ViewCriteria.CRITERIA_MODE_CACHE // Uses rows in memory without querying the database.
Below is the code snippet that implements in-memory sorting and filtering;
// Get View Object Instance and retrieve rows from the database
ViewObject allEmployees = applicationModule.findViewObject("EmployeesView");
allEmployees.executeQuery();
//Call helper method to display all the employees without sorting and filtering
displayEmployees(allEmployees);
// Lets tell to use all the existing rows of the view object without requerying the database
// and then do in-memory sorting and then display the sorted rows
allEmployees.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
allEmployees.setSortBy("Salary desc");
allEmployees.executeQuery();
displayEmployees(allEmployees);
// Lets implement in memory filtering and display only whose first name starts with R
// First lets create view criteria and set the criteria mode
ViewCriteria viewCriteria = allEmployees.createViewCriteria();
ViewCriteriaRow viewCriteriaRow = viewCriteria.createViewCriteriaRow();
viewCriteriaRow.setAttribute("FirstName","LIKE 'R%'");
viewCriteria.add(viewCriteriaRow);
viewCriteria.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
allEmployees.applyViewCriteria(viewCriteria);
allEmployees.executeQuery();
displayEmployees(allEmployees);
If want to further modify the existing behaviour for sorting we can override the following methods;
public void sortRows(Row[] rows)
public Comparator getRowComparator()
You can download the source code/project that runs on HR schema by clicking HERE.
- ADF Bussiness Components: In-Memory Sorting and Filtering
- MVC 5 with EF 6 in Visual Basic - Sorting, Filtering and Paging
- Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application
- In-memory Computing with SAP HANA读书笔记 - 第三章:Software components and data replication methods
- Telerik Grid Server Side Paging, Sorting and Filtering
- Date and Time in ADF
- Object and Components in a Financial System
- PrimeNG ——Let Filtering, Sorting and Lazy loading work together!
- [比较编程]Sorting in Ruby and Python
- System Memory,AGP Memory and Video Memory in D3D.
- Introduction to ADF Data Visualization Components - Graphs, Gauge, Maps, Pivot Table and Gantt
- Quickly creating, deploying and testing a WebService interface for ADF Business Components
- Spatial Filtering and Median Filtering
- The bussiness flow between DWM and ECC
- Some new and enhanced components coming in Tiburon
- Creating Components: Object Oriented, Concurrent, and Distributed Computing in Java
- components and building system in RDK for TI 8168
- Locating code and data in memory (Scatterloading)
- Oracle ADF Table Tree TreeTable 部分属性介绍及效果预览
- iOS 快捷键~文件和编辑代码
- JavaScript 工作线程实现方式
- Oracle Fusion Middleware各产品解释
- thymeleaf实现简单的条件搜索并分页搜索功能
- ADF Bussiness Components: In-Memory Sorting and Filtering
- Dubbo Monitor 配置
- 怎样在session范围内保存ADF UI组件状态
- java播放音乐
- ADF How to 每隔几秒保存一次用户输入
- JSONObject(net.sf.json)简介
- vmware安装Mac后找不到光驱问题
- dubbo工作原理,集群容错,负载均衡
- spring注解注入:<context:component-scan>详解