Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate 4.1.1 Multi-tenancy CurrentTenantIdentifierResolver approach, any example

Hibernate 4.1.1 Multi-tenancy CurrentTenantIdentifierResolver approach, any example. My concern is how the hibernate cache will be updated when we switch schema/tenant.

Any help will be appreciated.

like image 695
user2072692 Avatar asked Oct 05 '22 00:10

user2072692


1 Answers

As per the Hibernate documentation on multi-tenancy:

16.3.3. Caching

Multi-tenancy support in Hibernate works seamlessly with the Hibernate second level cache. The key used to cache data encodes the tenant identifier.

Which basically means that instead of Hibernate using the UID of the entity, it uses the identifier returned by CurrentTenantIdentifierResolver.resolveCurrentTenantIdentifier() plus the entity UID. This means each entity in the cache is unique to its schema.

like image 170
Craige Avatar answered Oct 10 '22 01:10

Craige