alesevilla92
alesevilla92

Reputation: 1

Ignore multi tenant for specifics tables

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

Answers (2)

pasquale
pasquale

Reputation: 509

You can override isRoot in CurrentTenantIdentifierResolver.

@Override
public boolean isRoot(String tenantId) {
    return "IDDQD".equals(tenantId);
}

Upvotes: 1

Willem Meints
Willem Meints

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:

  • A data source that is multi-tenant, as in my example.
  • A second data "regular" data source.

In addition to this you'll need to create two JPA configuration objects:

  • One that uses the multi-tenant data source
  • A second JPA configuration that uses the regular data source.

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

Related Questions