ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Lamey <cla...@localmatters.com>
Subject Re: AbstractRoutingDataSource & cache
Date Fri, 06 Apr 2007 16:59:17 GMT
Hello again,

I've started writing a RoutingSqlMapClient that implements the
SqlMapInterface and delegates all calls to Map of SqlMapClients based on
a ThreadLocal.  Each target SqlMapClient will have its own specific
datasource.

My concern with this approach is the Spring declarative transaction
handling, but I think it will work.  Transactions are handled on a
per-thread basis, so as along as the key to the routing sqlmapclient
says the same on a per-thread call it should all work.

I would really appreciate any thoughts on this.

Thanks,
Chris

On Fri, 2007-04-06 at 10:03 -0600, Chris Lamey wrote:
> Hello all,
> 
> I'm looking at using Spring's new-ish AbstractRoutingDataSource to hit
> multiple DataSources with iBATIS.  I think it'll work fine in terms of
> routing to the right DataSource via a ThreadLocal, but I'm concerned
> about the iBATIS caching mechanism.
> 
> Specifically, it seems to me that if I have a single
> SqlMapClientFactoryBean with RoutingDataSource as the DataSource, the
> cache in the SqlMapClient won't know which 'real' DataSource the results
> came from and mix them all together.  So if the databases in question
> have the same schemas and some overlapping OIDs, the cache would be
> messed up.
> 
> Does that sound about right?  Is there a way to avoid that other than
> not using cache?  Is there a better way to use Spring and iBATIS with
> multiple DataSources?
> 
> Thanks,
> Chris

Mime
View raw message