Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 2 (11.1.2.0.0)

E17483-01

oracle.jbo.server
Class EntityCache

java.lang.Object
  extended by oracle.jbo.common.NamedObjectImpl
      extended by oracle.jbo.server.NamedObjectImpl
          extended by oracle.jbo.server.ComponentObjectImpl
              extended by oracle.jbo.server.EntityCache
All Implemented Interfaces:
ComponentObject, ExprWrappable, GenericHints, OperationContainer, Properties, ValidationManager, AttributeDependencyManager, StructureDef, VariableManagerOwner, VariableManagerOwnerBase
Direct Known Subclasses:
DSEntityCache, EntityCacheOverRowSet, EntityFacadeCollImpl

public class EntityCache
extends ComponentObjectImpl
implements StructureDef, ValidationManager, AttributeDependencyManager

The EntityCache caches queried rows for a particular EntityImpl.


Field Summary
 
Fields inherited from class oracle.jbo.common.NamedObjectImpl
mFullName, mObjName, mParent, mProperties, RES_ID_SUFFIX, RESID_SUFFIX
 
Fields inherited from interface oracle.jbo.GenericHints
PROPERTY_LABEL, PROPERTY_LABEL_PLURAL, PROPERTY_TOOLTIP
 
Constructor Summary
EntityCache()
          Constructor.
 
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.
 void addEventAttr(java.lang.String attrName)
           
protected  EntityImpl addForAltKey(int keyIndex, EntityImpl srow)
           
 void addForwardDependency(java.lang.String attrName, java.lang.String depName)
           
protected  void addRowByDeletedPK(Key pkey, EntityImpl srow)
           
 void addTrigger(TriggerType trig, JboValidatorInterface aValidator)
           
 void addValidator(JboValidatorInterface aValidator)
           
protected  void clearCache()
           
protected  void closeStatements()
           
protected  java.sql.PreparedStatement createEffDtDateDayAddStatement()
          Create a PreparedStatement that could be cached and reused to compute the sum/difference between a date and specified number of days.
protected  java.sql.PreparedStatement createPreparedStatement(java.lang.String sqlString, boolean lock, int noRowsPrefetch)
           
protected  java.sql.PreparedStatement createPrepStmtForAltKey(java.lang.String sqlString, int keyIndex, boolean lock, int noRowsPrefetch)
           
protected  void deliverEntityEvent(EntityEvent event)
           
 AttributeDef findAttributeDef(java.lang.String name)
          Gets an attribute definition, given its name.
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)
           
 EntityImpl get(Key key)
          Get an EntityImpl from the cache.
 int getAttributeCount()
          Returns the number of defined attributes.
 AttributeDef getAttributeDef(int index)
          Gets an attribute definition, given its index.
 AttributeDefImpl[] getAttributeDefImpls()
           
 AttributeDef[] getAttributeDefs()
          Gets the defined attributes.
 int getAttributeIndexOf(java.lang.String name)
          Finds the index (0-based) of the named attribute.
 java.util.HashSet<java.lang.String> getBackwardDependencies(java.lang.String attrName)
           
 java.util.List getBackwardDependencyAttributes(java.lang.String attrName)
           
 int getBaseAttributeCount()
           
 java.lang.String getColumnNameForQuery(int index)
           
static java.util.Comparator getComparator()
           
 java.util.Iterator<EventMapping> getCreateEvents()
           
protected  java.sql.Timestamp getCurrentDbTime()
          Get the current database time for DATE History Column.
 DBTransactionImpl getDBTransactionImpl()
           
 java.lang.String getDefFullName()
          Gets the Full Name of the Def Object.
 java.lang.String getDefName()
          Gets the name of the Def Object.
 java.util.Iterator<EventMapping> getDeleteEvents()
           
protected  java.sql.PreparedStatement getEffDtDateDayAddStatement()
          Returns a cached statement that returns a date that is 'x' number of days apart from the specified date.
 EntityDefImpl getEntityDef()
           
 EventDef getEventDef(java.lang.String name)
           
 java.lang.String getEventNamespace()
           
 java.lang.String getEventPayloadNamespace()
           
 EntityImpl getForAltKey(int keyIndex, Key key)
           
 java.util.HashSet<java.lang.String> getForwardDependencies(java.lang.String attrName)
           
 java.util.List getForwardDependencyAttributes(java.lang.String attrName)
           
 java.lang.String getFullName()
          Gets this object's fully-qualified name.
 java.util.List getLOBAttrs()
           
 java.lang.String getName()
          Get the name of this object.
