Search code examples
javadatabasemulti-tenantspring-data-jdbc

Multi-Tenant Spring Data JDBC


There are several multitenancy models around https://vladmihalcea.com/database-multitenancy/

  1. Dedicated DB per tenant
  2. Shared DB, but one schema per tenant
  3. Shared schema with tenantId discriminator column per table

Are there any plans to support these scenarios conveniently with Spring Data JDBC?

Option 1 and 2 are probably tackled by multiple datasources/connection-pools support https://github.com/spring-projects/spring-data-jdbc/issues/544. Regarding option 3 it would be required to automatically inject the tenantId from the thread context into the statement.


Solution

  • As of right now there are no plans for that.

    If you are interested in this kind of feature you should open a ticket with the project.