App Component - using entities stored in app component database

Hi all,

Apologies if this has already been answered but I couldn’t quite see anything which directly answered my question.

I have 2 projects, A & B.

I would like to use B as an add-on module for A. (I am assuming that is what app-components are supposed to be used for.)

I would like the screens and classes to be carried over from B (as they currently are as an app-component) but I want to store the entities that are created from project B screens in database B. Is that possible? (Currently they get stored in database A by default)

Thank you for any clarification and help.




Yes, it is possible.

You have to make the following changes in project files. I have created sample projects as a proof-of-concept.

  1. In addon (“gps” project):
    make changes in app compoenent descriptor (app-component.xml).
    Comment out this export line:
    <module name="global" blocks="*">
        <artifact name="gps-global" appJar="true"/>

        <!--<property name="cuba.persistenceConfig" value="+com/company/gps/persistence.xml"/>-->
        <property name="cuba.metadataConfig" value="+com/company/gps/metadata.xml"/>
        <property name="cuba.viewsConfig" value="+com/company/gps/views.xml"/>

Because it is this line that forces project to put addon’s entities to main data store.

  1. Create “gps” addon database from gps add-on project.

  2. Install gps app-component (to local maven).

  3. In project A (“gis-with-gps” sample) - create new additional data store “gps” with the same name / URL as just created gps database.

  4. In project gis-with-gps - change additional datastore’s persistenceConfig application property in all modules (core, web, portal), adding addon’s persistence.xml:

cuba.persistenceConfig_gps = +com/company/gis/gps-persistence.xml com/company/gps/persistence.xml
  1. That’s it.
    Run main application, gps entities and screens are loaded and displayed.

  2. Limitations. (79.5 KB) (73.4 KB)

Thank you very much for your help Alex I shall give that a go.

Much appreciated,