Hello.
I'm facing a problem implementing a Multi Tenant application that's probably a bug.
There's currently a class that implements org.hibernate.context.spi.CurrentTenantIdentifierResolver which identifies the logged in tenant fetching the logged in user.
The id is then provided to the class that extends org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider which implements the method ConnectionProvider selectConnectionProvider(String tenantIdentifier) and must return a c3p0 ConnectionProvider object to use.
The real problem is this:
When the user user1 autheticates the system, the db connection is resolved ok.
But when the user2 authenticates, the method ConnectionProvider selectConnectionProvider(String tenantIdentifier) receives as parameter user1, and not user2, leading us to select the same database as user1.
The EntityManager is implemented with the PersistenceContextType.EXTENDED annotation, that may be the problem.
|