public int compareTo(PortalPreferences portalPreferences) { long primaryKey = portalPreferences.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
/** * Clears the cache for the portal preferences. * * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method. */ @Override public void clearCache(PortalPreferences portalPreferences) { EntityCacheUtil.removeResult( PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED, PortalPreferencesImpl.class, portalPreferences.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache(portalPreferences); }
/** * Caches the portal preferenceses in the entity cache if it is enabled. * * @param portalPreferenceses the portal preferenceses */ public void cacheResult(List<PortalPreferences> portalPreferenceses) { for (PortalPreferences portalPreferences : portalPreferenceses) { if (EntityCacheUtil.getResult( PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED, PortalPreferencesImpl.class, portalPreferences.getPrimaryKey()) == null) { cacheResult(portalPreferences); } else { portalPreferences.resetOriginalValues(); } } }
protected PortalPreferences toUnwrappedModel(PortalPreferences portalPreferences) { if (portalPreferences instanceof PortalPreferencesImpl) { return portalPreferences; } PortalPreferencesImpl portalPreferencesImpl = new PortalPreferencesImpl(); portalPreferencesImpl.setNew(portalPreferences.isNew()); portalPreferencesImpl.setPrimaryKey(portalPreferences.getPrimaryKey()); portalPreferencesImpl.setPortalPreferencesId(portalPreferences.getPortalPreferencesId()); portalPreferencesImpl.setOwnerId(portalPreferences.getOwnerId()); portalPreferencesImpl.setOwnerType(portalPreferences.getOwnerType()); portalPreferencesImpl.setPreferences(portalPreferences.getPreferences()); return portalPreferencesImpl; }
/** * Caches the portal preferences in the entity cache if it is enabled. * * @param portalPreferences the portal preferences */ public void cacheResult(PortalPreferences portalPreferences) { EntityCacheUtil.putResult( PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED, PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(), portalPreferences); FinderCacheUtil.putResult( FINDER_PATH_FETCH_BY_O_O, new Object[] { Long.valueOf(portalPreferences.getOwnerId()), Integer.valueOf(portalPreferences.getOwnerType()) }, portalPreferences); portalPreferences.resetOriginalValues(); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PortalPreferences)) { return false; } PortalPreferences portalPreferences = (PortalPreferences) obj; long primaryKey = portalPreferences.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } PortalPreferences portalPreferences = null; try { portalPreferences = (PortalPreferences) obj; } catch (ClassCastException cce) { return false; } long primaryKey = portalPreferences.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
@Override public PortalPreferences updateImpl(com.liferay.portal.model.PortalPreferences portalPreferences) throws SystemException { portalPreferences = toUnwrappedModel(portalPreferences); boolean isNew = portalPreferences.isNew(); PortalPreferencesModelImpl portalPreferencesModelImpl = (PortalPreferencesModelImpl) portalPreferences; Session session = null; try { session = openSession(); if (portalPreferences.isNew()) { session.save(portalPreferences); portalPreferences.setNew(false); } else { session.merge(portalPreferences); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !PortalPreferencesModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } EntityCacheUtil.putResult( PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED, PortalPreferencesImpl.class, portalPreferences.getPrimaryKey(), portalPreferences); if (isNew) { FinderCacheUtil.putResult( FINDER_PATH_FETCH_BY_O_O, new Object[] { Long.valueOf(portalPreferences.getOwnerId()), Integer.valueOf(portalPreferences.getOwnerType()) }, portalPreferences); } else { if ((portalPreferencesModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_O_O.getColumnBitmask()) != 0) { Object[] args = new Object[] { Long.valueOf(portalPreferencesModelImpl.getOriginalOwnerId()), Integer.valueOf(portalPreferencesModelImpl.getOriginalOwnerType()) }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_O_O, args); FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O, args); FinderCacheUtil.putResult( FINDER_PATH_FETCH_BY_O_O, new Object[] { Long.valueOf(portalPreferences.getOwnerId()), Integer.valueOf(portalPreferences.getOwnerType()) }, portalPreferences); } } return portalPreferences; }