Forums de discussion

How to get Next Primary Key

thumbnail
N. Belo, modifié il y a 12 années.

How to get Next Primary Key

Junior Member Publications: 33 Date d'inscription: 17/03/09 Publications récentes
Hi,

I have developed a couple of portlets and I still haven't found a good method to get the Next Primary Key value of a database table created by me.
I've tried to use CounterLocalServiceUtil methods, but:

CounterLocalServiceUtil.increment(myClass.class.getName()) seems to work fine but I am trying to reset the value in a method in MyLocalServiceUtilimpl with CounterLocalServiceUtil.reset(myClass.class.getName(), valueFound ) and that doesn't seem to reset the value properly

... And I would like to reset this Primary Key each time I deploy the portlet.

Any help here? Best practice advice?

Thanks in advance,
NBelo