You can dynamically define a new view object and add an instance of it
to an application module's data model at runtime by calling
createViewObjectFromQueryStmt()
on the application module.
Note: The view object instance you create will have no entity usages; that is, all of its attributes will be transient. For more information, or to add an instance of a view object with entity usages, see the Related topics list.
To add a view object instance with a new SQL-only definition at runtime:
String
containing the name you want to give the
instance in the data model. For example, if this instance is to be
called OrdersForCustomer
, you would use the following
code:
String voInstanceName = "OrdersForCustomer";
String
containing the query for the view object.
Do not include a semicolon in the String
:
String query = "SELECT * FROM ORDERS";
createViewObjectFromQueryStmt()
passing in the
instance name and the query:
ViewObject ordVO =
myAM.createViewObjectFromQueryStmt(voInstanceName, query);
Note: If you create a view object using this method,
the query may be executed twice the first time you fetch data. The first
query collects data type and precision information, which is used in
subsequent queries to map data to the proper Java types and make the
query more efficient (by specifying precision where it is below the
maximum). For expensive queries, where executing twice causes a
performance problem, you may want to create the view object with a
"dummy" where clause that returns no rows, call
getAttributeCount()
on the view object to facilitate the metadata
query and attribute definition, and then call setQuery()
to
change the query to the one you want. This way, the initial query is a
trivial, and far less expensive, query on the same dataset.
Ways to Add a View Object
Member to the Data Model at Runtime
About View Object Attributes
About Oracle
ADF View Objects
About Oracle ADF
Application Modules
About View
Object and View Link Instances
Accessing a Root-Level Application Module
Finding View Object Instances in the Data Model
Adding a View Object Instance Based on a Predefined View Object at Runtime
Adding a View Object Instance with a New Entity-Based Definition at Runtime
Copyright © 1997, 2004, Oracle. All rights reserved.