Reports with multi-tenant sollution

Hi!

We are using Cuba platform for developing our application. We decided that we are going to seperate the tenants into more databases. We used your recommendation to do so:

We are using the Reporting as well, but we would like to allow the clients to make reports based on their tenant database only.

Right now after implemented your sollution, the data is seperated and is coming from a different database, but we are only able to make reports based on the main db, even if we are logged in with a user associated with another user group (different tenant db).

Could you recommend us a sollution that the reporting tool would use the tenant’s own db as well?

Looking forward to your answer!

Thanks,
Attila

Hi Attila,
It is a known limitation for the db-per-tenant approach (and not the only one). Read what Michael Renaud said in this topic: Choose database on login or change schema dynamically
Also it might be useful to vote here: SaaS application : true database-per-tenant approach

Hi Attila,
Do you want the same set of reports for all tenants, but running on tenant databases depending on the user which starts them?

Yes I would like that.

Hi!

I have another question:

it says:

If you use entities with Long or Integer keys (subclasses of BaseLongIdEntity or BaseIntegerIdEntity), sequences for the generation of keys will be created in the main database. It means that the key values will be sequential across all databases

But if we do every step from the development apporach on github the sequences are still not used.

we get: ERROR: null value in column “id” violates not-null constraint.

Could you help us?

Thanks,
Attila

Attila,

Regrading using reports. Indeed, you can create only one set of reports for all tenants because report definitions are stored in the main database which is shared between tenants. However, when users run these reports, data will be loaded from tenants’ databases, i.e. each user will run a report against its tenant data. I hope this is what you need.

About using BaseLongIdEntity and BaseIntegerIdEntity. The README on GitHub is not correct in this part, there is an issue in platform 6.7 and earlier that integer identifiers are not generated for entities in additional datastores at all: https://youtrack.cuba-platform.com/issue/PL-7960. It is fixed in the upcoming version 6.8, see http://files.cuba-platform.com/cuba/release-notes/6.8/#id_sequences

1 Like

Hi!
Can I have another question?

We are using the database per tenant approach, and we are facing some difficulties: after connected to another datastore I can save an entity, but then the display screen is not refreshing. When we did it with one db it went smoothly. So we have a list and a create button. I create another element, then it should be added to the list. I create the new element, the item is saved to the db, but the list is not refreshing. After I close the window and open it again it displays the new item.

Do you have any advice on this?

Thanks,
Attila

In fact, when creating a new item, the item is added to the browser datasource right from the editor screen after closing it without any additional roundtrip to the database. So your problem is hardly related to the database access, and I couldn’t reproduce it.

You can find out what’s going on if you debug the com.haulmont.cuba.gui.components.actions.CreateAction#internalOpenEditor method.