//Use the list of removed ids to re-use IDs before generating new ones
if (prefIds.size() > 0) {
prefId = ((Integer)prefIds.removeLast()).intValue();
}
else {
final ICounterStore counterStore = CounterStoreFactory.getCounterStoreImpl();
try {
prefId = counterStore.getIncrementIntegerId(UP_PORTLET_PREFERENCE_VALUE);
}
catch (Exception e) {
counterStore.createCounter(UP_PORTLET_PREFERENCE_VALUE);
prefId = counterStore.getIncrementIntegerId(UP_PORTLET_PREFERENCE_VALUE);
}
}
insertPrefNamePstmt.setInt(5, prefId);