Giter VIP home page Giter VIP logo

tenancy-sample's Introduction

Multi Tenancy Sample

A sample application to test Spring Data GOSLING with Hibernate 5 and discriminator column separation.

This sample application demonstrates how to setup a multitenancy application using the Discriminator column separation strategy on relational databases. Multitenancy is still not standardized in the Java Persistence API (current version JPA 2.1) but the common strategies are implemented by JPA providers like Hibernate or EclipseLink. Therefore we've split the sample into two particular samples, one for each provider.

Conclusion

After doing some research and implemented both solutions we come to the conclusion that both providers do not match our projects requirements. The implementation of the Discriminator strategy in Hibernate is still under development and not yet suitable - even it is described in the reference documentation. We had to patch the current version of Hibernate to get the resolution of the tenant id working. The implementation of EclipseLink's Discriminator strategy is much more ahead and works as documented, but has some restrictions that prevent us from using it together with the latest Spring Data JPA version. Details of our investigation can be found on the modules README pages (Hibernate, EclipseLink).

Technologies and frameworks used in common:

  • Java 8
  • Spring Boot 1.3
  • Spring Data GOSLING, including Spring Data JPA 1.9.0.RELEASE
  • H2 and PostgreSQL database

Introduction in Mutlitenancy

A brief overview on multitenancy and the three major strategies is described in the Hibernate.org User Guide. Separation on Database or Schema level is sufficient for most applications. Whereas separating data based on a Discriminator column value is the more exotic strategy. As often, it depends on your requirements on multitenany which strategy to use.

Sample App Requirements

The following requirements are taken from our Stamplets project and are applied to both sample applications.

R1: The system must separate persisted data based on tenant information (sent by the client). Some data (database tables) must be shared across all tenants, whereas other data is kept dedicated to the current identified tenant.

R1.1: Log files are separated based on the tenant identifier.

R2: The system must provide the functionality to create new accounts at runtime, this implies that the system must handle new tenants dynamically without the need of a restart or any manual interaction.

ORM Variations

Multitenancy is not yet sepecified by the JPA, yet we rely on provider specific features.

Hibernate

At first we tried to setup multitenancy data separation based on a discriminator column value with Hibernate. We started with reading, understanding and implementing the solution how it is described in the corresponding [chapter of the Hibernate.org User Guide] (http://docs.jboss.org/hibernate/orm/5.0/userGuide/en-US/html_single/#d5e3234 "Hibernate.org User Guide"). Further imformation can be found on the Hibernate Sample README page.

EclipseLink

Then we gave EclipseLink a try to find out how this feature is implemented there and what the current state of development is. The conclusion and how to configure EclipseLink is described here

tenancy-sample's People

Contributors

openwms avatar

Watchers

 avatar  avatar

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.