Giter Club home page Giter Club logo

blog-multitenancy's Introduction

Multi Tenancy with Spring Boot, Hibernate & Liquibase

Overview

Multi Tenancy usually plays an important role in the business case for SAAS solutions. Spring Data and Hibernate provide out-of-the-box support for different Multi-tenancy strategies. Configuration however becomes more complicated, and the available examples are few.

This project complements my blog series on Multi Tenancy (see https://callistaenterprise.se/blogg/teknik/2020/09/19/multi-tenancy-with-spring-boot-part1/), and contains working examples of different Multi Tenant strategies implemented with Spring Boot, Hibemate and Liquibase, complete with support for database migrations as well as dynamically set up new tenants on the fly.

How to use the examples

The master branch contains a common, minimal example project skeleton. The different Multi-tenancy strategy examples are in separate branches.

Database per tenant

The database branch implements the Database per tenant strategy.

Schema per tenant

The schema branch implements the Schema per tenant strategy.

Shared Database with Discriminator, using Hibernate Filters

The shared_database_hibernate branch implements the Shared Database with Discriminator strategy, using Hibernate's experimental support for discriminator-based multi-tenancy (see e.g. https://hibernate.atlassian.net/browse/HHH-6054)

Shared Database with Discriminator, using PostgreSQL's Row Level Security

The shared_database_postgres_rls branch implements the Shared Database with Discriminator strategy, using PostgreSQL's Row Level Security.

How to start a Dockerized postgres database

All the examples require a postgres database running at localhost:5432. Run the following command to use the provided docker-compose.yml configuration to start a dockerized postgres container:

docker-compose up -d

Close it down with the following command when done, or if you need to recreate the database:

docker-compose down

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.