We are building a multi-tenant application that uses separate DBs per tenant. We used an AbstractPoolingDataSource for that as described in this post:
http://blog.springsource.com/2007/01/23/dynamic-datasource-routing/. With this approach, cache regions of the 2nd-Level-Cache will be shared across tenants, which leads to conflicting cache keys (as the DB-IDs are not unique across all tenant DBs). This is also described in the comments of the post, and there is also a solution which uses a CacheWrapper that modifies the cache keys when entries are written or read from the cache.
This solution would be okay for us, too. But I just wanted to ask, if it's possible to separate the caches more strictly, e.g. a cache region per tenant. Thought about a cache region prefix per tenant, but it seems cache region prefixes can only be set per SessionFactory (but I only have a single SF for all tenants, I'm just switching the DataSource).