DISCRIMINATOR based Multi-Tenancy with Spring Data JPA+Hibernate
Asked Answered
T

1

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?
Translative answered 5/3, 2014 at 14:3 Comment(3)
Must you use Hibernate 3? 5.x is current.Piazza
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.xMember
Hibernate does not support discriminator multi-tenancy. It does support schema or connection based tenancy though: docs.jboss.org/hibernate/core/4.2/devguide/en-US/html/ch16.htmlCalque
H
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

Hume answered 29/8, 2017 at 9:48 Comment(3)
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? Part II: Solutioning Part III: Implementation & Supporting InfrastructureArcanum
Thanks @Arcanum I initially tried with that example only but i am not sure now its broken. Anyway thanks for the another links.Hume
This GitHub repository contains a great example of how to implement discriminator-based multitenancy in Spring Boot by using Hibernate filters: github.com/M-Devloo/….Postfix

© 2022 - 2024 — McMap. All rights reserved.