Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making spring-data-mongodb multi-tenant

In a post last august sbzoom proposed a solution to make spring-data-mongoDB multi-tenant:

"You have to make your own RepositoryFactoryBean. Here is the example from the Spring Data MongoDB Reference Docs. You would still have to implement your own MongoTemplate and delay or remove the ensureIndexes() call. But you would have to rewrite a few classes to make sure your MongoTemplate is called instead of Spring's."

Did anybody implement this or something equivalent?

like image 414
nicolasvdb Avatar asked May 01 '13 20:05

nicolasvdb


People also ask

How do I create a multi-tenant database in MongoDB?

Create a Node app initialize one MongoDB connection along with the app and export this connection object. create this connection using mongoose createConnection as the createConnection method does not create default connection but return a DB connection object.

How do I create a multi-tenant application in spring boot?

There are three approaches on how to build a multi-tenant application: Database per tenant — each tenant has its database. Shared database, separate schema — all tenants are using the same database, but each tenant has his schema. Shared database, shared schema — all tenants are using the same schema.

Can I use Spring data JPA with MongoDB?

Yes, DataNucleus JPA allows it, as well as to many other databases.


1 Answers

Full featured multi-tenant/tenancy with Spring Boot + MongoDB + Spring MVC with shared/global database configuration.

https://github.com/arun2pratap/multitenant-spring-mongodb

enter image description here

like image 174
Arun Pratap Singh Avatar answered Oct 24 '22 11:10

Arun Pratap Singh