We're updating the issue view to help you get more done. 

Multi-tenancy and query-cache enhancement

Description

When working with Hibernate SessionFactory configured for multi-tenancy (Multi-tenant at application level and not schema level), the Query Cache and Entity Cache(s) that are managed by Hibernate are global for all tenants. There is no API to evict this data from these caches for a specific tenant. In Hibernate 4.1.6, the CacheKey exposes the tenantId (HHH-7502) so that we can at least write some custom code to iterate over all of the keys in the entity Cache and do some custom work. But this capability is not even available for QueryKey.

We have a business use case where there is a need to evict data from Entity and Query caches for a given tenant.

It would be helpful if tenantId is exposed on the QueryKey just like it is done for the CacheKey. If this supported, then we can at least write our own custom logic. In long term it would be nice to have API(s) for evictQueryRegion/evictEntityRegion/evictCollectionRegion for a specific tenant.

Environment

Hibernate 4.1.4, Ehcache 2.4.0

Status

Assignee

Unassigned

Reporter

Kiran Kollipara

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.1.4

Priority

Major