# Hibernate mult-Tenant not working in javaee

**URL:** <https://discourse.hibernate.org/t/hibernate-mult-tenant-not-working-in-javaee/8900>\
**Category:** Hibernate ORM\
**Created:** [January 24, 2024, 11:06pm UTC](https://discourse.hibernate.org/t/hibernate-mult-tenant-not-working-in-javaee/8900 "2024-01-24T23:06:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Rouse](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/marco_rouse/32/2906_2.png) [@Marco\_Rouse](https://discourse.hibernate.org/u/Marco_Rouse)\
**Post date:** [January 24, 2024, 11:06pm UTC](https://discourse.hibernate.org/t/hibernate-mult-tenant-not-working-in-javaee/8900/1 "2024-01-24T23:06:20Z")

</div>

Hello, I’m trying to setup a multi tenant app on glassfish 7.0.10 and Mysql 8 with hibernate, I defined a SchemaMultiTenantConnectionProvider and the tenant context, I’m using a separate schemas and when 2 or more schemas (customers) are using the app the information from one schema ends up in the other schemas view.  
The getConnection method on the provider changes the schema

```auto
        Connection myDSConnection = myDS.getConnection();
        myDSConnection.setSchema(s.toLowerCase(Locale.ROOT));
        myDSConnection.createStatement().execute(String.format("USE %s;", s.toLowerCase(Locale.ROOT)));

```

I can’t figure out why its doing this, as there are no errors in the log. I tried the glassfish pool the mysql jdbc pool and I still have the same problem.

I don’t know if its a bug in hibernate or the glassfish/mysql pool

Has anyone run into this problem or have any suggestions ?

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [January 25, 2024, 11:02am UTC](https://discourse.hibernate.org/t/hibernate-mult-tenant-not-working-in-javaee/8900/2 "2024-01-25T11:02:27Z")

</div>

Please share your `SchemaMultiTenantConnectionProvider` implementation.
