

Using Multiple EODatabaseChannels
By default, an EODatabaseContext uses one EODatabaseChannel. However, occasionally your application needs more channels. Conflicts due to "busy channels" can occur when an EODatabaseContext needs to perform a database operation and its EODatabaseChannel is already fetching. Most such conflicts are manifestations of inefficient database access and can be avoided. For more information, see the section "Cautions in Implementing Accessor Methods" in the chapter "Designing Enterprise Objects." However, if you can't eliminate fetching conflicts, using additional EODatabaseChannels is an option.Note: You should set an upper limit on the number of EODatabaseChannels your application registers with an EODatabaseContext. It's very unusual for an EODatabaseContext to require more than two or three EODatabaseChannels.
The following code examples demonstrate creating a new EODatabaseChannel and registering it with an EODatabaseContext:
EODatabaseContext context; // Assume this existsIn Objective-C:
EODatabaseChannel channel = new EODatabaseChannel(context);
if (channel) context.registerChannel(channel);
EODatabaseContext *context; // Assume this existsThe EODatabaseChannel constructor can return null if no more channels can be associated with the EODatabaseContext. Similarly, in Objective-C, the EODatabaseChannel method initWithDatabaseContext: can return nil if no more channels can be associated with the EODatabaseContext. Some database servers and their corresponding adaptors don't support multiple channels per context. For example, the Sybase adaptor only supports one EODatabaseChannel per EODatabaseContext.
EODatabaseChannel *channel = [[EODatabaseChannel alloc]
initWithDatabaseContext:context];
if (channel) [context registerChannel:channel];
Table of Contents
Next Section