Reputation: 1
I am setting up multi tenant in an application with N clients. There is certain information that is common to all instances (for example, the roles that a user may have in the app). I want that information not to be duplicated in each of the tenants.
I am following this example: https://github.com/wmeints/spring-multi-tenant-demo, but the settings are applied to all tables.
How can I filter a request to apply this setting or not, depending on which table it refers to?
Upvotes: 0
Views: 533
Reputation: 509
You can override isRoot in CurrentTenantIdentifierResolver.
@Override
public boolean isRoot(String tenantId) {
return "IDDQD".equals(tenantId);
}
Upvotes: 1
Reputation: 1182
Good question, I can imagine more people have this problem. It is possible to do this. You'll need to setup two data sources:
In addition to this you'll need to create two JPA configuration objects:
Baeldung has a great tutorial on how to set up multiple databases with JPA that should get you in ths right direction: https://www.baeldung.com/spring-data-jpa-multiple-databases.
Upvotes: 1