Are the databases on the same server? Will they always be on the same server? You can access tables on other databases of the same server just by fully qualifying the table names, and using just the one sesion factory. So you'd use something like "otherdatabase.dbo.othertable", or however your DBMS handles it. The only things that don't work across databases like this are relational constraints (foreign keys).
If the databases are on separate servers, you could try link servers to do the same thing. I know that only a few DBMSs handle link servers, so this mightn't be an option for you.
I can't think of a purely hibernate solution to this. Possibly do something like what hibernate does when it proxies associations? Inside the get method of the objects from database1 is an "if null then fetch from database2" bit of code? Not exactly bean-like, but at least it's object oriented.
_________________ Code tags are your friend. Know them and use them.
|