Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

oracle.jbo.server
Class EntityCache

java.lang.Object
  extended by oracle.jbo.server.NamedObjectImpl
      extended by oracle.jbo.server.ComponentObjectImpl
          extended by oracle.jbo.server.EntityCache
All Implemented Interfaces:
Formattable, ComponentObject, Properties, StructureDef, VariableManagerOwner, VariableManagerOwnerBase

public class EntityCache
extends ComponentObjectImpl
implements StructureDef

The EntityCache caches queried rows of a particular EntityDef type


Field Summary
static java.lang.Class CLASS_INSTANCE
           
 
Fields inherited from class oracle.jbo.server.NamedObjectImpl
mObjName, mParent, mProperties, mUserData, RES_ID_SUFFIX
 
Constructor Summary
EntityCache()
           
 
Method Summary
protected  EntityImpl add(EntityImpl srow)
          Add an Entity to the cache.
 AttributeDef addDynamicAttribute(java.lang.String attrName)
           
 void addEntityListener(EntityListener listener)
          Add an EntityListener.
protected  EntityImpl addForAltKey(int keyIndex, EntityImpl srow)
           
protected  void addRowByDeletedPK(Key pkey, EntityImpl srow)
           
protected  void clearCache()
           
protected  void closeStatements()
           
protected  PreparedStatement createPreparedStatement(java.lang.String sqlString, boolean lock, int noRowsPrefetch)
           
protected  PreparedStatement createPrepStmtForAltKey(java.lang.String sqlString, int keyIndex, boolean lock, int noRowsPrefetch)
           
protected  void deliverEntityEvent(EntityEvent event)
           
 java.util.Enumeration elements()
           
 AttributeDef findAttributeDef(java.lang.String name)
          Get the named AttributeDef
protected  ViewObject findOrCreateLocalViewObject(java.lang.String usageName)
          Find or create the local view instance from the local view usage name.
 ViewAccessorDef findViewAccessorDef(java.lang.String name)
           
 java.lang.String formatForOutput(OutputFormatter formatter)
           
 EntityImpl get(Key key)
          Get an EntityImpl from the cache.
 int getAttributeCount()
          Get the # of attributes for a row of this EntityDef type
 AttributeDef getAttributeDef(int index)
          Get the AttributeDef for the given index
 AttributeDefImpl[] getAttributeDefImpls()
           
 AttributeDef[] getAttributeDefs()
          Get all the AttributeDef's for this EntityCache's EntityDef
 int getAttributeIndexOf(java.lang.String name)
          Determines the 0-based index of the named attribute
 int getBaseAttributeCount()
           
 java.lang.String getColumnNameForQuery(int index)
           
protected  Timestamp getCurrentDbTime()
          Get the current database time for DATE History Column.
 DBTransactionImpl getDBTransactionImpl()
           
 java.lang.String getDefFullName()
          Get the fully-qualified name of the EntityDef
 java.lang.String getDefName()
          Get the short name of the EntityDef
 EntityDefImpl getEntityDef()
          Gets the EntityDef associated with this EntityCache
 EntityImpl getForAltKey(int keyIndex, Key key)
           
 java.lang.String getFullName()
          Get the fully-qualified name of the EntityDef
 java.lang.String getName()
          Get the short name of the EntityDef
protected  PreparedStatement getPreparedSelectStatement(boolean lock)
           
protected  PreparedStatement getPrepSelStmtForAltKey(int keyIndex, boolean lock)
           
 EntityImpl getWithHandle(Key key)
          Get an EntityImpl from the cache.
 boolean hasRows()
          Does this EntityCache have any rows?
protected  void init(DBTransactionImpl trans, EntityDefImpl entityDef)
           
 boolean isAssociationAccessorRetained()
           
protected  boolean isBatchable(int operation)
           
protected  Iterator iterator()
          Return an Iterator for the EntityCache.
 AttributeDef lookupAttributeDef(java.lang.String name)
          Get the AttributeDef with the given name
 ViewAccessorDef lookupViewAccessorDef(java.lang.String vaName)
           
 void pin(EntityImpl srow)
           
 void removeEntityListener(EntityListener listener)
          Remove an EntityListener.
protected  EntityImpl removeRow(EntityImpl srow)
          Remove a EntityImpl from the cache.
protected  EntityImpl removeRowByDeletedPK(EntityImpl srow)
           
protected  EntityImpl removeRowByOldPK(EntityImpl srow)
           
protected  EntityImpl removeRowForAltKey(int keyIndex, EntityImpl srow)
           
protected  void replace(EntityImpl srow, Key okey)
          Remove a row in cache and add it in using the new key values.
protected  void replaceForAltKey(int keyIndex, EntityImpl srow, Key okey)
           
 boolean unpin(EntityImpl srow)
           
 void validate(EntityImpl validateEntity)
           
 
