Friday Aug 24, 2012

In-Memory Filtering and RowMatch

Assumption

We have a view object named ExampleVO which is based on entity object ExampleEO, and this VO has an attribute called ExampleFlag. ExampleVO has a clause in the base query that only allows rows that match the criteria ExampleEO.ExampleFlag = ‘Y’. We have another view object named CreateExampleVO that is used to add new rows to the ExampleEO. Both these view objects have view link consistency enabled.

Observation


Now if we insert a row into CreateExampleVO with the value of ExampleFlag as ‘N’ one would expect that this row will not be included in the ExampleVO. This is not the behavior that is observed. We now have a row in the ExampleVO that does not match the clause. If view link consistency is enabled, any new row created by any view object based on the same entity is added (regardless of the query) to the row set of all VO’s based on that EO.

Solution

If the view object has a design-time WHERE clause like ExampleEO.ExampleFlag = ‘Y’, you can apply a RowMatch object to your view object to perform the same filtering in-memory.

The filtering expression of the RowMatch object you specify prevents new rows that don’t match the condition from being added.

You can add a RowMatch to the view object by creating the same clause in a view criteria and applying it. The mode for said view criteria should be set to ‘In-memory’.
Note: You don’t have to remove the where clause from the query

Relevant Links.
http://docs.oracle.com/cd/E21043_01/web.1111/b31974/bcadvvo.htm#BCGHDDAD

https://blogs.oracle.com/workingwithadf/entry/little_mysterious_rowmatch


Monday Jun 25, 2012

View Link inConsistency

What is View Link Consistency?

When multiple instances (say VO1, VO2, VO3 etc) of an EO-based VO are based on the same underlying EO, a new row created in one of these VO instances (say VO1)can be automatically added (without re-query) to the row sets of the others (VO2, VO3 etc ). This capability is known as the view link consistency. This feature works for any VO for which it is enabled, regardless of whether they are involved in a view link or not.

What causes View Link inConsistency?

View Link Consistency for a VO could be disabled by disabling jbo.viewlink.consistent for the VO (or globally), or by applying setAssociationConsistent(false). Otherwise, any of the following can cause View Link inConsistency. 

1. setWhereClause

2. Unreferenced secondary EO

3. findByViewCriteria()

4. Using view link accessor row set

Why does this happen - View Link inConsistency? Well, there can be one of the following reasons.

a. In case of 1 & 2, the view link consistency flag is disabled on that view object.

b. As far as 3 is concerned, findByViewCriteria is used to retrieve a new row set to process programmatically without changing the contents of the default row set. In this case, unlike previous cases, the view link consistency flag is not disabled, meaning that the changes in the default row set would be reflected in the new row set. 

However, the opposite doesn't hold true. For instance, if a row is deleted from this new row set, the corresponding row in the default row set does not get deleted. In one of my features, which involved deletion of row(s), I observed that my changes were not reflected on UI. To resolve this apparent "view link inconsistency" issue, I replaced findByViewCriteria by applyViewCriteria.

b. For 4, it's similar to 3 - whenever a view link accessor row set is retrieved, a new row set is created.

Now, creating new row set does not mean re-executing the query each time, only creating a new instance of a RowSet object with its default iterator reset to the "slot" before the first row. Also, please note that this new row set always originates from an internally created view object instance, not one you that added to the data model. This internal view object instance is created as needed and added with a system-defined name to the root application module.

Anyway, the very reason a distinct, internally-created view object instance is used is to guarantee that it remains unaffected by developer-related changes to their own view objects instances in the data model.

About

ADF Tips and Tricks

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today