Foros de discusión

Counter Service for auto increment

thumbnail
Nirav Prajapati, modificado hace 6 años.

Counter Service for auto increment

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
Hello Friends,

I am using liferay 6.2 CE-GA6 with service builder.

For ID Auto-increment i am using long id = CounterLocalServiceUtil.increment(MyClass.class.getName());

But here Counter is start from 1.

I want to set counter start from 10000000 to 19999999 on portlet level not portal.

Means counter Start from 10000000 and it will Stop on 19999999.

Please help me to fix it.
thumbnail
Jorge Díaz, modificado hace 6 años.

RE: Counter Service for auto increment (Respuesta)

Liferay Master Mensajes: 753 Fecha de incorporación: 9/01/14 Mensajes recientes
You can change the start value to 10000000 but it is not possible to set up a stop value.

In order to get values starting from 10000000, you have to update your counter MyClass.class.getName().
The counter is stored in counter_ table, but don't directly update it, use Liferay API instead.

You have to call:

You can execute that code from a custom portlet or from groovy script console
thumbnail
Nirav Prajapati, modificado hace 6 años.

RE: Counter Service for auto increment

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
Thank You