Application component with separate database

One of my app “A” is like knowledge base, where all data input will be from our side. This app “A” will be used in many of other applications B/C/D just for readonly view.

If we use application “A” as application component all data will be entered again in B/C/D.

We want to host “A” separately with all data to be entered by us in it. Same database should be used in all other app B/C/D, so as we don’t have to maintain separate database for same data.

How can we achieve this?

thanks

Hi,
Similar requirements have been discussed on the forum previously:

1 Like

Also this one: How to change datastore(main to additional) of an addon entity - CUBA.Platform

Thanks, I will check.

This is not working.

I have one app sheellegal, whivc will be used in sheelonline as as addon. I used following steps as mentioned in above mentioned forum-

  1. Generated app component description for sheellegal.
  2. Commented line in descriptor.

> <!-- <property name="cuba.persistenceConfig" value="+com/sheel/sheellegal/persistence.xml"/>-->
3. Defined additional datastore in sheelonline with sheellegal name and connection parameters.
4. edited following line in core and web module app properties.

cuba.persistenceConfig_sheellegal=+com/sheel/sheelonline/sheellegal-persistence.xml com/sheel/sheellegal/persistence.xml

When I run the sheelonline, it ask for updating database and create all sheellegal database in sheelonline dtabase.

When I run the application it gives following error.

om.haulmont.cuba.web.sys.remoting.LocalServiceAccessException: Unable to connect to middleware. Middleware block ‘sheelonline-core’ failed to start. See exception cause for details.
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.createServiceAccessException(LocalServiceProxy.java:193)
at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:108)
at com.sun.proxy.$Proxy30.healthCheck(Unknown Source)
at com.haulmont.cuba.web.AppUI.init(AppUI.java:342)
at com.vaadin.ui.UI.doInit(UI.java:738)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:209)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:67)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory_sheellegal’ defined in class path resource [com/sheel/sheelonline/spring.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [SheelLegal] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.sheel.sheellegal.entity.MasterDocument] uses a non-entity [class com.haulmont.cuba.core.entity.FileDescriptor] as target entity in the relationship attribute [field file].
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.afterPropertiesSet(AbstractRefreshableConfigApplicationContext.java:154)
at com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext.(CubaClassPathXmlApplicationContext.java:42)
at com.haulmont.cuba.core.sys.CubaCoreApplicationContext.(CubaCoreApplicationContext.java:32)
at com.haulmont.cuba.core.sys.AppContextLoader.createApplicationContext(AppContextLoader.java:125)
at com.haulmont.cuba.core.sys.AppContextLoader.createApplicationContext(AppContextLoader.java:43)
at com.haulmont.cuba.core.sys.AbstractAppContextLoader.initAppContext(AbstractAppContextLoader.java:65)
at com.haulmont.cuba.core.sys.AbstractWebAppContextLoader.contextInitialized(AbstractWebAppContextLoader.java:86)
at com.haulmont.cuba.core.sys.AppContextLoader.contextInitialized(AppContextLoader.java:52)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4685)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5146)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1133)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1867)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1045)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1576)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:633)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [SheelLegal] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.sheel.sheellegal.entity.MasterDocument] uses a non-entity [class com.haulmont.cuba.core.entity.FileDescriptor] as target entity in the relationship attribute [field file].
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:2104)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2080)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactoryImpl(PersistenceProvider.java:350)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:316)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:391)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:378)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
… 58 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [SheelLegal] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.sheel.sheellegal.entity.MasterDocument] uses a non-entity [class com.haulmont.cuba.core.entity.FileDescriptor] as target entity in the relationship attribute [field file].
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:233)
… 68 more
Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class com.sheel.sheellegal.entity.MasterDocument] uses a non-entity [class com.haulmont.cuba.core.entity.FileDescriptor] as target entity in the relationship attribute [field file].
at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1383)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:569)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processForeignKeyRelationship(ObjectAccessor.java:678)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:752)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:130)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1666)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1919)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:584)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:629)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2001)
… 66 more

Is some other steps to be followed?

PS : app sheellegal runs perfectly separately. This is where error is reported (nothing changed by me)

 <bean id="entityManagerFactory_sheellegal"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" lazy-init="false">
        <property name="persistenceXmlLocation" value="file:${cuba.dataDir}/sheellegal-persistence.xml"/>
        <property name="dataSource" ref="cubaDataSource_sheellegal"/>
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
    </bean>

regards

umesh

Hi,

You are referencing from your entity MasterDocument which lives in additional data store - entity FileDescriptor which lives in main data store.
It is not possible “out of the box”, these entities live in different databases.

