Re: two databases from one application
Re: two databases from one application
- Subject: Re: two databases from one application
- From: Anjo Krank <email@hidden>
- Date: Wed, 10 May 2006 19:34:14 +0200
WO application I am working on was pretty simple up to
this point: one apache webserver and one database
server serving data to it. The things turned more
complicated now: In addition to the first database, we
now want to add access to another database. Both of
these databases have identical schema, and the tables
in question are identical. Think of the second
database as a backup.
You simply can't do that in an easy way.
Having said that, what you *can* do - if you are of the adventurous
type - is to use sth similar to the ERXAdaptorChannelDelegate/
ERXAdaptorOperationWrapper in Project Wonder. I'm using it to sync
two databases via - get this - email.
To do this yourself and in only one app, you'd need to set your
original DBC.context.availableChannel.delegate to an object that
listens to
public Throwable adaptorChannelDidPerformOperations(EOAdaptorChannel
channel, NSArray adaptorOps, Throwable exception) {
if (log.isDebugEnabled()) {
log.debug("adaptorChannelDidPerformOperations: count="
+ adaptorOps.count() + ", exception = " + exception);
}
if (exception == null) {
if (postAdaptorOperationNotifications()) {
otherDBC.performAdaptorOperations(adaptorOps);
}
}
return exception;
}
Of course, once your other DB is changed or modified too, you'll have
a hell of a time managing conflicts. One way to get this to a minimum
is to have your DBC delegate to implement:
public NSDictionary databaseContextNewPrimaryKey
(EODatabaseContext databaseContext, Object object, EOEntity entity) {
return ... some new ID which is unique to all DBCs;
}
Good luck, you'll need it.
Cheers, Anjo
PS: any other approach simply won't work as your EC1 doesn't have
access to the DB2.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden