I need to implement multitenancy in hibernate. I currently support multiple database platforms. I have a new need to support multitenancy dynamically. When I need to add a new tenant, I cannot stop the server and restart. The new tenant must br created and configured on the fly. I want to use “schema” multitenancy.
I have read this post and thought it would work for me:
In this solution, can anyone tell me what component is pooling the connections and where that is configured?
@triforce Yes I did. I used Hibernate’s multitenancy framework. The center of it is this class:
MultiTenantConnectionProvider
I use Liquibase to generate the schema DDL. I used Hikari to store the connection pools. I have a connection pool per tenant.
I didn’t feel that scaled very well, so on Postgres, I was able to use a single connection pool for all tenants and set the schema on the JDBC connection dynamically. This scales and works very well, but only works for Postgres.