Jul 24th, 2007, 09:23 AM
Modifying cacheKey for multiple datasources via interceptor
we are currently working on an application which switches the datasource by loging in according to the users organisation.
the switching is done via HotSwappableTargetSource with one sessionfactory and seems to work fine (all sources have same schema).
After all we tried to enable ehcache for hibernate and ran into a small issue.
- 1. i try to get com.example.domain.UserEO with id#1 from datasource A
- 2. i try to get com.example.domain.UserEO with id#1 from datasourceB
Result: instead of querying the second userEO, ehCache gives me the result from the cache:
Cache lookup: com.example.domain.UserEOImpl#1
Cache hit: com.example.domain.UserEOImpl#1
[without enabled cache the results come from both datasources...]
so my questions are..
is there any possibillity to modify the cacheKey in order to differ both queries?
is it possible to use setCacheRegion via spring interceptor?
so the cache key could be modified according to the used datasource....
or am i getting things completly wrong?
i would be grateful for any expiriences or solutions..
thanks in advance!!
by the way - we are using