Application Component with different datastore

Hi, this is our scenario: we have the application A and the related tables and data are in the X database schema.
We want to include this application ( to reuse screen,view already developed and data in the X schema) as a component in the application B that has the related tables and data are in the Y database schema.
In the application B must we create a second datastore and remap the application A datamodels or are included in the component?
Why does the datamodels ao the A application are recreated in the schema Y?
Where are we wrong? Where can we find an example?

5 Likes

I suppose that both of your database schemas were created by CUBA as main data stores. So in the target application all your entities will also be in the main data store. Why do you want to separate them to different schemas? Are they physically in different databases?

Hi Konstantin ,
we want to separate them to different schemas because our application is really big and modular and we 'd like to separate tables of one application from the others. It is possibile if we create the second database schemas as addictional data stores?
Whats happens with cuba tables If we use the same schema? Has Each application its own management (user,profile,etc) with the same tables?

Hi Manuel,

Let me explain the existing rules and restrictions regarding app components and data stores, and then you will ask further questions taking into account these rules.

  • There is always one main data store and any number of additional. CUBA entities (User, Role, etc.) are always stored in main data store only.

  • Entities of main datastore from app component keep belonging to main datastore in the target application.

  • Entities from additiona datastore from app component belong to an additional datastore with the same name in the target application (if yuo define such datastore in the target app).

  • CUBA Studio generates update and init scripts only for main datastore. You have to provide conssistence between your data model and additional stores yourself.

Hi Konstantin,
i understand restrictions regarding app components and data stores, the problem is that if i use the same schema for application A (the component) and the application B (the target) i can’t separate the list of users granted for application A from list of user granted to application B, so if i create an user for application B this one can access to application A .
Furthermore items of search folder or application folder of application B are visible in the application A where are not defined.
I’m sorry for the trouble, but for us it is important to know how to move.
Manuel

I lost my question: exists a way to overcome these problems?

So, you have two apps: A and AB, working with the same database. They both have entities User, Role, etc. mapped to tables SEC_USER, SEC_ROLE, etc., so the both apps work with the same data. You can divide this data only if you set different databases as main datastores of the apps. At the same time, you can create additional datastores for your domain entities.

For example:

App A:
Main datastore: DB1
Additional datastore: DB2
All A entities use the DB2 datastore.

App B:
Main datastore: DB3
Additional datastore: DB2
All B entities use the DB2 datastore.

So system and security entities will be in separate databases and domain entities in the same one.