I am building an application which will need to present a homogenous view of data from disparate datasources. In other words, I have about seven different databases that each have similiar table structure. The key being similiar as they are not all alike, some tables have rows that others do not.
So, my general thought is to define a series of Interfaces and then have objects specific to each database implement that interface.
So for instance I have interface Foo. I would then create the following POJOs: Foo_DB1, Foo_DB2, Foo_DB3, Foo_DB4, Foo_DB5, Foo_DB6, Foo_DB7. I would configure the SessionFactory with the hbm.xml files for each of the 7 different foo objects. The only way that the Session would know which one it was connecting to would by the java.sql.Connection object I pass to it.
So, I have two questions.
#1. What does everyone think about that idea? (If you don't like it, I'd really like alternative ideas.)
#2. Can I run this query "from com.mypackage.Foo foo" and pick up the proper Foo_DB object?
Cheers,
Chris
|