deletePrefNamesPstmt.executeUpdate();
//Loop through the prefs, inserting each name then the values
for (Iterator prefItr = prefs.iterator(); prefItr.hasNext();) {
final Preference pref = (Preference)prefItr.next();
int prefId = -1;
insertPrefNamePstmt.setInt(1, chanId);
insertPrefNamePstmt.setString(2, pref.getName());
if (pref.isReadOnly()) {
insertPrefNamePstmt.setString(3, READ_ONLY_TRUE);
} else {
insertPrefNamePstmt.setString(3, READ_ONLY_FALSE);
}
//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();
prefId = counterStore.getIncrementIntegerId(UP_PORTLET_PREFERENCE_VALUE);
}
insertPrefNamePstmt.setInt(4, prefId);
//Insert the name row
if (log.isDebugEnabled())
log.debug("RDBMPortletPreferencesStore::setDefinitionPreferences(): " + insertPrefName);
insertPrefNamePstmt.executeUpdate();
//For each value a row will be inserted in the values table
for (final Iterator valueItr = pref.getValues(); valueItr.hasNext();) {
String value = (String)valueItr.next();
if (log.isDebugEnabled())
log.debug("RDBMPortletPreferencesStore::setDefinitionPreferences(): " + insertPrefValue);
insertPrefValuePstmt.setInt(1, prefId);