ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David McReynolds" <david.mcreyno...@gmail.com>
Subject duplicate databases
Date Tue, 21 Oct 2008 13:53:36 GMT
Precondition: I know this is a screwy set up. But, it is, what it is. What I
need, are ideas for dealing with it, and any heads up dor potential
nightmares.

We have two databases that are supposed to remain synchronized. For some
reason, there is no abstraction layer (hardware or otherwise) that presents
the databases as one to the application layer.

What I have done so far, is create two sqlMapConfig files which define the
two datasources and include the map files.

Then, I have an SqlMapClientFactory that accepts a "resourceName" and a
"resourceType", the latter being "Primary" or "Secondary", the former being
one of many different datasources the application must deal with.

Finally, I altered the iBator generated DAO constructors to accept the
"resourceName". Then each method has to be get the SqlMapClient instance
from the factory (which is caching the references: Primary and Secondary).
The bodies of the DAO methods are written with try/catch and the catch
blocks attempt the same operation but with the "Secondary" SqlMapClient.
Only if the secondary fails is the standard ibatis sql exception allowed to
propagate up.

--
dlm

Mime
View raw message