On 11/16/06, Henry Chen <[EMAIL PROTECTED]> wrote:
Thank you. Did you come up with any solution without Tapernate?


This is relatively simple if you aren't using a framework that
explicitly prevents it.  I use swing + hibernate to provide all the
layers to my app underneath the web layer and it is trivial to provide
access to multiple databases.  I can define multiple data sources in
my application context and then provide dao beans which use the
appropriate data sources as well as service objects which utilize
those daos.  My web layer isn't even aware of the location of data.
It just calls a method in the service layer, which may use DAOs from
multiple databases to accomplish the necessary work.  And with
spring's nice declarative transactions, it is easy, within the
confines of a JTA transaction in a J2EE container, to have a single
transaction span db access to multiple databases, which is really
convenient.

In my app, I have a situation where my entire domain model is provided
via hibernate to a single domain db, but the huge volume of data that
I need to provide access to for reporting is in 2 separate data
warehouses.  The domain entities are all accessed via DAO's using
spring's built in hibernate dao support classes, and I use pure JDBC
to access the 2 separate data warehouses.  So I have about 25 DAOs
using the hibernate data source (one for each entity), and one dao
using one jdbc connection to the first warehouse and 3 separate DAOs
using JDBC connections to the second warehouse.  I have service
objects which need to pass hibernate entities to the warehouse daos so
that they can construct the correct SQL statements for building
reports, so many of my service objects receive a reference to several
hibernate DAOs as well as at least one jdbc dao.  It works like a
charm.  All transactions are declared on service object methods, so
transactions automatically encapsulate access to every database used
by the service method, and my daos don't need to know a thing about
transactions.

Honestly, I can't imagine a system of this complexity having a simpler
interface since everything is done declaratively within the spring
application context.  There's not a single line of code devoted to
dealing with multiple databases.

--sam

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to