However with some coding you can implement cross-datastore references in your code, so that MasterDocument can reference FileDescriptor (stored in another database) with a transient link. Look at the documentation how to code it: Data Stores - CUBA Platform. Developer’s Manual

I will go through it. However, why tables of sheellegal are being generated in the main database. They should not be in both databases.

Secondly in case file descriptor will be only in main datastore then sheellegal can’t be used as separate app at all. (I have to remove MasterDocument entity from there).

for guidance please.

The FileDescriptor entity may be only in main data store (CUBA doesn’t support one entity to be located in two data stores).
So you won’t be able to directly reference FileDescriptor from entities of your additional data store.

But by following the process, as detailed in first post. sheellegal tables are being created in sheeonline database also. This should not be the case.

Capture2

These tables starting with sheellegal should only be in additional datastore i.e. sheellegal but are being created in sheelonline database also (see pic above from sheelonline database).

Am I missing some step?

If I follow these instruction and import “A” addon in “B”. It work perfectly, but

  1. All tables of “A” is created in “B” database.
  2. If I add any entity in “B” with association with “A”, running project gives error.

I made bookmark entity having association with masterlegaltext in addon. This is the error-

> com.haulmont.cuba.web.sys.remoting.LocalServiceAccessException: Unable to connect to middleware. Middleware block 'sheelonline-core' failed to start. See exception cause for details.
> 	at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.createServiceAccessException(LocalServiceProxy.java:193)
> 	at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:108)
> 	at com.sun.proxy.$Proxy30.healthCheck(Unknown Source)
> 	at com.haulmont.cuba.web.AppUI.init(AppUI.java:342)
> 	at com.vaadin.ui.UI.doInit(UI.java:738)
> 	at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:209)
> 	at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:67)
> 	at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
> 	at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
> 	at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
> 	at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
> 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> 	at java.lang.Thread.run(Thread.java:748)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [com/haulmont/cuba/spring.xml]: Cannot resolve reference to bean 'cuba_BeanValidation' while setting bean property 'beanValidation'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_BeanValidation': Unsatisfied dependency expressed through field 'messages'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Messages': Unsatisfied dependency expressed through field 'messageTools'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_MessageTools': Unsatisfied dependency expressed through field 'metadata'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Metadata': Unsatisfied dependency expressed through field 'tools'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_MetadataTools': Unsatisfied dependency expressed through field 'dynamicAttributesTools'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_DynamicAttributesTools': Unsatisfied dependency expressed through field 'dynamicAttributes'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_DynamicAttributesService': Unsatisfied dependency expressed through field 'dynamicAttributesManagerAPI'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_DynamicAttributesManager': Unsatisfied dependency expressed through field 'persistence'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Persistence': Unsatisfied dependency expressed through field 'transactions'; nested exception is 
> Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.EntityManagerSetupException
> Exception Description: Predeployment of PersistenceUnit [sheelonline] failed.
> Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
> Exception Description: [class com.company.sheelonline.entity.Bookmark] uses a non-entity [class com.sheel.sheellegal.entity.MasterLegalText] as target entity in the relationship attribute [field legalText].
> 	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:233)
> 	... 228 more
> Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.7.3.7-cuba): org.eclipse.persistence.exceptions.ValidationException
> Exception Description: [class com.company.sheelonline.entity.Bookmark] uses a non-entity [class com.sheel.sheellegal.entity.MasterLegalText] as target entity in the relationship attribute [field legalText].
> 	at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1383)
> 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:569)
> 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processForeignKeyRelationship(ObjectAccessor.java:678)
> 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:752)
> 	at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:130)
> 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1666)
> 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1919)
> 	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:584)
> 	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:629)
> 	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2001)
> 	... 226 more

Please advise

Hi,

Yes, tables for add-ons entities are also created in the main datastore, because add-on exports database scripts like they are for main datastore.

We can add small change to build.gradle and delete these unnecessary scripts:

1 - open file manager, check sub-folders of the modules/core/build/db folder, to find name of the folder with add-on’s db scripts. In my sample project add-on was named “prods”, and folder name is “50-prods”.

2 - add a change to the build.gradle to delete unnecessary scripts:

configure(coreModule) {
...
    assembleDbScripts {
        doLast {
            def addonDbScriptsDir = "${project.buildDir}/db/50-prods"
            new File("$addonDbScriptsDir/init").deleteDir()
            new File("$addonDbScriptsDir/update").deleteDir()
        }
    }

}

assembleDbScripts is the task that gathers all DB scripts from CUBA, addons and project just before createDb, updateDb tasks and before project deployment.

Note that DB scripts for addon’s tables will be re-generated from scratch in the project using the add-on (named 01.prods-create-db.sql, 02.prods-create-db.sql in my case).