Message Boards

Service Builder relating two custom entities

marvin ros, modified 4 Years ago.

Service Builder relating two custom entities

Junior Member Posts: 35 Join Date: 5/9/19 Recent Posts
Hello together,

well I looked for a solution for a while now but I can not find one.I have two completely different custom service Builder modules and I want to use a entity relation between them. 

I have tried to use the mapping-table attribute and the reference attribute:

<column name="locations" type="Collection" entity="my.custom.second.portlet.model.Location" mapping-table="JobOffer_Location" />
<reference package-path="my.custom.second.portlet" entity="Location" />
when I run build service I am getting this error:

Caused by: java.io.IOException: Unable to open resource my/custom/second/portlet/model/service.xml in class loader  sun.misc.Launcher$AppClassLoader@70dea4e

So I dont want to put them in one service Builder module to keep it as modular as possible because the Location service Builder module is needed from a bunch of other portlets as well.

So my question is:

How do I relate a custom Entity to another custom Entity in different service.xml files? Is this even possible?

Thank you in advance!
thumbnail
Victor Manea, modified 3 Years ago.

RE: Service Builder relating two custom entities

New Member Posts: 11 Join Date: 10/23/20 Recent Posts

Hi, did you find a solution to this ? I have the same situation.

thumbnail
Christoph Rabel, modified 3 Years ago.

RE: Service Builder relating two custom entities

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts

I am not really a service builder expert, so the only idea I have here is to just store the id of the location and add a getLocation() method to the ModelImpl and fetching them from there, e.g. something like:

public Location getLocation() {

  return locationLocalService.getLocation(this.locationId);

}