java - Spring Data MongoDB: how to implement multi-tenancy in CrudRepository -
this question has answer here:
- making spring-data-mongodb multi-tenant 2 answers
i designed db support multi-tenancy: every document has reference tenant
.
i'm using spring data mongodb implement data access logic , need handle document retrieval tenant in repositories.
is there common approach implement it? need override every method of crudrepository
match documents tenant or there facilities achieve this?
i decided implement multi-tenancy @ service layer suggested markus w mahlberg in comment.
at repository level created findbytenantidandid
query check if entity/document id
belongs proper tenant.
i have custom implementation of userdetails
interface, storing tenantid
logged user. retrieve logged user @ service layer via securitycontextholder
.
Comments
Post a Comment