Methods inherited from class oracle.jbo.server.ComponentObjectImpl
addListener, applyPersonalization, create, createRef, ensureVariableManager, getAllProperties, getApplicationModule, getCompListeners, getCompListenersList, getMessageBundleClass, getResourceBundleDef, getRootApplicationModule, getVariableManager, hasVariables, isDead, remove, resolvePropertyRaw
 
Methods inherited from class oracle.jbo.server.NamedObjectImpl
formatChildCollectionForOutput, formatChildCollectionForOutput, formatChildCollectionForOutput, formatForOutput, getParent, getProperties, getPropertiesAsStrings, getPropertiesMap, getProperty, getProperty, getResourcesFromBundle, getUserData, parseAttrArrayElements, refreshProperty, requiresNamePrefixedResId, setFullName, setName, setParent, setPropertiesMap, setProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jbo.Properties
getProperties, getProperty, getProperty, refreshProperty
 

Field Detail

CLASS_INSTANCE

public static final java.lang.Class CLASS_INSTANCE
Constructor Detail

EntityCache

public EntityCache()
Method Detail

init

protected void init(DBTransactionImpl trans,
                    EntityDefImpl entityDef)

add

protected EntityImpl add(EntityImpl srow)
Add an Entity to the cache. TODO: This really should check for conflicts between the EntityDefImpl of the row and the cache.

Parameters:
srow - the row to be added.

get

public EntityImpl get(Key key)
Get an EntityImpl from the cache. If the entity is not found then we return a null value.

Parameters:
key - the Primary key of the EntityImpl.
Returns:
the EntityImpl with the Key or null if not found.

hasRows

public boolean hasRows()
Does this EntityCache have any rows?

Returns:
true if at least one row exist; false otherwise

getEntityDef

public EntityDefImpl getEntityDef()
Gets the EntityDef associated with this EntityCache

Returns:
EntityDef object

findAttributeDef

public AttributeDef findAttributeDef(java.lang.String name)
Get the named AttributeDef

Specified by:
findAttributeDef in interface StructureDef
Parameters:
name - Name of the attribute to find
Returns:
An AttributeDef if found
Throws:
NoDefException - if named AttributeDef not found

deliverEntityEvent

protected void deliverEntityEvent(EntityEvent event)

getAttributeCount

public int getAttributeCount()
Get the # of attributes for a row of this EntityDef type

Specified by:
getAttributeCount in interface StructureDef
Returns:
# of attributes

getAttributeDef

public AttributeDef getAttributeDef(int index)
Get the AttributeDef for the given index

Specified by:
getAttributeDef in interface StructureDef
Parameters:
index - 0-based index of interest
Returns:
AttributeDef, or null if index out of range

getAttributeDefs

public AttributeDef[] getAttributeDefs()
Get all the AttributeDef's for this EntityCache's EntityDef

Specified by:
getAttributeDefs in interface StructureDef
Returns:
An array of all the AttributeDef's, or null if there are no AttributeDef's

getAttributeIndexOf

public int getAttributeIndexOf(java.lang.String name)
Determines the 0-based index of the named attribute

Specified by:
getAttributeIndexOf in interface StructureDef
Parameters:
name - Name of attribute
Returns:
0-based index if found, or -1 if not

getDefFullName

public java.lang.String getDefFullName()
Get the fully-qualified name of the EntityDef

Specified by:
getDefFullName in interface ComponentObject
Specified by:
getDefFullName in interface StructureDef
Overrides:
getDefFullName in class ComponentObjectImpl
Returns:
Fully-qualified name of EntityDef

getDefName

public java.lang.String getDefName()
Get the short name of the EntityDef

Specified by:
getDefName in interface ComponentObject
Specified by:
getDefName in interface StructureDef
Overrides:
getDefName in class ComponentObjectImpl
Returns:
Short name of EntityDef

getFullName

public java.lang.String getFullName()
Get the fully-qualified name of the EntityDef

Specified by:
getFullName in interface ComponentObject
Specified by:
getFullName in interface StructureDef
Overrides:
getFullName in class NamedObjectImpl
Returns:
Fully-qualified name of EntityDef

getName

public java.lang.String getName()
Get the short name of the EntityDef

Specified by:
getName in interface ComponentObject
Specified by:
getName in interface StructureDef
Specified by:
getName in interface VariableManagerOwner
Overrides:
getName in class NamedObjectImpl
Returns:
Short name of EntityDef

lookupAttributeDef

public AttributeDef lookupAttributeDef(java.lang.String name)
Get the AttributeDef with the given name

Specified by:
lookupAttributeDef in interface StructureDef
Parameters:
name - Name to search for
Returns:
Named AttributeDef if found; otherwise null

