-
Type:
Bug
-
Status: Closed
-
Resolution: Won't Fix
-
Affects Version/s: 7.0.0 DXP SP4
-
Fix Version/s: None
-
Component/s: Core Infrastructure > Service Builder
-
Labels:
-
Story Points:5
Observed behaviour:
When creating a service builder -module (eg. with blade create -t service-builder many-to-many-bug) and creating a many-to-many mapping between to entities, eg:
<?xml version="1.0"?> <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd"> <service-builder package-path="many.to.many.bug"> <namespace>FOO</namespace> <!--<entity data-source="sampleDataSource" local-service="true" name="Foo" remote-service="false" session-factory="sampleSessionFactory" table="foo" tx-manager="sampleTransactionManager uuid="true"">--> <entity local-service="true" name="Foo" remote-service="true" uuid="true"> <column name="fooId" primary="true" type="long" /> <column name="barId" type="Collection" entity="Bar" mapping-table="Foo_Bar" /> </entity> <entity local-service="true" name="Bar" remote-service-true="true" uuid="true"> <column name="barId" primary="true" type="long" /> <column name="fooId" type="Collection" entity="Foo" mapping-table="Foo_Bar" /> </entity> </service-builder>
and running service builder (eg. blade gw buildService && blade gw build), one gets errors like:
modules/many-to-many-bug/many-to-many-bug-service/src/main/java/many/to/many/bug/service/persistence/impl/BarPersistenceImpl.java:1406: error: cannot find symbol barToFooTableMapper.addTableMapping(bar.getCompanyId(), pk, ^ symbol: method getCompanyId() location: variable bar of type Bar
(There are multiple similar errors).
The errors can be fixed by including companyId-field to the both entities:
<column name="companyId" type="long" />
The reason for this seems to be that this commit introduced a addTableMapping-functions that require companyId parameter: https://github.com/liferay/liferay-portal/commit/200695f4b31642c3453f5e26b3340430be6fe4e3 - I'm not very familiar with the Liferay-source code, so I'm not sure if this was done differently before. In any case, I'm porting a pre DXP/7 Liferay-application to DXP and have service.xml-file, which used to work at some point in history.
Expected behaviour:
generated source files should compile ok even if they don't have companyId-field but many-to-many-mappings. Or the current documentation is updated to indicate the actual behaviour.