protected  java.sql.PreparedStatement getPreparedSelectStatement(boolean lock)
           
protected  java.sql.PreparedStatement getPrepSelStmtForAltKey(int keyIndex, boolean lock)
           
static RowSetIterator getRSI(DBTransaction trans, java.lang.String amUsageName, java.lang.String voName, java.lang.String rsiName)
           
 java.util.ArrayList getTriggersOfType(TriggerType type)
           
 java.util.Iterator<EventMapping> getUpdateEvents()
           
 java.util.ArrayList getValidators()
           
 EntityImpl getWithHandle(Key key)
          Get an EntityImpl from the cache.
 boolean hasLOBAttrs()
           
 boolean hasRows()
           
protected  void init(DBTransactionImpl trans, EntityDefImpl entityDef)
           
 boolean isAssociationAccessorRetained()
           
protected  boolean isBatchable(int operation)
           
protected  java.util.Iterator iterator()
          Return an Iterator for the EntityCache.
 java.util.Iterator iterator(boolean inclSubclasses)
           
 AttributeDef lookupAttributeDef(java.lang.String name)
          Gets an attribute definition, given its name.
protected  JboValidatorInterface lookupTrigger(TriggerType trig, java.lang.String name, boolean localOnly)
           
 JboValidatorInterface lookupValidator(java.lang.String name, boolean localOnly)
           
 ViewAccessorDef lookupViewAccessorDef(java.lang.String vaName)
           
 void personalizeTrigger(TriggerType trig, JboValidatorHints persValidator)
           
 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)
           
 boolean removeValidator(JboValidatorInterface aValidator)
           
protected  void replace(EntityImpl srow, Key okey)
          Remove a row in cache and add it in using the new key values.
protected  void replace(EntityImpl srow, Key[] okeys)
           
protected  void replaceForAltKey(int keyIndex, EntityImpl srow, Key okey)
           
 void setAssociationAccessorRetained(boolean b)
           
 boolean unpin(EntityImpl srow)
           
 void validate(EntityImpl validateEntity)
           
 
Methods inherited from class oracle.jbo.server.ComponentObjectImpl
addListener, applyPersonalization, create, createRef, createVariableValueManager, ensureVariableManager, findOperationDefinitions, findPersDefObject, getAllProperties, getApplicationModule, getCompListeners, getCompListenersList, getDefinitionManager, getFullNameForPersDef, getHintValue, getLabel, getLabelPlural, getMessageBundleClass, getProxyClassName, getProxyClassName, getResourceBundleDef, getRootApplicationModule, getStringFromMessageBundle, getTooltip, getVariableManager, hasVariables, isDead, isPersonalized, isRegWithPiggyMan, remove, resolvePropertyRaw, setName, setParent, setProxyClassName
 
Methods inherited from class oracle.jbo.server.NamedObjectImpl
setParent, setPropertiesMap
 
Methods inherited from class oracle.jbo.common.NamedObjectImpl
allocatePropertyMap, getParent, getProperties, getPropertiesAsStrings, getPropertiesMap, getProperty, getProperty, getPropertyExpressionsMap, getPropertyMap, getResourcesFromBundle, isPropertyExpression, mergePropertyMap, refreshProperty, removeProperty, removeProperty, requiresNamePrefixedResId, resolveObjectProperty, setFullName, setPropertiesMap2, setProperty, setProperty, setPropertyExpression, setPropertyMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jbo.rules.ValidationManager
getResourceBundleDef
 
Methods inherited from interface oracle.jbo.Properties
getProperties, getProperty, getProperty, refreshProperty
 

Constructor Detail

EntityCache

public EntityCache()
Constructor.

Method Detail

getName

public java.lang.String getName()
Description copied from class: NamedObjectImpl
Get the name of this object.

Specified by:
getName in interface ComponentObject
Specified by:
getName in interface ValidationManager
Specified by:
getName in interface StructureDef
Specified by:
getName in interface VariableManagerOwner
Overrides:
getName in class NamedObjectImpl
Returns:
the name given to this object.

getFullName

public java.lang.String getFullName()
Description copied from class: NamedObjectImpl
Gets this object's fully-qualified name.

