|
Business Components | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.jbo.common.BaseObject | +--oracle.jbo.server.NamedObjectImpl | +--oracle.jbo.server.ComponentObjectImpl | +--oracle.jbo.server.ViewObjectImpl
The implementation of the
ViewObject
interface, the middle-tier class that manages
database queries and the view rows that result from executing queries.
A View Object's base definition is provided by a View Definition object, which is built from the meta-data stored in an XML file. The View Object inherits many of its definitions from its View Definition, but applications can override them in instances.
A View Object manages a view row set (ViewRowSetImpl
).
When the application calls a
RowSet
method on a View Object, the call is delegated to the
its view row set, which performs the actual operation.
A View Object persists until it, or the Application Module from which it was created, is explicitly deleted (using remove methods). You can use a given View Object definition more than once within an Application Module; the Business Component framework uses View instance names to distinguish between them.
ViewObject
,
RowSet
,
ViewRowSetImpl
Field Summary | |
static byte |
FETCH_ALL
A fetch mode that causes rows to be retrieved from a JDBC result set immediately, and then closes the result set. |
static byte |
FETCH_AS_NEEDED
A fetch mode that causes rows to be retrieved from a JDBC result set as the user navigates through the row set. |
static byte |
FETCH_DEFAULT
Not implemented. A fetch mode that causes all rows to be retrieved from a JDBC result set. |
protected java.lang.String |
mAssocClause
|
protected java.util.Vector |
mAssocRefs
|
protected java.util.Vector |
mAttrRefs
|
protected boolean |
mAutoPostChanges
|
static int |
mDefaultMaxActiveNodes
|
static int |
mDefaultMaxRowsPerNode
|
protected AttributeDef[] |
mKeyAttrRefs
|
protected java.lang.String |
mOrderBy
|
static boolean |
mUsePersColl
|
protected java.lang.String |
mUserDefinedQuery
|
protected oracle.jbo.server.ViewDefImpl |
mViewDef
|
protected ViewRowSetImpl |
mViewRowSet
|
protected java.lang.String |
mWhere
|
Fields inherited from class oracle.jbo.server.NamedObjectImpl |
mFullName,
mName,
mParent,
mProperties |
Fields inherited from class oracle.jbo.common.BaseObject |
TRACE_EVERY_ALLOC,
TRACE_NONE,
TRACE_OCCASIONAL,
TRACE_UNINITIALIZED |
Fields inherited from interface oracle.jbo.RowIterator |
SLOT_BEFORE_FIRST,
SLOT_BEYOND_LAST,
SLOT_DELETED,
SLOT_VALID |
Constructor Summary | |
ViewObjectImpl()
Constructs a new View Object. |
|
ViewObjectImpl(java.lang.String name,
oracle.jbo.server.ViewDefImpl voDef)
Constructs a new View Object. |
Method Summary | |
AttributeDef |
addDynamicAttribute(java.lang.String attrName)
Adds a dynamic attribute to this View Object. |
void |
addListener(java.lang.Object listener)
Registers an event listener with this View Object. |
void |
addOrderByClause(java.lang.String expr)
Appends an expession to the query's ORDER BY clause. |
void |
addWhereClause(java.lang.String expr)
Appends an additional WHERE clause to the query. |
void |
afterCommit(TransactionEvent event)
Handles events raised after a transaction has been committed. |
protected void |
afterEntityRemove(Entity srow)
Notification handler called before an entity row is removed. |
void |
afterRemove(TransactionEvent event)
Handles events raised after rows have been removed. |
void |
afterRollback(TransactionEvent event)
Handles events raised after a transaction has been rolled back. |
void |
applyViewCriteria(ViewCriteria criteria)
Applies the view criteria to this View Object. |
void |
beforeCommit(TransactionEvent e)
Handles events raised before a transaction is committed. |
protected void |
beforeEntityRemove(Entity entity)
Notification handler called before an entity row is removed. |
void |
beforeRollback(TransactionEvent e)
Handles events raised before a transaction is rolled back. |
protected boolean |
buildOrderByClause(java.lang.StringBuffer sqlBuffer,
java.lang.String defOrderByClause)
Builds the order-by-clause part of the query and adds it into the string buffer. |
protected boolean |
buildWhereClause(java.lang.StringBuffer sqlBuffer,
int noUserParams)
Builds the where-clause part of the query and adds it into the string buffer. |
protected void |
create()
Framework invoked method, called when the View Object is created. |
RowSet |
createDetailRowSet(java.lang.String rsName,
java.lang.String linkDefName)
Creates and returns an new detail row set for this row set iterator. |
ViewRowImpl |
createInstance(ViewRowSetImpl viewRowSet,
AttributeList attrValList)
Creates a view row instance. |
ViewRowImpl |
createInstanceFromResultSet(oracle.jbo.server.QueryCollection qc,
java.sql.ResultSet resultSet)
Internal: Applications should not use this method. |
Row |
createRow()
Creates a new view row. |
RowSet |
createRowSet(java.lang.String name)
Creates and returns a new row set for this View Object. |
RowSetIterator |
createRowSetIterator(java.lang.String name)
Creates and returns a new row set iterator for this row set. |
ViewCriteria |
createViewCriteria()
Creates a new view criteria object. |
java.util.Enumeration |
enumerateRowsInRange()
Creates and returns an enumerator of the rows in the range. |
void |
executeQuery()
Executes the query. |
AttributeDef |
findAttributeDef(java.lang.String name)
Finds a named attribute definition. |
Row[] |
findByEntity(int eRowHandle,
int maxNumOfRows)
Finds and returns view rows that use the entity row, identified by the entity row handle, eRowHandle . |
Row[] |
findByKey(Key key,
int maxNumOfRows)
Creates an array of rows matching a given key. |
AttributeDef |
findViewLinkAccessor(ViewLink vl)
Finds the View Link accessor attribute. |
Row |
first()
Navigates to the first row in the row set. |
Row[] |
getAllRowsInRange()
Returns an array of all rows in the iterator's range. |
ApplicationModule |
getApplicationModule()
Returns the application module to which this View Object belongs. |
int |
getAttributeCount()
Counts a View Object's attributes. |
AttributeDef |
getAttributeDef(int index)
Gets the attribute definition at the specified position. |
AttributeDef[] |
getAttributeDefs()
Constructs an array of attribute definitions. |
int |
getAttributeIndexOf(java.lang.String attrName)
Gets the index of an attribute given its name. |
int |
getBindingStyle()
Returns the binding style. |
int |
getCalculatedAttributeCount()
Counts the number of "calculated" attributes. |
Row |
getCurrentRow()
Returns the current row of the iterator. |
int |
getCurrentRowIndex()
Returns the absolute row index of the iterator's current row. |
int |
getCurrentRowSlot()
Returns the current row's slot status. |
DBTransaction |
getDBTransaction()
Gets the transaction within which this View Object operates. |
ViewRowSetImpl |
getDefaultRowSet()
Gets the default view row set. |
java.lang.String |
getDefFullName()
Returns the full name of the view definition from which this View Object was created. |
java.lang.String |
getDefName()
Returns the name of the view definition from which this view object was created. |
RowSet[] |
getDetailRowSets()
Returns an array of all detail row sets for this row set iterator. |
protected EntityDefImpl[] |
getEntityDefs()
Could be used to perform meta-data initializations like "custom" Properties that are calculated using the current transaction. |
long |
getEstimatedRowCount()
Makes an estimated count of the rows in this row set. |
int |
getFetchedRowCount()
Counts the number of rows fetched from the JDBC result set. |
byte |
getFetchMode()
Gets the current fetch mode. |
int |
getFetchSize()
Gets the row pre-fetch size. |
AttributeDef[] |
getKeyAttributeDefs()
Constructs an array of definitions of key attributes. |
RowSetIterator[] |
getMasterRowSetIterators()
Returns an array of all master row set iterators for this row set. |
int |
getMaxFetchSize()
Gets the maximum row fetch size. |
java.lang.String |
getOrderByClause()
Returns the query's ORDER BY clause. |
java.lang.Object[] |
getParametersAsStorageTypes()
Constructs an array of the bind values used for binding arguments to the query. |
AttributeDefImpl[] |
getPrimaryKeys()
Constructs an array of entity attribute definitions of the primary keys of the View Object's Entity Objects. |
java.util.Hashtable |
getProperties()
Retrieves all properties. |
java.lang.Object |
getProperty(java.lang.String propName)
Retrieves the specified property. |
java.lang.String |
getProxyClassName()
Returns the name of this View Object's proxy class. |
protected java.lang.String |
getProxyClassName(java.lang.String platform)
Returns the name of this View Object's proxy class, given a platform name. |
java.lang.String |
getQuery()
Returns the query statement. |
oracle.jbo.server.QueryCollection |
getQueryCollection()
Internal: Applications should not use this method. |
long |
getQueryHitCount(ViewRowSetImpl viewRowSet)
Counts the number of rows that would be returned if the View Object were executed with the current query. |
int |
getRangeIndexOf(Row row)
Returns the range index of a given row. |
int |
getRangeSize()
Returns the range size of the iterator. |
int |
getRangeStart()
Returns the absolute row index of the first row in the range. |
Row |
getRow(Key key)
Returns the first row matching a given key. |
Row |
getRowAtRangeIndex(int index)
Returns the row at a given range position. |
java.lang.Class |
getRowClass()
Gets the Java class of this View Object's rows. |
int |
getRowCount()
Counts the total number of rows in this row set. |
int |
getRowCountInRange()
Counts the rows actually in the range. |
Row |
getRowFromHandle(java.lang.Object hdl)
Internal: Applications should not use this method. |
java.lang.String |
getRowProxyClassName()
Returns the name of this View Object's row proxy class. |
RowSet |
getRowSet()
Gets the row set that this iterator belongs to. |
RowSetIterator |
getRowSetIterator()
Gets the row set iterator interface of this object. |
int |
getTransPostHandle()
Internal: Applications should not use this method. |
java.lang.String |
getUserDefinedQuery()
Gets the user-defined query, if one exists. |
oracle.jbo.server.ViewAttributeDefImpl[] |
getViewAttributeDefImpls()
Internal: Applications should not use this method. |
ViewCriteria |
getViewCriteria()
Gets the view criteria. |
java.lang.String |
getViewCriteriaClause()
Generates the WHERE clause expression from the view criteria. |
protected oracle.jbo.server.ViewDefImpl |
getViewDef()
Internal: Applications should not use this method. |
java.lang.String[] |
getViewLinkNames()
Constructs an array of names of View Links that involve this View Object. |
ViewLink[] |
getViewLinks()
Constructs an array of View Links that involve this View Object. |
ViewObject |
getViewObject()
Gets the View Object that contains the row set. |
java.lang.String |
getWhereClause()
Gets the query's WHERE clause. |
java.lang.Object[] |
getWhereClauseParams()
Constructs an array of the bind values currently specified for the query. |
boolean |
hasNext()
Indicates whether the iterator has a next row. |
boolean |
hasPrevious()
Indicates whether the iterator has a previous row or not. |
void |
insertRow(Row row)
Inserts a row into the row set. |
void |
insertRowAtRangeIndex(int index,
Row row)
Inserts a row into the row set. |
boolean |
isAssociationConsistent()
Returns the state of the association-consistent flag for this row set. |
boolean |
isAutoPostChanges()
Indicates whether auto-post-changes is enabled or not. |
boolean |
isDynamicAttribute(int index)
Indicates whether an attribute is dynamic. |
boolean |
isDynamicAttribute(java.lang.String name)
Indicates whether the named attribute is dynamic. |
protected boolean |
isForeignKey(oracle.jbo.server.ViewAttributeDefImpl attr)
Checks if a view attribute is involved in a View Link in which this View Object is detail. |
boolean |
isForwardOnly()
Indicates whether this row set is forward-only. |
protected boolean |
isQueryChanged()
Internal: Applications should not use this method. |
boolean |
isRangeAtBottom()
Indicates whether the iterator range contains the last row of the row set. |
boolean |
isRangeAtTop()
Indicates whether the iterator range contains the first row of the row set. |
boolean |
isReadOnly()
Tests whether this View Object is read-only. |
boolean |
isTransientTransactionListener()
Tests whether this transaction listener is transient or permanent. |
boolean |
isTransientTransactionPostListener()
Reports that this view object is not a transient transaction post listener. |
Row |
last()
Navigates to the last row in the row set. |
Row |
next()
Navigates to the next row in the row set. |
protected void |
notifyRowUpdated(ViewRowSetImpl vrs,
Row[] viewRows,
int[] attrIndices)
This method is invoked by the framework when updates are made to any attribute for rows in the given ViewRowSet for this ViewObject. |
void |
postChanges(TransactionEvent e)
This method is not implemented in this class. |
Row |
previous()
Navigates to the previous row in the row set. |
void |
remove()
Removes this View Object from its containing application module. |
void |
removeCurrentRow()
Removes the current row. |
void |
removeListener(java.lang.Object listener)
Removes an event listener. |
boolean |
removeMasterRowSetIterator(RowSetIterator masterRSI)
Removes the master row set iterator (masterRSI) from a master-detail View Link. |
void |
removeRowHandle(java.lang.Object hdl)
Internal: Applications should not use this method. |
void |
reset()
Resets the iterator. |
int |
scrollRange(int amount)
Scrolls the range. |
int |
scrollRangeTo(Row row,
int index)
Scrolls the range to a specified row. |
void |
setAssociationConsistent(boolean isConsistent)
Sets the association-consistent flag for this row set. |
void |
setAutoPostChanges(boolean bAutoPostChanges)
Sets the auto-post-changes flag. |
void |
setBindingStyle(int bindingStyle)
Sets the binding style. |
boolean |
setCurrentRow(Row row)
Designates a given row as the current row. |
boolean |
setCurrentRowAtRangeIndex(int index)
Designates a row at a specified position as the current row. |
protected void |
setFetchMode(byte fetchMode)
Sets the fetch mode. |
void |
setForwardOnly(boolean isForwardOnly)
Sets whether this row set will be forward-only or not. |
void |
setListenToEntityEvents(boolean b)
Sets the listen-to-entity-events flag. |
boolean |
setMasterRowSetIterator(RowSetIterator masterRSI)
Sets the master row set iterator in a master-detail View Link. |
void |
setOrderByClause(java.lang.String orderByClause)
Sets the query's ORDER BY clause. |
protected void |
setProxyClassName(java.lang.String platform,
java.lang.String proxyClassName)
Sets the name of this View Object's proxy class, given a platform name. |
void |
setQuery(java.lang.String query)
Sets the user-defined query. |
protected void |
setQueryChanged(boolean isChanged)
Internal: Applications should not use this method. |
int |
setRangeSize(int size)
Sets the range size for the iterator. |
int |
setRangeStart(int start)
Positions the range. |
void |
setTransPostHandle(int hdl)
Internal: Applications should not use this method. |
void |
setWhereClause(java.lang.String whereClause)
Sets the query's WHERE clause. |
void |
setWhereClauseParam(int index,
java.lang.Object value)
Sets a specified the bind value. |
void |
setWhereClauseParams(java.lang.Object[] values)
Sets the query's bind values. |
void |
showCursorUsage(java.io.Writer out)
Internal: Applications should not use this method. |
void |
sourceChanged(EntityEvent event)
Handles events reported to ( EntityListener )s. |
void |
validate()
Validates all view rows within this View Object. |
Methods inherited from class oracle.jbo.server.ComponentObjectImpl |
addListener,
createRef,
getCompListeners,
getRootApplicationModule,
isRegWithPiggyMan |
Methods inherited from class oracle.jbo.server.NamedObjectImpl |
getFullName,
getName,
getParent,
getPropertiesAsStrings,
setFullName,
setProperty |
Methods inherited from class oracle.jbo.common.BaseObject |
dumpState,
setTraceLevel,
setTraceWriter |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final byte FETCH_AS_NEEDED
setFetchMode(byte)
public static final byte FETCH_ALL
setFetchMode(byte)
public static final byte FETCH_DEFAULT
setFetchMode(byte)
protected oracle.jbo.server.ViewDefImpl mViewDef
protected java.util.Vector mAssocRefs
protected java.lang.String mAssocClause
protected java.lang.String mUserDefinedQuery
protected java.lang.String mOrderBy
protected java.lang.String mWhere
protected ViewRowSetImpl mViewRowSet
protected java.util.Vector mAttrRefs
protected AttributeDef[] mKeyAttrRefs
protected boolean mAutoPostChanges
public static boolean mUsePersColl
public static int mDefaultMaxRowsPerNode
public static int mDefaultMaxActiveNodes
Constructor Detail |
public ViewObjectImpl()
public ViewObjectImpl(java.lang.String name, oracle.jbo.server.ViewDefImpl voDef)
name
- the name to be assigned to the View Object.voDef
- a view definition.Method Detail |
protected void create()
This method can be overridden to perform custom initialization of the View Object. For example, it may set up a custom query statement based on the current running environment.
If sub-classed, super.create()
should be called before
any operations are performed.
public java.lang.Object getProperty(java.lang.String propName)
propName
- the name of the property.public java.util.Hashtable getProperties()
public final ApplicationModule getApplicationModule()
public java.lang.String getDefName()
public java.lang.String getDefFullName()
protected oracle.jbo.server.ViewDefImpl getViewDef()
Returns the view definition object from which this View Object was created.
public oracle.jbo.server.ViewAttributeDefImpl[] getViewAttributeDefImpls()
Returns an array of view attribute definitions.
This array includes dynamic attributes
(created through the addDynamicAttribute()
method)
on this View Object.
public ViewLink[] getViewLinks()
A View Link can use this View Object as either its source or destination. To determine whether it is the source or destination, use code such as:
viewLink.getDestination() == this
public java.lang.String[] getViewLinkNames()
A View Link may use this View Object as either its source or destination.
public boolean isReadOnly()
A View Object is read-only if it does not have a Primary Key, or if all its Entity Objects are read-only.
true
if this View Object is
read-only.public oracle.jbo.server.QueryCollection getQueryCollection()
Returns the query collection for this View Object's default row set.
public ViewRowSetImpl getDefaultRowSet()
This row set has the same name as this View Object.
public java.lang.String getWhereClause()
public void addWhereClause(java.lang.String expr)
The new WHERE clause is appended to the current WHERE clause. This method does not interpose "AND" or any other conjunctive between. the old and new clauses: the application must provide it.
The modified WHERE clause does not take effect until
executeQuery()
is called.
expr
- the SQL WHERE clause to be appended.public void setWhereClause(java.lang.String whereClause)
The new WHERE clause does not take effect until
executeQuery()
is called.
whereClause
- a SQL WHERE clause.public java.lang.String getOrderByClause()
public void addOrderByClause(java.lang.String expr)
The new expression is appended to the current order-by-clause, and a "," is interposed between them, if necessary.
The modified ORDER BY clause does not take effect until
executeQuery()
is called.
expr
- the SQL ORDER BY expression to be appended.public void setOrderByClause(java.lang.String orderByClause)
The new ORDER BY clause does not take effect until
executeQuery()
is called.
orderByClause
- a SQL ORDER BY clause.public java.lang.Object[] getWhereClauseParams()
public void setWhereClauseParams(java.lang.Object[] values)
The new WHERE clause parameter values do not take effect until
executeQuery()
is invoked.
values
- an array of bind values.public void setWhereClauseParam(int index, java.lang.Object value)
The new WHERE clause parameter value does not take effect until
executeQuery()
is invoked.
index
- the position of the bind value.value
- the bind value.public DBTransaction getDBTransaction()
public java.lang.String getUserDefinedQuery()
The View Object's query statement is normally built from various
clauses, such as FROM, WHERE, and ORDER BY. An application can
bypass this mechanism by supplying a complete query though
setQuery(String)
.
public java.lang.String getQuery()
public long getQueryHitCount(ViewRowSetImpl viewRowSet)
This method obtains the row count by executing:
SELECT COUNT(1) FROM query-statement;
protected boolean buildWhereClause(java.lang.StringBuffer sqlBuffer, int noUserParams)
The where-clause is made up of the following parts:
sqlBuffer
- StringBuffer
into which the
where-clause is appended.defWhereClause
- where-clause from the definition object.noUserParams
- the number of bind variables in the where-clause.
Typically, this number is
getWhereClauseParams().length
.true
if a where-clause was appended.protected boolean buildOrderByClause(java.lang.StringBuffer sqlBuffer, java.lang.String defOrderByClause)
The order-by-clause is made up of the following parts:
sqlBuffer
- StringBuffer
into which the
order-by-clause is appended.defOrderByClause
- order-by-clause from the definition object.true
if an order-by-clause was appended.public void setQuery(java.lang.String query)
The View Object's query statement is normally built from various
clauses, such as FROM, WHERE, and ORDER BY. An application can
bypass this mechanism by using this method to supply a complete query.
The new query statement does not take effect until
executeQuery()
is invoked.
query
- a user-defined query statement.public java.lang.Object[] getParametersAsStorageTypes()
The resulting array is a union of the following sets of bind values:
setWhereClauseParam()
.null
if none.public java.lang.Class getRowClass()
public ViewRowImpl createInstance(ViewRowSetImpl viewRowSet, AttributeList attrValList)
This method is called by ViewObjectImpl.createRow()
.
The view row is created, and if it is a detail row for some View Link,
its foreign key value attributes are initialized.
viewRowSet
- the row set requesting the new row instance.attrValList
- a list of attribute values to be used
for initializing the view row.
If it is a detail row for some View Link, this list will
contain foreign key values.public ViewRowImpl createInstanceFromResultSet(oracle.jbo.server.QueryCollection qc, java.sql.ResultSet resultSet)
Creates a view row instance from the query result.
This method is called as the user navigates through the query result.
As rows are traversed through the JDBC ResultSet
, view
rows are created through calls to this method.
qc
- query collection.resultSet
- JDBC ResultSet
.protected EntityDefImpl[] getEntityDefs()
public AttributeDef[] getAttributeDefs()
This array includes dynamic attributes
created through addDynamicAttribute()
.
public AttributeDef[] getKeyAttributeDefs()
The View Object's key is a composite key, consisting of view attributes mapped to the primary keys of its Entity Objects.
public int getCalculatedAttributeCount()
Calculated attributes are those that are not directly mapped to entity attributes, such as SQL derived attributes and association accessor attributes.
public AttributeDefImpl[] getPrimaryKeys()
This method returns
an array of entity attribute definitions, in constrast to
getKeyAttributeDefs()
, which returns an array of view
attribute definitions.
public void executeQuery()
This method does not necessarily retrieve data. The View Object's
fetch mode determines whether the rows are retrieved immediately
or not. If FETCH_AS_NEEDED is specified, the ResultSet
is left open, and the rows are retrieved as the user navigates through
the row set.
Calling this method will ensure that the user will see the latest data from the database, as well as the data changes that the user has made in the current transaction.
If the user changes the SQL statement, or modifies attributes used by it, view rows that were visible may "disappear" after this method is invoked, and the new WHERE clause takes effect.
When a row set is first instantiated and the application calls a navigational method such as, next(), previous(), first(), last(), this method is implicitly called.
Upon successful execution of query, this method fires a
RangeRefreshEvent
event to RowSetListener
's
registered with this object, by calling
RowSetListener.rangeRefreshed()
.
setFetchMode(byte)
public int getAttributeCount()
This number includes dynamic attributes
created through addDynamicAttribute()
.
public AttributeDef findAttributeDef(java.lang.String name)
name
- the name of the attribute.name
.name
is invalid.public AttributeDef getAttributeDef(int index)
index
- the position of the attribute definition.null
if the index is
out of range.public AttributeDef addDynamicAttribute(java.lang.String attrName)
Dynamic attributes are typeless, in that the application can set the attribute value to any object.
attrName
- the name of the dynamic attribute.public int getAttributeIndexOf(java.lang.String attrName)
attrName
- the name of the attribute.public boolean isDynamicAttribute(int index)
index
- the attribute's position.true
if the attribute is dynamic, or
false
otherwise.public boolean isDynamicAttribute(java.lang.String name)
name
- the attribute'same.true
if the attribute is dynamic, or
false
otherwise.public void validate()
This method enumerates through all rows in the row set and calls
validate()
on any that have been modified.
ViewRowImpl.validate()
public boolean isAutoPostChanges()
If enabled, changes are automatically posted to the database before the View Object's query is executed.
public void setAutoPostChanges(boolean bAutoPostChanges)
If enabled, changes are automatically posted to the database before the View Object's query is executed.
bAutoPostChanges
- true enables auto-post-changes.public byte getFetchMode()
setFetchMode()
.protected void setFetchMode(byte fetchMode)
The fetchMode
parameter should be one of the FETCH_...
constants. This fetch mode controls how rows are retrieved
out of JDBC's ResultSet
.
After the query is executed, the row data are retrieved from
the ResultSet
. If FETCH_AS_NEEDED is specified, the
result set is left open and rows are retrieved as the user navigates
through the row set. If the user navigates to the end of the row
set, the result set is closed.
If FETCH_ALL is specified, all rows are retrieved out of the results set even if the user has not navigated through the row set. After all rows are retrieved, the result set is closed.
FETCH_DEFAULT should not used for now.
FETCH_ALL should be used if the number of rows in the row set
relatively small and the number of row sets open on the View Object
is large. This is because FETCH_ALL enables the user to avoid using
up JDBC ResultSet
's. If FETCH_AS_NEEDED is specified
and too many row sets are open (and left open because they are not
navigated to the end), the user may run out ResultSet
's.
On the other hand, if the result set contains many rows, FETCH_ALL
may not desirable because it incurs the cost of retrieving all rows
up front.
fetchMode
- the new fetch mode.public int getBindingStyle()
public void setBindingStyle(int bindingStyle)
bindingStyle
- the binding style.public int getFetchSize()
This value is used to set the JDBC row pre-fetch size.
public int getMaxFetchSize()
This number is used to set the maximum number of rows to retrieve from JDBC. The default is 0, indicating no limit.
public ViewCriteria createViewCriteria()
public void applyViewCriteria(ViewCriteria criteria)
criteria
- the view criteria to apply.public ViewCriteria getViewCriteria()
null
if none is specified.public java.lang.String getViewCriteriaClause()
public RowSet getRowSet()
public RowSetIterator getRowSetIterator()
public Row next()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
If the current row designation is to change, ViewRowImpl.validate()
is
called to validate the current row.
The row set has a "slot" before the first row, and
one after the last row. When the row set is executed the iterator
is positioned at the slot before the first row. If next()
is invoked on a newly-executed row,
the first row will be returned.
If next()
is called when the iterator is positioned
on the last row of the row set, null
is returned
and the iterator is positioned at the slot following the last row.
If the iterator is at the last row of the range when next()
is called, RowSetListener.rangeScrolled()
is called to send
ScrollEvent
to registeredRowSetListener
s.
When successful, this method fires a
NavigationEvent
to registered RowSetListener
s, by calling
RowSetListener.navigated()
. The row returned is designated as
the current row.
null
if no next row.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public Row previous()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
If the current row designation is to change, ViewRowImpl.validate()
is
called to validate the current row.
The row set has a "slot" before the first row, and
one after the last row. When the row set is executed the iterator
is positioned at the slot before the first row.
If previous()
is called when the iterator is positioned
on the first row of the row set, null
is returned
and the iterator is positioned at the slot preceeding the first row.
If the iterator is at the first row of the range when previous()
is called, RowSetListener.rangeScrolled()
is called to send
ScrollEvent
to registeredRowSetListener
s.
When successful, this method fires a
NavigationEvent
to registered RowSetListener
s, by calling
RowSetListener.navigated()
. The row returned is designated as
the current row.
null
if no previous row.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public Row first()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
If the current row designation is to change, ViewRowImpl.validate()
is
called to validate the current row.
If the range does not include the first row when next()
is called, RowSetListener.rangeScrolled()
is called to send
ScrollEvent
to registeredRowSetListener
s.
When successful, this method fires a
NavigationEvent
to registered RowSetListener
s, by calling
RowSetListener.navigated()
. The row returned is designated as
the current row.
null
if the set has no rows.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public Row last()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
If the current row designation is to change, ViewRowImpl.validate()
is
called to validate the current row.
This method retrieves rows until the end of row set is found.
Thus, this operation may be slow.
If the range does not include the last row when next()
is called, RowSetListener.rangeScrolled()
is called to send
ScrollEvent
to registeredRowSetListener
s.
When successful, this method fires a
NavigationEvent
to registered RowSetListener
s, by calling
RowSetListener.navigated()
. The row returned is designated as
the current row.
null
if the set has no rows.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public void reset()
The iterator is positioned to the slot before the first row, the state of a newly-executed row set.
public boolean hasNext()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
This method does not move the current row.
true
if the row set has a next row, or
false
if not.public boolean hasPrevious()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
This method does not move the current row.
true
if the row set a previous row, or
false
if not.public boolean isRangeAtBottom()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
This method does not move the current row.
true
if the range contains the last row, or
false
if not.public boolean isRangeAtTop()
If this method is called on a row set that has not yet been
executed, executeQuery()
is implicitly called.
This method does not move the current row.
true
if the range contains the first row, or
false
if not.public int getFetchedRowCount()
public int getRowCount()
This method retrieves rows until the last row is retrieved. Thus, this operation may be slow.
Use getEstimatedRowCount()
to obtain a quicker count.
getEstimatedRowCount()
public long getEstimatedRowCount()
This method estimates the number of rows in the row count
by calling getQueryHitCount()
, and then modifies
this number as rows are added and removed.
Thus, after the first call to this method, it can return
the estimated count quickly.
getQueryHitCount(ViewRowSetImpl)
public int setRangeSize(int size)
size
- the new range size, or -1 if all rows are to be included.size
is greater than 1.public int getRangeSize()
A range size of -1 indicates that the range will contain all the rows of the row set.
public int getRangeStart()
An absolute row index is a row index in the entire row set.
public int setRangeStart(int start)
This method scrolls the range to make the row of
the specified start index the first row of the range. If successful,
RowSetListener.rangeScrolled()
is called to send
a ScrollEvent
to registered RowSetListener
.
If start
indicates a row beyond the last row, the range
will be scrolled to the end of the row set.
start
- an absolute row index.ScrollEvent
,
RowSetListener
public int scrollRange(int amount)
The number of rows to scroll, amount
, may be positive or negative.
If negative, the range is scrolled upward (backward).
If amount
would scroll the range
beyond either end of the row set, this method scrolls to that end of the range.
After the range is scrolled, this method
calls RowSetListener.rangeScrolled
() to send
a ScrollEvent
to registered RowSetListener
s.
amount
- the number of rows to scroll.amount
is negative.ScrollEvent
,
RowSetListener
public int scrollRangeTo(Row row, int index)
This method scrolls the range to position the specified row at a specified range index. This operation may be slow.
After the range is scrolled, this method
calls RowSetListener.rangeScrolled
() to send
a ScrollEvent
to registered RowSetListener
s.
row
- the row to scroll the range to.index
- the range index at which row is to be positioned.index
is
outside the range, or if
row
is not found
in the row set.ScrollEvent
,
RowSetListener
public Row getRow(Key key)
This method retrieves rows from the database until a match is found or the end of the row set is reached.
If this View Object has multiple Entity Objects, the key
need not be specified for all. When this is the case multiple rows may
match the key. The first of these rows will be returned.
This method differs from findByKey()
in the
following respects:
getRow
returns one row only, findByKey()
returns
multiple rows.
getRow
populates the collection
until it finds a match, but findByKey
retrieves rows
first from the cache and then from the database,
and does not populate the collection.
findByKey
may be much faster than getRow
.
getRow
returns the first matching row,
findByKey
may retrieve rows in the order not specified by the query.
key
- the key to be matched.null
if none match.public Row getRowAtRangeIndex(int index)
index
- a zero-based index within the range.null
if index
is outside of the range.public Row getRowFromHandle(java.lang.Object hdl)
Returns the row with a handle specified by hdl
.
A view row can be assigned a handle unique in the running
session (ViewRowImpl.getHandle
). This handle
can be used to get back the row. This method returns the
row given the row handle.
The row handle is valid only within the running session and may not be persisted across sessions.
This method is an internal routine. The client should
use the row's key (ViewRowImpl.getKey
) if he wishes to
get the row back at a later time. Also, the key
may be persisted and used across sessions.
hdl
- the row handle.ViewRowImpl.getHandle()
,
ViewRowImpl.getKey()
public void removeRowHandle(java.lang.Object hdl)
Removes the row handle from the row handle hash table.
A view row can be assigned a handle unique in the running
session (ViewRowImpl.getHandle
). This handle
can be used to get back the row. This method removes the
row handle from the row handle hash table.
hdl
- the row handle to remove.ViewRowImpl.getHandle()
public Row getCurrentRow()
If the row set has not been executed, or if this method is called
immediately after the current row is removed, then it returns
null
(no current row).
null
if no current row.public int getCurrentRowIndex()
If the row set has not been executed, or the iterator has been reset, -1 is returned.
public int getCurrentRowSlot()
The current row's slot status is one of the following
oracle.jbo.RowIterator
constants:
RowIterator
public boolean setCurrentRow(Row row)
This method calls ViewRowImpl.validate
to
validate the previous current row.
After designating row as the current row, this method
invokes RowSetListener.navigated()
to send a
NavigationEvent
to registered RowSetListener
s.
row
- the row that is to become the current row.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public boolean setCurrentRowAtRangeIndex(int index)
This method calls ViewRowImpl.validate
to
validate the previous current row.
After designating row as the current row, this method
invokes RowSetListener.navigated()
to send a
NavigationEvent
to registered RowSetListener
s.
index
- the position of the row that is to become the current row.NavigationEvent
,
RowSetListener
,
ViewRowImpl.validate()
public Row createRow()
public void insertRow(Row row)
The row is inserted at the current row position and becomes the current row. The indices for rows below the insertion point are incremented.
Upon successful insertion, this method
invokes RowSetListener.rowInserted()
to send a
InsertEvent
to registered RowSetListener
s.
row
- the view row to insert.public void insertRowAtRangeIndex(int index, Row row)
The row is inserted at the given range index, and becomes the current row. The indices for rows below the insertion point are incremented.
Upon successful insertion, this method
invokes RowSetListener.rowInserted()
to send a
InsertEvent
to registered RowSetListener
s.
index
- the range index at which row is to be inserted.row
- the view row to insert.public void removeCurrentRow()
This method marks constituent Entity Object rows as deleted. When changes are posted to database or transaction committed, the database rows are deleted.
Upon successful removal of the row, the current row position does not
move. However, the current row is set to null
,
and its slot status is set to SLOT_DELETED.
Calling next()
or previous()
after removal
will return a row adjacent to the removed row.
After removing the row, this method
invokes RowSetListener.rowDeleted()
to send a
DeleteEvent
to registered RowSetListener
s.
RowSetListener.rowDeleted(oracle.jbo.DeleteEvent)
public int getRangeIndexOf(Row row)
row
- a row.public java.util.Enumeration enumerateRowsInRange()
public Row[] getAllRowsInRange()
public ViewObject getViewObject()
ViewObject
.public boolean setMasterRowSetIterator(RowSetIterator masterRSI)
The given iterator must be valid: a View Link must
associate this detail View Object with another View Object, for which
masterRSI
is the master iterator.
masterRSI
- a master row set iterator.public boolean removeMasterRowSetIterator(RowSetIterator masterRSI)
If masterRSI
is a master row set iterator for this
row set, it is removed from the list of master row set
iterators.
masterRSI
- master row set iterator to be removed.public RowSetIterator[] getMasterRowSetIterators()
public RowSet[] getDetailRowSets()
public RowSet createDetailRowSet(java.lang.String rsName, java.lang.String linkDefName)
rsName
- the name to be assigned to the new
detail row set.linkDefName
- the name of the View Link definition that
defines a master-detail relationship between this row set iterator, the master,
and the newly created detail row set.public void addListener(java.lang.Object listener)
listener
- a RowSetListener
instance.public void removeListener(java.lang.Object listener)
listener
- the listener to be removed.public RowSet createRowSet(java.lang.String name)
name
- the name of the new row set.public RowSetIterator createRowSetIterator(java.lang.String name)
name
- the name of the new row set iterator.public int getRowCountInRange()
If the range is at the end of the row set, the number of rows in the range may be less than the range size.
public Row[] findByKey(Key key, int maxNumOfRows)
If this View Object has multiple Entity Objects, the key
need not be specified for all. When this is the case multiple rows may
match the key.
The number of rows returned
may be unbounded. Use maxNumOfRows()
to limit the number
of rows and the size of the returning array.
This method retrieves rows first from the cache and then from the database, and does not populate the collection.
This method does not fire any navigation event, nor does it move the range or the current row.
key
- the key to be matched.maxNumOfRows
- the maximum size of the array to return,
or -1 to return all rows.getRow(oracle.jbo.Key)
public Row[] findByEntity(int eRowHandle, int maxNumOfRows)
eRowHandle
.
eRowHandle
- the entity row handle.maxNumOfRows
- the maximum size of the row array to return,
or -1 to return all rows.protected void setQueryChanged(boolean isChanged)
Sets whether the query should be marked changed or not.
If the query is marked as changed, this method walks through the list of view row sets and tells each to refresh its content.
isChanged
- the new change flag.protected boolean isQueryChanged()
Indicates whether the query is marked changed or not.
protected void notifyRowUpdated(ViewRowSetImpl vrs, Row[] viewRows, int[] attrIndices)
vrs
- ViewRowSetImpl instance to be notified about the attribute(s) updateviewRows
- A collection of View Row instances that have been modified.attrIndices
- A collection of attribute indices in the View Rows that have
been modified.protected boolean isForeignKey(oracle.jbo.server.ViewAttributeDefImpl attr)
attr
- a view attribute definition.public java.lang.String getProxyClassName()
protected java.lang.String getProxyClassName(java.lang.String platform)
The platforms currently recognized are VB (Visibroker) and 8i (Oracle8i).
platform
- name of the platform. Currently, can be either
VB (Visibroker) or 8i (Oracle8i).protected void setProxyClassName(java.lang.String platform, java.lang.String proxyClassName)
The platforms currently recognized are VB (Visibroker) and 8i (Oracle8i). The proxy class name can be different depending on the Application Server platform. For example, for Visibroker, the proxy class name can be "X", while for Oracle8i the name of the same proxy class can be "Y".
platform
- name of the platform. Currently, can be either
VB (Visibroker) or 8i (Oracle8i).proxyClassName
- a name for the proxy class.public java.lang.String getRowProxyClassName()
public void remove()
public void setForwardOnly(boolean isForwardOnly)
Forward-only row sets manage only one row, and constrain users to working only with the current row. Data-update operations are not allowed.
Forward-only row sets are useful for
batch operations which proceed linearly.
The only allowed
navigation operation is next()
.
A foward-only row set is faster and
consumes fewer resources than a normal row set.
isForwardOnly
- true if the row set should be
forward-only.public boolean isForwardOnly()
Forward-only row sets manage only one row, and constrain users to working only with the current row. Data-update operations are not allowed.
Forward-only row sets are useful for
batch operations which proceed linearly.
The only allowed
navigation operation is next()
.
A foward-only row set is faster and
consumes fewer resources than a normal row set.
public void setAssociationConsistent(boolean isConsistent)
When association-consistency is disabled (the default), changes made in one View Object may not be visible in other View Objects until posted to the database.
When association-consistency is enabled, modified data will be fetched from the cache, rather than from the database, so changes will be visible before they are posted. Rows with modified foreign keys, newly created rows, deletions will be consistently shown. However, performace will be degraded. If association-consistency is on, the row set will reflect rows with modified foreign keys, newly created rows, and removed (deleted) rows.
If association-consistency is off, the user can post the pending changes to database. This way all subsequent queries into the database will include the data changes.
This method is relevant only if this row set was returned by a call to an entity association accessor.
isConsistent
- true if association-consistency is to be enabled.public boolean isAssociationConsistent()
setAssociationConsistent(boolean)
public void showCursorUsage(java.io.Writer out)
Debug routine that prints the cursor usage for this View Object.
out
- where to write the output.protected void beforeEntityRemove(Entity entity)
If some action causes an entity row to be removed, this handler
is invoked (before the entity row is removed). The user can
override this method to respond to the remove event. Note that
this handler is invoked regardless of whether the removed
entity
affects one of the rows in this View Object.
entity
- entity about to be removed.protected void afterEntityRemove(Entity srow)
public void sourceChanged(EntityEvent event)
EntityListener
)s.
This event is sent by the entity cache to notify listeners of changes to entity rows. It is invoked for attribute changes and row removal.
When rows are remmoved this method is invoked twice,
first as a BEFORE_REMOVE event,
and then as a STATE_CHANGE
event.
event
- the Entity Object event.EntityListener
,
EntityEvent
public void afterCommit(TransactionEvent event)
event
- the transaction event.TransactionListener
public void afterRollback(TransactionEvent event)
event
- the transaction event.TransactionListener
public void afterRemove(TransactionEvent event)
event
- the transaction event.TransactionListener
public void beforeCommit(TransactionEvent e)
event
- the transaction event.TransactionListener
public void beforeRollback(TransactionEvent e)
event
- the transaction event.TransactionListener
public boolean isTransientTransactionListener()
Transient listeners are automatically removed at the end of a transaction commit or rollback cycle; permanent listeners remain across these cycles.
true
if the listener is transient.public void postChanges(TransactionEvent e)
e
- ignored.public int getTransPostHandle()
Implements the getTransPostHandle
method for the
(TransactionPostListener
)
interface.
Transaction post handle is a handle identifying a row object in the transaction post listener list. View Objects do not have a transaction post handle, and thus returns -1.
public void setTransPostHandle(int hdl)
Implements the setTransPostHandle
method for the transaction
post listener (TransactionPostListener
)
interface.
Transaction post handle is a handle identifying a row object in the transaction post listener list. View Objects do not have a transaction post handle, and thus this method does nothing.
hdl
- the transaction post handle.public boolean isTransientTransactionPostListener()
Transient listeners are automatically removed at the end of a transaction post cycle; permanent listeners remain across post cycles. This property does not change.
false
public void setListenToEntityEvents(boolean b)
This flag controls whether the View Object should listen to entity events or not. If false, the View Object and all its row sets will not receive events generated from changes to entity row data. This is useful for batch processing because suppressing events improves performance.
the
- new listen-to-entity-events flag.public AttributeDef findViewLinkAccessor(ViewLink vl)
vl
- the View Link whose accessor is sought.null
.
|
Business Components | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |