# Hibernate Multitenancy

**URL:** https://discourse.hibernate.org/t/hibernate-multitenancy/3192
**Category:** Hibernate ORM
**Created:** [September 5, 2019, 2:45pm UTC](https://discourse.hibernate.org/t/hibernate-multitenancy/3192 "2019-09-05T14:45:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zeigler](https://avatars.discourse-cdn.com/v4/letter/z/90ced4/32.png) [@zeigler](https://discourse.hibernate.org/u/zeigler)
#### Post date: [September 5, 2019, 2:45pm UTC](https://discourse.hibernate.org/t/hibernate-multitenancy/3192/1 "2019-09-05T14:45:50Z")

</div>

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:

> **[Hibernate database schema multitenancy - Vlad Mihalcea](https://vladmihalcea.com/hibernate-database-schema-multitenancy/)**
>
> Learn how to implement a schema-based database multitenancy architecture when using JPA and Hibernate.

In this solution, can anyone tell me what component is pooling the connections and where that is configured?

---

<div class="post-metadata">

### Author: ![triforce](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/triforce/32/3529_2.png) [@triforce](https://discourse.hibernate.org/u/triforce)
#### Post date: [October 17, 2024, 1:53pm UTC](https://discourse.hibernate.org/t/hibernate-multitenancy/3192/2 "2024-10-17T13:53:19Z")

</div>

Hey @zeigler,

I am researching a similar solution. Did you ever find a solution?

Thanks,

Stephen

---

<div class="post-metadata">

### Author: ![zeigler](https://avatars.discourse-cdn.com/v4/letter/z/90ced4/32.png) [@zeigler](https://discourse.hibernate.org/u/zeigler)
#### Post date: [October 17, 2024, 10:44pm UTC](https://discourse.hibernate.org/t/hibernate-multitenancy/3192/3 "2024-10-17T22:44:49Z")

</div>

@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.
