/multi-tenant

Spring Boot + Spring JPA + Hibernate + Postgresql

Primary LanguageJava

Spring Boot Hibernate Multi-tenant Demo

This sample project uses hibernate "SEPARATE DATABASE" multi-tenant strategy, and it also allows you to plugin new database (datasources) at runtime.

Useful resources 1 2 3 4

Running the demo

You need to add a table orders in database (PostgreSQL in this case but ofcourse you can choose anyone)

CREATE TABLE "orders" (
"id" int4 NOT NULL,
"date" date NOT NULL
);

Available URLs

curl -v POST -H "X-TenantID: DB1" "http://localhost:8080/orders"
curl -v POST -H "X-TenantID: DB2" "http://localhost:8080/orders"
curl -v POST -H "X-TenantID: DB3" "http://localhost:8080/orders"