How to enable Multitenancy with Spring Data Jpa

后端 未结 1 631
暗喜
暗喜 2020-12-07 03:56

Background : I am building a Multitenant SaaS app and have chosen single database, shared schema as the Multitenancy approach. Every table has a discriminat

1条回答
  •  庸人自扰
    2020-12-07 04:47

    I have blogged about Multi-tenant applications using Spring Boot, JPA, Hibernate and Postgres and even though I took the DB per tenant approach, the DISCRIMINATOR (One or multiple table columns used to specify different tenants) approach you are using most-likely requires less configuration.

    Take a look at the CurrentTenantIdentifierResolver implementation (TenantDvdRentalIdentifierResolverImpl.java), the DvdRentalMultiTenantInterceptor.java Spring MVC interceptor and DvdRentalTenantContext.java that uses the ThreadLocal to store / pass the tenantId.

    0 讨论(0)
提交回复
热议问题