Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-73945

Service Builder generated code fails if many-to-many relationship is defined between entities that have no companyId-field


    • Story Points:


      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">
              <!--<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 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" />

      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.




            • Assignee:
              joyce.wang Joyce Wang
              Ilja.sidoroff Ilja Sidoroff
              Participants of an Issue:
              Recent user:
              Enterprise Release HU
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created:
                Days since last comment:
                1 year, 31 weeks, 3 days ago


                Version Package