
Classes | |
| interface | AutoBatchFaultingEnterpriseObject |
| interface | BatchHandler |
| class | ObjectNotAvailableException |
| class | ReentranceProtector |
Public Member Functions | |
| ERXArrayFaultCache | arrayFaultCache () |
| void | databaseContextDidFetchObjects (EODatabaseContext dbc, NSArray eos, EOFetchSpecification fs, EOEditingContext ec) |
| void | databaseContextDidSelectObjects (EODatabaseContext dc, EOFetchSpecification fs, EODatabaseChannel channel) |
| boolean | databaseContextFailedToFetchObject (EODatabaseContext context, Object object, EOGlobalID gid) |
| NSDictionary | databaseContextNewPrimaryKey (EODatabaseContext databaseContext, Object object, EOEntity entity) |
| boolean | databaseContextShouldFetchArrayFault (EODatabaseContext dbc, Object obj) |
| boolean | databaseContextShouldFetchObjectFault (EODatabaseContext dbc, Object obj) |
| NSArray | databaseContextShouldFetchObjects (EODatabaseContext dbc, EOFetchSpecification fs, EOEditingContext ec) |
| boolean | databaseContextShouldHandleDatabaseException (EODatabaseContext dbc, Exception e) throws Throwable |
| boolean | databaseContextShouldHandleDatabaseException (EODatabaseContext databaseContext, Throwable throwable) |
| NSArray | databaseContextWillPerformAdaptorOperations (EODatabaseContext dbCtxt, NSArray adaptorOps, EOAdaptorChannel adChannel) |
| ERXFetchResultCache | fetchResultCache () |
| void | setArrayFaultCache (ERXArrayFaultCache value) |
| void | setBatchHandler (BatchHandler handler) |
| void | setFetchResultCache (ERXFetchResultCache value) |
Static Public Member Functions | |
| static int | autoBatchFetchSize () |
| static ERXDatabaseContextDelegate | defaultDelegate () |
| static void | setCurrentBatchObjects (NSArray arr) |
| static void | setDefaultDelegate (ERXDatabaseContextDelegate delegate) |
Static Public Attributes | |
| static int | autoBatchFetchSize = -1 |
| static final Logger | batchLog = Logger.getLogger("er.transaction.adaptor.Batching") |
| static final String | DatabaseContextFailedToFetchObject = "DatabaseContextFailedToFetchObject" |
| static final Logger | dbLog = Logger.getLogger("er.transaction.adaptor.FaultFiring") |
| static final Logger | exLog = Logger.getLogger("er.transaction.adaptor.Exceptions") |
| static final Logger | log = Logger.getLogger(ERXDatabaseContextDelegate.class) |
| static final String | THREAD_KEY = "ERXBatching" |
Private Member Functions | |
| boolean | batchFetchToManyFault (EODatabaseContext dbc, Object obj) |
| synchronized boolean | batchFetchToOneFault (EODatabaseContext dbc, AutoBatchFaultingEnterpriseObject eo) |
| void | doFetch (EODatabaseContext dbc, EOEditingContext ec, EORelationship relationship, NSArray eos) |
| void | freshenFetchTimestamps (NSArray eos, long timestamp) |
| void | markEnd (String type, EOEnterpriseObject eo, String key) |
| void | markStart (String type, EOEnterpriseObject eo, String key) |
Private Attributes | |
| ERXArrayFaultCache | _arrayFaultCache = null |
| ERXFetchResultCache | _fetchResultCache = null |
| BatchHandler | _handler = DEFAULT |
| BatchHandler | DEFAULT |
| ReentranceProtector | fetchingToMany = new ReentranceProtector() |
| ReentranceProtector | fetchingToOne = new ReentranceProtector() |
| ReentranceProtector | reportingError = new ReentranceProtector() |
Static Private Attributes | |
| static ERXDatabaseContextDelegate | _defaultDelegate = new ERXDatabaseContextDelegate() |
| ERXArrayFaultCache arrayFaultCache | ( | ) |
| static int autoBatchFetchSize | ( | ) | [static] |
Returns the batch size for automatic batch faulting from the System property er.extensions.ERXDatabaseContextDelegate.autoBatchFetchSize. Default is 0, meaning it's disabled.
| boolean batchFetchToManyFault | ( | EODatabaseContext | dbc, | |
| Object | obj | |||
| ) | [private] |
Fetches the to-many fault and the faults of all other objects in the EC that have the same relationship, the fetch timestamp and the same class description.
| dbc | database context | |
| obj | to-many fault |
| synchronized boolean batchFetchToOneFault | ( | EODatabaseContext | dbc, | |
| AutoBatchFaultingEnterpriseObject | eo | |||
| ) | [private] |
Fetches the to-one fault and the faults of all other objects in the EC that have the same relationship, the fetch timestamp and the same class description.
| dbc | database context | |
| obj | to-one fault |
| void databaseContextDidFetchObjects | ( | EODatabaseContext | dbc, | |
| NSArray | eos, | |||
| EOFetchSpecification | fs, | |||
| EOEditingContext | ec | |||
| ) |
Sets the cache entry for the fetched objects and refreshes the timestamps for fetched objects if batch faulting is enabled.
| dbc | ||
| eos | ||
| fs | ||
| ec |
| void databaseContextDidSelectObjects | ( | EODatabaseContext | dc, | |
| EOFetchSpecification | fs, | |||
| EODatabaseChannel | channel | |||
| ) |
This delegate method is called every time a fault is fired that needs to go to the database. All we have added is logging statement of the debug priority. This way during runtime a developer can toggle the logger priority settting on and off to see what faults are firing. Also note that when using 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 databasecontext | |
| fs | the fetchspecification | |
| channel | the databasechannel |
| boolean databaseContextFailedToFetchObject | ( | EODatabaseContext | context, | |
| Object | object, | |||
| EOGlobalID | gid | |||
| ) |
This is Kelly Hawks' fix for the missing to one relationship. Delegate on EODatabaseContext that gets called when a to-one fault cannot find its data in the database. The object that is returned is a cleared fault. We raise here to restore the functionality that existed prior to WebObjects 4.5. Whenever a fault fails for a globalID (i.e. the object is NOT found in the database), we raise an EOObjectNotAvailableException.
If you have entities you don't really care about, you can set the system property 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 context | |
| object | object that is firing the fault for a given to-one relationship | |
| gid | global id that wasn't found in the database. |
| NSDictionary databaseContextNewPrimaryKey | ( | EODatabaseContext | databaseContext, | |
| Object | object, | |||
| EOEntity | entity | |||
| ) |
Provides the ability for new enterprise objects that implement the interface 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 | databasecontext | |
| object | the new enterprise object | |
| entity | the entity of the object |
| boolean databaseContextShouldFetchArrayFault | ( | EODatabaseContext | dbc, | |
| Object | obj | |||
| ) |
This delegate method first checks the arrayFaultCache if it is set before trying to resolve the fault from the DB. It can be a severe performance optimization depending on your setup. Also, it support batch fetching of to-many relationships of EOs that were fetched at the "same" time.
| dbc | ||
| obj |
| boolean databaseContextShouldFetchObjectFault | ( | EODatabaseContext | dbc, | |
| Object | obj | |||
| ) |
Batch fetches to one relationships if enabled.
| dbc | ||
| obj |
| NSArray databaseContextShouldFetchObjects | ( | EODatabaseContext | dbc, | |
| EOFetchSpecification | fs, | |||
| EOEditingContext | ec | |||
| ) |
Returns an array of already fetched objects or null if they were not already fetched.
| dbc | ||
| fs | ||
| ec |
| boolean databaseContextShouldHandleDatabaseException | ( | EODatabaseContext | dbc, | |
| Exception | e | |||
| ) | throws Throwable |
Allows custom handling of dropped connection exceptions. This was needed in WebObjects 4.5 because the OracleEOAdaptor wouldn't correctly handle all exceptions of dropped connections. This may not be needed now.
| dbc | current database context | |
| e | throw exception |
handleDroppedConnection is called directly on the database object of the context and false is returned otherwise true. | boolean databaseContextShouldHandleDatabaseException | ( | 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. To see the exceptions trace, set the logger er.transaction.adaptor.Exceptions to DEBUG.
| databaseContext | ||
| throwable |
| NSArray databaseContextWillPerformAdaptorOperations | ( | EODatabaseContext | dbCtxt, | |
| NSArray | adaptorOps, | |||
| EOAdaptorChannel | adChannel | |||
| ) |
Overridden to remove inserts and deletes of the "same" row. When you delete from a join table and then re-add the same object, then the order of operations would be insert, then delete and you will get an error because the delete would try to also delete the newly inserted row. Here we just check every insert and see if the deleted contains the same object. If they do, we just skip both operations,
| dbCtxt | ||
| adaptorOps | ||
| adChannel |
| static ERXDatabaseContextDelegate defaultDelegate | ( | ) | [static] |
Returns the singleton of the database context delegate
| void doFetch | ( | EODatabaseContext | dbc, | |
| EOEditingContext | ec, | |||
| EORelationship | relationship, | |||
| NSArray | eos | |||
| ) | [private] |
| ERXFetchResultCache fetchResultCache | ( | ) |
| void freshenFetchTimestamps | ( | NSArray | eos, | |
| long | timestamp | |||
| ) | [private] |
Refreshes the fetch timestamp for the fetched objects.
| eos | ||
| ec |
| void setArrayFaultCache | ( | ERXArrayFaultCache | value | ) |
| void setBatchHandler | ( | BatchHandler | handler | ) |
Sets the batch handler.
| handler |
| static void setCurrentBatchObjects | ( | NSArray | arr | ) | [static] |
| static void setDefaultDelegate | ( | ERXDatabaseContextDelegate | delegate | ) | [static] |
| delegate | - the singleton database context delegate to set |
| void setFetchResultCache | ( | ERXFetchResultCache | value | ) |
ERXArrayFaultCache _arrayFaultCache = null [private] |
ERXDatabaseContextDelegate _defaultDelegate = new ERXDatabaseContextDelegate() [static, private] |
Holds onto the singleton of the default delegate
ERXFetchResultCache _fetchResultCache = null [private] |
BatchHandler _handler = DEFAULT [private] |
int autoBatchFetchSize = -1 [static] |
Holds the auto batch fetch size.
final Logger batchLog = Logger.getLogger("er.transaction.adaptor.Batching") [static] |
final String DatabaseContextFailedToFetchObject = "DatabaseContextFailedToFetchObject" [static] |
final Logger dbLog = Logger.getLogger("er.transaction.adaptor.FaultFiring") [static] |
BatchHandler DEFAULT [private] |
Initial value:
new BatchHandler() { public int batchSizeForRelationship(EOEditingContext ec, EORelationship relationship) { return autoBatchFetchSize(); } }
final Logger exLog = Logger.getLogger("er.transaction.adaptor.Exceptions") [static] |
ReentranceProtector fetchingToMany = new ReentranceProtector() [private] |
The delegate is not reentrant, so this marks whether we are already batch faulting a to-many relationship.
ReentranceProtector fetchingToOne = new ReentranceProtector() [private] |
The delegate is not reentrant, so this marks whether we are already batch faulting a to-one relationship.
final Logger log = Logger.getLogger(ERXDatabaseContextDelegate.class) [static] |
Basic logging support
ReentranceProtector reportingError = new ReentranceProtector() [private] |
final String THREAD_KEY = "ERXBatching" [static] |
Batching thread key
1.5.8