clearCache

protected void clearCache()

elements

public java.util.Enumeration elements()

addEntityListener

public void addEntityListener(EntityListener listener)
Add an EntityListener.

Parameters:
listener - The object to be registered as listener.

removeEntityListener

public void removeEntityListener(EntityListener listener)
Remove an EntityListener.

Parameters:
listener - The object to be removed from the list of listeners.

closeStatements

protected void closeStatements()

getColumnNameForQuery

public java.lang.String getColumnNameForQuery(int index)
Specified by:
getColumnNameForQuery in interface StructureDef

getBaseAttributeCount

public int getBaseAttributeCount()

addDynamicAttribute

public AttributeDef addDynamicAttribute(java.lang.String attrName)

isAssociationAccessorRetained

public boolean isAssociationAccessorRetained()

formatForOutput

public java.lang.String formatForOutput(OutputFormatter formatter)
Specified by:
formatForOutput in interface Formattable
Overrides:
formatForOutput in class NamedObjectImpl

getForAltKey

public EntityImpl getForAltKey(int keyIndex,
                               Key key)

getAttributeDefImpls

public AttributeDefImpl[] getAttributeDefImpls()

getPreparedSelectStatement

protected PreparedStatement getPreparedSelectStatement(boolean lock)

getPrepSelStmtForAltKey

protected PreparedStatement getPrepSelStmtForAltKey(int keyIndex,
                                                    boolean lock)

createPreparedStatement

protected PreparedStatement createPreparedStatement(java.lang.String sqlString,
                                                    boolean lock,
                                                    int noRowsPrefetch)

createPrepStmtForAltKey

protected PreparedStatement createPrepStmtForAltKey(java.lang.String sqlString,
                                                    int keyIndex,
                                                    boolean lock,
                                                    int noRowsPrefetch)

removeRowByOldPK

protected EntityImpl removeRowByOldPK(EntityImpl srow)

removeRowByDeletedPK

protected EntityImpl removeRowByDeletedPK(EntityImpl srow)

removeRow

protected EntityImpl removeRow(EntityImpl srow)
Remove a EntityImpl from the cache.

Parameters:
srow - the row to be removed.

removeRowForAltKey

protected EntityImpl removeRowForAltKey(int keyIndex,
                                        EntityImpl srow)

addForAltKey

protected EntityImpl addForAltKey(int keyIndex,
                                  EntityImpl srow)

replaceForAltKey

protected void replaceForAltKey(int keyIndex,
                                EntityImpl srow,
                                Key okey)

addRowByDeletedPK

protected void addRowByDeletedPK(Key pkey,
                                 EntityImpl srow)

replace

protected void replace(EntityImpl srow,
                       Key okey)
Remove a row in cache and add it in using the new key values. This is used when the key values changed by the user or from RETURNING clause on INSERT or UPDATE.

Parameters:
srow - the row to be replaced.
okey - the original key.

getDBTransactionImpl

public DBTransactionImpl getDBTransactionImpl()

iterator

protected Iterator iterator()
Return an Iterator for the EntityCache. The naming of this method is consistent with the JDK 1.2 Collection classes. The behaviour of the Iterator isn't defined if the underlying values in the cache change as it is executing.

Returns:
an Interator over the cache values.

validate

public void validate(EntityImpl validateEntity)

pin

public void pin(EntityImpl srow)

unpin

public boolean unpin(EntityImpl srow)

findViewAccessorDef

public ViewAccessorDef findViewAccessorDef(java.lang.String name)

lookupViewAccessorDef

public ViewAccessorDef lookupViewAccessorDef(java.lang.String vaName)

getWithHandle

public EntityImpl getWithHandle(Key key)
Get an EntityImpl from the cache. If the Key has non-null values the cache is searched by doing a Map lookup for faster results. If the values are null but it has valid handle then the Cache looks in the modified rows first because it is where the new and initilized rows are kept. If it is still not found then a lookup with the handle against the regular rows is performed.

Parameters:
key - the Primary key of the EntityImpl.
Returns:
the EntityImpl with the Key or null if not found.

findOrCreateLocalViewObject

protected ViewObject findOrCreateLocalViewObject(java.lang.String usageName)
Find or create the local view instance from the local view usage name.

Parameters:
usageName - The local view usage name.
Returns:
The local view object.

isBatchable

protected boolean isBatchable(int operation)

getCurrentDbTime

protected Timestamp getCurrentDbTime()
Get the current database time for DATE History Column. Subclasses can override this method to perform customizations.

Returns:
current database time.

Oracle Fusion Middleware Java API Reference for Oracle ADF Mobile Client
11g Release 1 (11.1.1)

E17503-02

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.