Oracle ADF Business Components uses a sophisticated caching system to improve performance and maintain consistent views of data. Understanding how the caching system works is important for understanding how your business components will behave at runtime.
Every view object instance controls its own cache, called its view cache. This cache holds a collection of view rows. When a view object retrieves data from the datasource, it creates a view row to represent that row of data and adds the instance to the view cache. Each view attribute of this view row is populated, but how it's populated depends on whether or not the view attribute is mapped to an entity attribute.
If a view attribute is not mapped to an entity attribute, the view attribute is populated directly with the value from the datasource.
For example, consider a view object, CustomerOrdersView
,
with the SQL query
SELECT CUSTOMERS.CUSTOMER_ID, CUSTOMERS.CUST_FIRST_NAME,
CUSTOMERS.CUST_LAST_NAME, Orders.ORDER_ID, Orders.ORDER_DATE,
Orders.ORDER_TOTAL
FROM CUSTOMERS, ORDERS Orders
WHERE CUSTOMERS.CUSTOMER_ID = Orders.CUSTOMER_ID
and with view attributes:
CustomerId
CustFirstName
CustLastName
OrderId
OrderDate
OrderTotal
Suppose that OrderId
, OrderDate
, and
OrderTotal
are not mapped to any entity attributes.
Now, suppose an instance of CustomersOrdersView
,
MyCustomersAndOrders
, executes its query. The first row returned
by the query is
CUSTOMER_ID | CUST_FIRST_NAME | CUST_LAST_NAME | ORDER_ID | ORDER_DATE | ORDER_TOTAL |
---|---|---|---|---|---|
501 | John | Doe | 1137 | 01-AUG-03 | 573 |
Then the OrderId
, OrderDate
, and
OrderTotal
view attributes for the first view row added to the
view cache will be directly populated with these values.
If a view attribute is mapped to an entity attribute, the view object instance follows this procedure:
For example, consider the CustomerOrdersView view object definition
mentioned above. Suppose the view object attributes CustomerId
, CustFirstName
, and CustLastName
are mapped to
entity object attributes with the same name in an entity object called
Customers
. When the first view row of the MyCustomersAndOrders view
object instance is created, it will be populated with pointers to a row
in Customers
' entity cache:
Using the entity cache allows you to do the following:
CustomersOrdersView
will each contain a view row referring to
Customer 501, as will an independent instance of a view object with
the SQL
SELECT * FROM CUSTOMERS
By basing the view attributes CustomerId
,
CustFirstName
, and CustLastName
from both view
object definitions on the same entity object attributes, the data
501, "John", and "Doe" will only need to be stored once (in
Customers
' entity cache) rather than three times (in view caches for
both instances of CustomersOrdersView
and for the
instance of CustomersView
).
MyCustomersAndOrders
' cache will return many rows corresponding to Customer 501: One for each
order that Customer 501 has placed. By basing the view attributes
CustomerId
, CustFirstName
, and CustLastName
on corresponding entity cache, the data 501, "John", and "Doe" will
only need to be stored once (in a single row of Customers
' entity cache) rather than once for each of Customer 501's rows.
OrderDate
in one row of MyCustomersAndOrders
, and that
attribute is not mapped to an entity attribute, the value will become
inconsistent with other views of the same order. However, if you
change the view attribute CustFirstName
in one row of
MyCustomersAndOrders
, and that attribute is mapped to an entity object
attribute, the change will actually happen in the entity object cache,
and be visible with all other views of the same customer.
If you do not need any of these advantages, however, you may want to eliminate the entity cache, because creating and storing the pointers adds a small amount of overhead. For more information, see the related topics list.
Each application module instance has an entirely separate set of caches. For this reason, it is very important that you know how to tune Oracle ADF Business Components so that it will scale for large numbers of application module instances, if you expect to have a large number of simultaneous users. For more information, see the related topics list.
Introducing Oracle ADF Business Components
About Oracle ADF View Objects
About View Object Attributes
About Oracle
ADF Entity Objects
About
Entity Object Attributes
About View Object and View Link Instances
About
Oracle ADF Application Modules
Bypassing Entity Caching
Bypassing View Caching
Scaling
Multiple Transactions
Copyright © 1997, 2004, Oracle. All rights reserved.