Beginner
Beginner

Reputation: 1030

Is it always necessary to have companyID and groupID in Liferay Service Builder?

I'm developing a liferay portlet. I use Service Builder. The question is that do I have to use companyID and groupID in my entity fields? What should I do if I don't want to have these fields? If I don't use them how can I use resourceLocalService.addResources() method?

Upvotes: 2

Views: 3001

Answers (2)

Rez
Rez

Reputation: 500

Notice that the DBA team didn’t specify these two foreign key fields in the tables, but you add them anyway. You do this because the DBAs didn’t know the internal workings of Liferay when they designed the table.

These fields are internal to Liferay and are used for context purposes in non-instanceable portlets. CompanyId corresponds to the portal instance to which the user has navigated, and groupId corresponds to the community or organization to which the user has navigated.

Because you’ll use these field values as parameters in all your queries, the portlet will have different data in different portals, communities, and organizations.

Upvotes: 1

rp.
rp.

Reputation: 3465

They are not required but they are convenient to have.

Liferay has many additional services available to you to use like permissions, users, document library. These services are almost always scoped to a portal instance, for example, Users are scoped to an instance which is tracked by companyId. Some are scoped to a group like document library.

So depending on what Liferay services you are planning to use and at what scope those services operate, it is convenient to have those values stored as well for easy lookup when you're calling those services you are using.

Upvotes: 6

Related Questions