Hi,
this question concerns the JBoss Cache and Hibernate.
Hibernate have a "limitation" that I would like to overcome.
Hibernate cannot use the Same Schma for 2 different databases. Using C-JDBC is not the answer either.
See:
http://forum.hibernate.org/viewtopic.php?t=937847
http://forum.hibernate.org/viewtopic.php?t=938654&highlight=schema+multiple+database
I read in the JBoss faq
http://docs.jboss.org/jbcache/FAQ.html and in the documentation that the JBoss cache can use a Cache Loader (since 1.1) to persist its cache objects (FileCacheLoader, BdcjeCacheLoader and JDBCCacheLoader).
Quote:
A CacheLoader is the connection of JBossCache to a (persistent) data store. The CacheLoader is called by JBossCache to fetch data from a store when that data is not in the cache, and when modifications are made to data in the cache the CacheLoader is called to store those modifications back to the store.
In conjunction with eviction policies, JBossCache with a CacheLoader allows a user to maintain a bounded cache for a large backend datastore. Frequently used data is fetched from the datastore into the cache, and the least used data is evicted, in order to provide fast access to frequently accessed data. This is all configured through XML, and the programmer doesn't have to take care of loading and eviction.
Would it be possible that 2 SessionFactory (each connect to a different physical DB, with a different schma: Schema 1 on DB1:Oracle, Schema 2 on DB2:Sybase) use the SAME cache loader? I means that if a Parent table is on Sybase, the Children data (on Oracle) could be retreived in memory because it could have been load in the same cache before?
But from this mail:
http://forum.hibernate.org/viewtopic.php?t=938654&highlight=schema+multiple+database it seems that it isn't the case.
Quote:
First, no, Hibernate will not be implementing in-memory joins
But if the CacheLoader do the job, could it be possible? I think about 2 BdcjeCacheLoader for each SessionFactory loading in the same SleepyCat BD?
Quote:
BdbjeCacheLoader: this implementation is based on the Sleepycat Java Edition database, a fast and efficient transactional database. It uses a single file for the entire store.
http://www.sleepycat.com/jeforjbosscache for details.
Another options could be, using the JDBCCacheLoader, and cache the DB1:Oracle data inside the DB2:Sybase in a extended schema? So, the connection factory on DB2:Sybase might have all the data?
I know this sound tricky to say the less, but could it be feasible by writing a CustomClassLoader?
The goal of all this is to simulate a transparent SQL INNER JOIN between two physical databases and avoid tousand of "SQL SELECT" on a real DB.
Note that the DB1:Oracle maintain only read-only data (easily cachable) and only updated by a batch process each day at 12AM. The DB2:Sybase would be the transactinoal (r/w) database.
Thanks for replying
Etienne.
Montreal