public class ERXDatabaseContextDelegate extends Object
EODatabaseContext.Delegate
.
Of special note this class adds the ability
for enterprise objects to generate their own primary keys, correctly throws an
exception when a toOne relationship object is not found in the database and adds
debugging abilities to tracking down when faults are fired. It also supports a cache for
array fault that is checked before they are fetched from the database.Name | Description |
---|---|
er.extensions.ERXDatabaseContextDelegate.Exceptions.regex | regular expression to check the exception test for if database connection should be reopened |
Modifier and Type | Class and Description |
---|---|
static interface |
ERXDatabaseContextDelegate.AutoBatchFaultingEnterpriseObject
Interface to provide auto-magic batch fetching.
|
static interface |
ERXDatabaseContextDelegate.BatchHandler |
static class |
ERXDatabaseContextDelegate.ObjectNotAvailableException |
Modifier and Type | Field and Description |
---|---|
static int |
autoBatchFetchSize
Holds the auto batch fetch size.
|
static Logger |
batchLog
Faulting logging support, logging category: er.transaction.adaptor.Batching
|
static String |
DatabaseContextFailedToFetchObject |
static Logger |
dbLog
Faulting logging support, logging category: er.transaction.adaptor.FaultFiring
|
static String |
ERX_ADAPTOR_EXCEPTIONS_REGEX |
static String |
ERX_ADAPTOR_EXCEPTIONS_REGEX_DEFAULT |
static Logger |
exLog
Faulting logging support, logging category: er.transaction.adaptor.Exceptions
|
static Logger |
log
Basic logging support
|
static String |
THREAD_KEY
Batching thread key
|
Constructor and Description |
---|
ERXDatabaseContextDelegate() |
Modifier and Type | Method and Description |
---|---|
ERXArrayFaultCache |
arrayFaultCache() |
static int |
autoBatchFetchSize()
Returns the batch size for automatic batch faulting from the System property
er.extensions.ERXDatabaseContextDelegate.autoBatchFetchSize . |
void |
databaseContextDidFetchObjects(com.webobjects.eoaccess.EODatabaseContext dbc,
NSArray eos,
com.webobjects.eocontrol.EOFetchSpecification fs,
com.webobjects.eocontrol.EOEditingContext ec)
Sets the cache entry for the fetched objects and refreshes the timestamps
for fetched objects if batch faulting is enabled.
|
void |
databaseContextDidSelectObjects(com.webobjects.eoaccess.EODatabaseContext dc,
com.webobjects.eocontrol.EOFetchSpecification fs,
com.webobjects.eoaccess.EODatabaseChannel channel)
This delegate method is called every time a fault is fired that needs
to go to the database.
|
boolean |
databaseContextFailedToFetchObject(com.webobjects.eoaccess.EODatabaseContext context,
Object object,
com.webobjects.eocontrol.EOGlobalID gid)
This is Kelly Hawks' fix for the missing to one relationship.
|
NSDictionary<String,Object> |
databaseContextNewPrimaryKey(com.webobjects.eoaccess.EODatabaseContext databaseContext,
Object object,
com.webobjects.eoaccess.EOEntity entity)
Provides the ability for new enterprise objects that implement the interface
ERXGeneratesPrimaryKeyInterface
to provide their own primary key dictionary. |
boolean |
databaseContextShouldFetchArrayFault(com.webobjects.eoaccess.EODatabaseContext dbc,
Object obj)
This delegate method first checks the arrayFaultCache if it is set before
trying to resolve the fault from the DB.
|
boolean |
databaseContextShouldFetchObjectFault(com.webobjects.eoaccess.EODatabaseContext dbc,
Object obj)
Batch fetches to one relationships if enabled.
|
NSArray |
databaseContextShouldFetchObjects(com.webobjects.eoaccess.EODatabaseContext dbc,
com.webobjects.eocontrol.EOFetchSpecification fs,
com.webobjects.eocontrol.EOEditingContext ec)
Returns an array of already fetched objects or null if they were not already fetched.
|
boolean |
databaseContextShouldHandleDatabaseException(com.webobjects.eoaccess.EODatabaseContext dbc,
Exception e)
Allows custom handling of dropped connection exceptions.
|
boolean |
databaseContextShouldHandleDatabaseException(com.webobjects.eoaccess.EODatabaseContext databaseContext,
Throwable throwable)
Provides for a hook to get at the original exceptions from the JDBC
driver, as opposed to the cooked EOGeneralAdaptorException you get from
EOF.
|
NSArray |
databaseContextWillPerformAdaptorOperations(com.webobjects.eoaccess.EODatabaseContext dbCtxt,
NSArray adaptorOps,
com.webobjects.eoaccess.EOAdaptorChannel adChannel)
Overridden to remove inserts and deletes of the "same" row.
|
static ERXDatabaseContextDelegate |
defaultDelegate()
Returns the singleton of the database context delegate
|
ERXFetchResultCache |
fetchResultCache() |
void |
setArrayFaultCache(ERXArrayFaultCache value) |
void |
setBatchHandler(ERXDatabaseContextDelegate.BatchHandler handler)
Sets the batch handler.
|
static void |
setCurrentBatchObjects(NSArray arr) |
static void |
setDefaultDelegate(ERXDatabaseContextDelegate delegate) |
void |
setFetchResultCache(ERXFetchResultCache value) |
public static final String DatabaseContextFailedToFetchObject
public static final String ERX_ADAPTOR_EXCEPTIONS_REGEX
public static final String ERX_ADAPTOR_EXCEPTIONS_REGEX_DEFAULT
public static final Logger log
public static final Logger dbLog
public static final Logger exLog
public static final Logger batchLog
public static int autoBatchFetchSize
public static final String THREAD_KEY
public static ERXDatabaseContextDelegate defaultDelegate()
public static void setDefaultDelegate(ERXDatabaseContextDelegate delegate)
delegate
- - the singleton database context delegate to setpublic ERXArrayFaultCache arrayFaultCache()
public void setArrayFaultCache(ERXArrayFaultCache value)
public ERXFetchResultCache fetchResultCache()
public void setFetchResultCache(ERXFetchResultCache value)
public NSArray databaseContextShouldFetchObjects(com.webobjects.eoaccess.EODatabaseContext dbc, com.webobjects.eocontrol.EOFetchSpecification fs, com.webobjects.eocontrol.EOEditingContext ec)
dbc
- fs
- ec
- public void databaseContextDidFetchObjects(com.webobjects.eoaccess.EODatabaseContext dbc, NSArray eos, com.webobjects.eocontrol.EOFetchSpecification fs, com.webobjects.eocontrol.EOEditingContext ec)
dbc
- eos
- fs
- ec
- public boolean databaseContextShouldHandleDatabaseException(com.webobjects.eoaccess.EODatabaseContext databaseContext, Throwable throwable)
databaseContext
- the current database contextthrowable
- the original exceptiontrue
if the exception has been handled alreadypublic NSDictionary<String,Object> databaseContextNewPrimaryKey(com.webobjects.eoaccess.EODatabaseContext databaseContext, Object object, com.webobjects.eoaccess.EOEntity entity)
ERXGeneratesPrimaryKeyInterface
to provide their own primary key dictionary. If the enterprise object implements the above interface then the
method primaryKeyDictionary(true)
will be called on the object. If the object returns null then a
primary key will be generated for the object in the usual fashion.databaseContext
- databasecontextobject
- the new enterprise objectentity
- the entity of the objectpublic boolean databaseContextShouldHandleDatabaseException(com.webobjects.eoaccess.EODatabaseContext dbc, Exception e) throws Throwable
dbc
- current database contexte
- throw exceptionhandleDroppedConnection
is called directly on the database object of the context and false
is returned otherwise true
.Throwable
public boolean databaseContextFailedToFetchObject(com.webobjects.eoaccess.EODatabaseContext context, Object object, com.webobjects.eocontrol.EOGlobalID gid)
EOObjectNotAvailableException
. er.extensions.ERXDatabaseContextDelegate.tolerantEntityPattern
to a regular expression
that will be tested against the GID entity name. If it matches, then only an error will be logged
but no exception will be thrown.context
- database contextobject
- object that is firing the fault for a given to-one relationshipgid
- global id that wasn't found in the database.public void databaseContextDidSelectObjects(com.webobjects.eoaccess.EODatabaseContext dc, com.webobjects.eocontrol.EOFetchSpecification fs, com.webobjects.eoaccess.EODatabaseChannel channel)
ERXPatternLayout
one can set the option to
see full backtraces to the calling method. With this option specified
a developer can see exactly which methods are firing faults.dc
- the databasecontextfs
- the fetchspecificationchannel
- the databasechannelpublic boolean databaseContextShouldFetchArrayFault(com.webobjects.eoaccess.EODatabaseContext dbc, Object obj)
dbc
- obj
- public boolean databaseContextShouldFetchObjectFault(com.webobjects.eoaccess.EODatabaseContext dbc, Object obj)
dbc
- obj
- public NSArray databaseContextWillPerformAdaptorOperations(com.webobjects.eoaccess.EODatabaseContext dbCtxt, NSArray adaptorOps, com.webobjects.eoaccess.EOAdaptorChannel adChannel)
dbCtxt
- adaptorOps
- adChannel
- public static int autoBatchFetchSize()
er.extensions.ERXDatabaseContextDelegate.autoBatchFetchSize
.
Default is 0, meaning it's disabled.public void setBatchHandler(ERXDatabaseContextDelegate.BatchHandler handler)
handler
- public static void setCurrentBatchObjects(NSArray arr)
Copyright © 2002 – 2020 Project Wonder.