5

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.

  • You may also want to consider updating to the latest Hibernate version available to you. There were issues with he 4.1.{1-4} releases where Hibernate did not respect the CurrentTenantIdentifierResolver value. I'm [still fighting this is issue](http://stackoverflow.com/questions/14837601/multi-tenancy-with-spring-hibernate-sessionfactory-configured-for-multi-tena) with Spring + Hibernate 4.1.9. – Craige Feb 24 '13 at 20:12

1 Answers1

4

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.

Community
  • 1
  • 1
Craige
  • 2,882
  • 2
  • 20
  • 28