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?
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.
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 CUBA Platform and Studio Release Notes
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.
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.