9

I want to implement DISCRIMINATOR based Multi-Tenancy solution for Shared Schema Based Multi-Tenancy Model-common database schema for all tenants.

Technology stack

  • Hibernate 3 Global filter (I can't use EclipseLink)
  • Spring Data JPA - I want this because we are already using this one and we cant change it.

My questions are

  • How to achieve this : Spring Data JPA has no any support for GLOBAL filter so I need to add customize Spring Data JPA repository which can in-turn apply global filter for DISCRIMINATOR based solution?
  • At all, Is it possible to implement my requirement with Spring Data JPA+Hibernate 3?
halfer
  • 19,824
  • 17
  • 99
  • 186
Ketan
  • 2,612
  • 5
  • 31
  • 44
  • Must you use Hibernate 3? 5.x is current. – sofend Jan 26 '17 at 00:07
  • What I can definitely tell you is, that Hibernate still have no support for discriminator based multi-tenancy. We had the same issue in our project and we're on hibernate 5.x – Ansgar Schulte Mar 07 '17 at 19:18
  • Hibernate does not support discriminator multi-tenancy. It does support schema or connection based tenancy though: https://docs.jboss.org/hibernate/core/4.2/devguide/en-US/html/ch16.html – Jan-Willem Gmelig Meyling Jun 06 '17 at 17:57

1 Answers1

2

Using hibernate filters you can achieve below items in our application,

  1. Multi-tenancy,
  2. Authorisation
  3. Authentication
  4. Row level authorisation

In our application we applied this and got great results and applied the same stuff to other web based products as well. For your reference go through the below link and you will get some idea on the above stuffs. http://www.jroller.com/RickHigh/entry/using_spring_aop_and_hibernate

Hakuna Matata
  • 755
  • 3
  • 13
  • 4
    The link is dead, but there is another set of blog posts which goes into detail on this called **Elegant Multi-Tenancy for Microservices**: [Part I: Why Bother?](https://medium.com/@Integral_io/elegant-multi-tenancy-for-microservices-part-i-why-bother-a88234f9d293) [Part II: Solutioning](https://medium.com/@Integral_io/elegant-multi-tenancy-for-microservices-part-ii-solutioning-d0d9b6cd6f0f) [Part III: Implementation & Supporting Infrastructure](https://medium.com/@Integral_io/elegant-multi-tenancy-for-microservices-part-iii-implementation-supporting-infrastructure-64b74093615) – n_l Sep 17 '18 at 13:46
  • Thanks @n_l I initially tried with that example only but i am not sure now its broken. Anyway thanks for the another links. – Hakuna Matata Oct 01 '18 at 05:46
  • This GitHub repository contains a great example of how to implement discriminator-based multitenancy in Spring Boot by using Hibernate filters: https://github.com/M-Devloo/Spring-boot-auth0-discriminator-multitenancy. – Terskel Mar 18 '22 at 12:04