Search code examples
liferay-6

Generating id for tables in liferay?


For some reasons, I have to build a rating module my own. I use RatingsEntryLocalServiceUtil to insert new rating from user.

The method RatingsEntryLocalServiceUtil.createRatingsEntry(long entryId) receive a long number as an Id. I want to know are there some built-in ways to get the Id for new ratingsentry or I have to create my own Id?

I use liferay 6.1


Solution

  • Yes You can use CounterLocalServiceUtil.increment(RatingsEntry.class)

    CounterLocalServiceUtil.java is utility class for generating ids for models.

    Regards