Affects Version/s: 3.1.1
Fix Version/s: None
Last commented by a User:false
HibernateTransactionManager always opens new session by invoking sessionFactory.openSession(). However with multi tenancy session should be opened by sessionFactory.withOptions().tenantIdentifier(tenantIdentifier).openSession().
I managed to get it working with a few local modifications
1)adding new property to HibernateTransactionManager, implementation of org.hibernate.context.spi.CurrentTenantIdentifierResolver
2)using new property if present to open session in multi tenant way
3)modification of key used to bind session to thread
TransactionSynchronizationManager.bindResource(new MultiKey(sessionFactory,tenantIdentifierFromResolverOrNull), txObject.getSessionHolder());
4)modification of key used by SpringSessionContext to retrive earlier created session when callin sessionFactory.getCurrentSession() in my app code
Unfortunately this is not very neat solution to the problem and probably has some negative, unforeseen by me consequences.