Skip to Content
0

Multitenancy with SAP HANA Multitenant Database Containers (MDC)

Apr 26 at 05:50 AM

155

avatar image

Hi Experts,

I would like to develop a multitenant java app based on MDC.

Each tenant should get it's own TenantDB in MDC.

I have found some tutorials how the provide a schema-based solution (1 schema per tenant in one DB using Hibernate/JPA).
But how is it working with HANA TenantDB's?

Best regards
Oliver

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Ivan Mirisola
Apr 26 at 04:36 PM
0

Hi Oliver,

Have you seen this blog already on multi tenancy development on SCP?

Regards,
Ivan

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Ivan,

Yes I know this blog :-) It's very good, however it describes just the possibility of "Tenant Discriminator Column" in more detail.
However I would like to use the TenantDB-Functionality of MDC.
Any ideas how to work with TenantDB's?
I guess I have to work with several datasources / or I have to create the connection dynamically based on tenant-info. But I couldn't find any sample for this scenario.

Best regards
Oliver

0

Hi Oliver,

In that case you should consider the usage of provider account and subscriber account - that assuming we are on a Neo environment. Since data binding can have different configuration on each account, it would be possible to run you application connected to different database tenants, depending on the context it is running.

You deploy your app on the provider account and subscribe to it on the subscriber account. The provider will have a data base binding pointing to Tenant A whereas the subscriber will have it pointing to Tenant B of the same database.

This way you get to keep the same version deployed on a single instance using a single compute unit, but you would be able to provide it to different organizations, without the hassle of dealing with it on the database itself. In addition to it, users from one account will not see users of other accounts subscribing to the same application - which is an awesome segregation.

Regards,

Ivan

0

Hello Ivan,

They way you are describing for Neo would be my preferred solution.
However, what confuses me, is that in the subscriber account, I can't find a configuration possibility in order to point the subscribed application to another database. If I click on the subscribed app, I can see "Destinations" and "Roles" to configure, but nothing about Datasource Binding (which I have available only at the provider account). Or is it something I have to do with CLI ?

Best regards

Oliver

subscribedapp.jpg (61.0 kB)
0

Hi Oliver,

Sorry, but the information I've sent before is not really correct. The binding is done in the context of the provider account. So you need to treat the Hana Tenant ID when you obtain a connection to the database. You are able to retrieve the sub-account name (scp's tenant) and map to a database tenant.

1) Use the account api to retrieve the subscriber ID:

2) Use switch case statement to map account Id to db tenant Id and build the connection string to the default database. Here you specify the databaseName parameter to identify to which db tenant the connection should go thru.

Regards,
Ivan

1