Specified by:
getFullName in interface ComponentObject
Specified by:
getFullName in interface ValidationManager
Specified by:
getFullName in interface StructureDef
Overrides:
getFullName in class NamedObjectImpl
Returns:
this object's fully-qualified name; the package name concatenated with the class name.

getDefName

public java.lang.String getDefName()
Description copied from class: ComponentObjectImpl
Gets the name of the Def Object.

Specified by:
getDefName in interface ComponentObject
Specified by:
getDefName in interface StructureDef
Overrides:
getDefName in class ComponentObjectImpl
Returns:
Name of the Def Object

getDefFullName

public java.lang.String getDefFullName()
Description copied from class: ComponentObjectImpl
Gets the Full Name of the Def Object.

Specified by:
getDefFullName in interface ComponentObject
Specified by:
getDefFullName in interface StructureDef
Overrides:
getDefFullName in class ComponentObjectImpl
Returns:
a class name.

init

protected void init(DBTransactionImpl trans,
                    EntityDefImpl entityDef)

getDBTransactionImpl

public DBTransactionImpl getDBTransactionImpl()

getEntityDef

public EntityDefImpl getEntityDef()

pin

public void pin(EntityImpl srow)

unpin

public boolean unpin(EntityImpl srow)

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.

addForAltKey

protected EntityImpl addForAltKey(int keyIndex,
                                  EntityImpl srow)

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.

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.

getForAltKey

public EntityImpl getForAltKey(int keyIndex,
                               Key key)

hasRows

public boolean hasRows()

addRowByDeletedPK

protected void addRowByDeletedPK(Key pkey,
                                 EntityImpl srow)

removeRowByDeletedPK

protected EntityImpl removeRowByDeletedPK(EntityImpl srow)

removeRowByOldPK

protected EntityImpl removeRowByOldPK(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)

clearCache

protected void clearCache()

iterator

protected java.util.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.

iterator

public java.util.Iterator iterator(boolean inclSubclasses)

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.

deliverEntityEvent

protected void deliverEntityEvent(EntityEvent event)

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.

replace

protected void replace(EntityImpl srow,
                       Key[] okeys)

replaceForAltKey

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

getPreparedSelectStatement

protected java.sql.PreparedStatement getPreparedSelectStatement(boolean lock)

getPrepSelStmtForAltKey

protected java.sql.PreparedStatement getPrepSelStmtForAltKey(int keyIndex,
                                                             boolean lock)

createPreparedStatement

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

createPrepStmtForAltKey

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

isBatchable

protected boolean isBatchable(int operation)

closeStatements

protected void closeStatements()

getCurrentDbTime

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

Returns:
current database time.

isAssociationAccessorRetained

public boolean isAssociationAccessorRetained()

setAssociationAccessorRetained

public void setAssociationAccessorRetained(boolean b)

getAttributeDefs

public AttributeDef[] getAttributeDefs()
Description copied from interface: StructureDef
Gets the defined attributes.

Specified by:
getAttributeDefs in interface StructureDef
Returns:
an array of attribute definitions.

getAttributeDefImpls

public AttributeDefImpl[] getAttributeDefImpls()

getBaseAttributeCount

public int getBaseAttributeCount()

getAttributeCount

public int getAttributeCount()
Description copied from interface: StructureDef
Returns the number of defined attributes.

Specified by:
getAttributeCount in interface StructureDef
Returns:
the number of attributes.

lookupAttributeDef

public AttributeDef lookupAttributeDef(java.lang.String name)
Description copied from interface: StructureDef
Gets an attribute definition, given its name.

Specified by:
lookupAttributeDef in interface AttributeDependencyManager
Specified by:
lookupAttributeDef in interface StructureDef
Parameters:
name - the name of an AttributeDef.
Returns:
an attribute definition if found, null otherwise

findAttributeDef

public AttributeDef findAttributeDef(java.lang.String name)
Description copied from interface: StructureDef
Gets an attribute definition, given its name.

Specified by:
findAttributeDef in interface StructureDef
Parameters:
name - the name of an AttributeDef.
Returns:
an attribute definition

getAttributeDef

public AttributeDef getAttributeDef(int index)
Description copied from interface: StructureDef
Gets an attribute definition, given its index.

