Little mysterious RowMatch
Posted
by kishore.kondepudi(at)oracle.com
on Oracle Blogs
See other posts from Oracle Blogs
or by kishore.kondepudi(at)oracle.com
Published on Mon, 20 Dec 2010 22:21:51 +0530
Indexed on
2010/12/20
17:51 UTC
Read the original article
Hit count: 354
The simplest design i chose was to create an EO on the tax rates table and create two VO's called CertificateVO and ExceptionVO based on the same EO.So far so good.I wrote all the business logic in the EO and completed the model project.
The CertificateVO has the query as select * from tax_rates TaxRateEO where rate_type='CERTIFICATE' and similary the ExceptionVO is also built.
The UI is pretty simple and it has two tabs called Certificates and Exceptions and each table has a button to create a tax rate.The certificate tab is driven by CertificateVO and exception tab is driven by ExceptionVO.The CertificateVO has default value of rate_type set to 'CERTIFICATE' and ExceptionVO has default value of rate_type to 'EXCEPTION' to default values for new records.
So far so good.But on running the UI i noticed a strange thing,When i create a new row in Certificate i see the same row in Exception too and vice-versa.i.e; what ever row i create in one VO it also appears in the second one although it shouldn't be.
I couldn't understand the reason for behavior even though an explicit where clause is present.Digging through documentation i found that ADF doesnt apply the where clause to new rows instead it applies something called as RowMatch to them.
RowMatch in simple terms is a where condition applied to the VO rows at runtime.Since we had both VO's based on the same EO we have the same entity cache.The filter factor for new rows to be shown in VO at runtime is actually RowMatch than the where clause defined in the VO.
The default RowMatch is empty as a result any new row appears in both the VO's since its from same entity cache.
The solution to this problem is to use polymorphic view objects which can do the row filter based on configuration or override the getRowMatch() method in the VOImpl and pass the custom where filter instead of default RowMatch.
Eg:
@Override
public RowMatch getRowMatch(){
return new RowMatch("rate_type='CERTIFICATE'");
}
similarly for ExceptionVO too.
With proper RowMatch in place new rows will route themselves to appropriate VO.
PS: The behavior(Same row pushed to both VO's from entity cache) is also called as ViewLink Consistency.
Try it out!
© Oracle Blogs or respective owner