Specified by:
getAttributeDef in interface StructureDef
Parameters:
index - the index of an AttributeDef, where the leftmost attribute has index zero.
Returns:
an attribute definition.

getAttributeIndexOf

public int getAttributeIndexOf(java.lang.String name)
Description copied from interface: StructureDef
Finds the index (0-based) of the named attribute.

Specified by:
getAttributeIndexOf in interface StructureDef
Parameters:
name - the attribute's name.
Returns:
an integer in the range 0 to getAttributeCount() - 1. If the named attribute is not found, it returns -1.

getColumnNameForQuery

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

lookupViewAccessorDef

public ViewAccessorDef lookupViewAccessorDef(java.lang.String vaName)

findViewAccessorDef

public ViewAccessorDef findViewAccessorDef(java.lang.String name)

addDynamicAttribute

public AttributeDef addDynamicAttribute(java.lang.String attrName)

hasLOBAttrs

public boolean hasLOBAttrs()

getLOBAttrs

public java.util.List getLOBAttrs()

getBackwardDependencyAttributes

public java.util.List getBackwardDependencyAttributes(java.lang.String attrName)
Specified by:
getBackwardDependencyAttributes in interface AttributeDependencyManager

getForwardDependencyAttributes

public java.util.List getForwardDependencyAttributes(java.lang.String attrName)
Specified by:
getForwardDependencyAttributes in interface AttributeDependencyManager

getBackwardDependencies

public java.util.HashSet<java.lang.String> getBackwardDependencies(java.lang.String attrName)
Specified by:
getBackwardDependencies in interface AttributeDependencyManager

getForwardDependencies

public java.util.HashSet<java.lang.String> getForwardDependencies(java.lang.String attrName)
Specified by:
getForwardDependencies in interface AttributeDependencyManager

addForwardDependency

public void addForwardDependency(java.lang.String attrName,
                                 java.lang.String depName)
Specified by:
addForwardDependency in interface AttributeDependencyManager

getTriggersOfType

public java.util.ArrayList getTriggersOfType(TriggerType type)

lookupTrigger

protected JboValidatorInterface lookupTrigger(TriggerType trig,
                                              java.lang.String name,
                                              boolean localOnly)

personalizeTrigger

public void personalizeTrigger(TriggerType trig,
                               JboValidatorHints persValidator)
For internal use only. Application developers should not use this

addTrigger

public void addTrigger(TriggerType trig,
                       JboValidatorInterface aValidator)

lookupValidator

public JboValidatorInterface lookupValidator(java.lang.String name,
                                             boolean localOnly)

getValidators

public java.util.ArrayList getValidators()
Specified by:
getValidators in interface ValidationManager

addValidator

public void addValidator(JboValidatorInterface aValidator)
Specified by:
addValidator in interface ValidationManager

removeValidator

public boolean removeValidator(JboValidatorInterface aValidator)

validate

public void validate(EntityImpl validateEntity)

addEventAttr

public void addEventAttr(java.lang.String attrName)

getCreateEvents

public java.util.Iterator<EventMapping> getCreateEvents()

getUpdateEvents

public java.util.Iterator<EventMapping> getUpdateEvents()

getDeleteEvents

public java.util.Iterator<EventMapping> getDeleteEvents()

getEventDef

public EventDef getEventDef(java.lang.String name)

getEventNamespace

public java.lang.String getEventNamespace()

getEventPayloadNamespace

public java.lang.String getEventPayloadNamespace()

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.

getRSI

public static RowSetIterator getRSI(DBTransaction trans,
                                    java.lang.String amUsageName,
                                    java.lang.String voName,
                                    java.lang.String rsiName)

getEffDtDateDayAddStatement

protected java.sql.PreparedStatement getEffDtDateDayAddStatement()
Returns a cached statement that returns a date that is 'x' number of days apart from the specified date.

Returns:
A PreparedStatement object.

createEffDtDateDayAddStatement

protected java.sql.PreparedStatement createEffDtDateDayAddStatement()
Create a PreparedStatement that could be cached and reused to compute the sum/difference between a date and specified number of days.

Returns:
A PreparedStatement object.

getComparator

public static java.util.Comparator getComparator()

Oracle Fusion Middleware Java API Reference for Oracle ADF Model
11g Release 2 (11.1.2.0.0)

E17483-01

Copyright © 1997, 2011, Oracle. All rights reserved.