protected void clearUniqueFindersCache(PortalPreferences portalPreferences) { FinderCacheUtil.removeResult( FINDER_PATH_FETCH_BY_O_O, new Object[] { Long.valueOf(portalPreferences.getOwnerId()), Integer.valueOf(portalPreferences.getOwnerType()) }); }
/** * Creates a new portal preferences with the primary key. Does not add the portal preferences to * the database. * * @param portalPreferencesId the primary key for the new portal preferences * @return the new portal preferences */ public PortalPreferences create(long portalPreferencesId) { PortalPreferences portalPreferences = new PortalPreferencesImpl(); portalPreferences.setNew(true); portalPreferences.setPrimaryKey(portalPreferencesId); return 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(); } } }
@Override public void clearCache(List<PortalPreferences> portalPreferenceses) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (PortalPreferences portalPreferences : portalPreferenceses) { EntityCacheUtil.removeResult( PortalPreferencesModelImpl.ENTITY_CACHE_ENABLED, PortalPreferencesImpl.class, portalPreferences.getPrimaryKey()); clearUniqueFindersCache(portalPreferences); } }
@Override protected PortalPreferences removeImpl(PortalPreferences portalPreferences) throws SystemException { portalPreferences = toUnwrappedModel(portalPreferences); Session session = null; try { session = openSession(); if (!session.contains(portalPreferences)) { portalPreferences = (PortalPreferences) session.get(PortalPreferencesImpl.class, portalPreferences.getPrimaryKeyObj()); } if (portalPreferences != null) { session.delete(portalPreferences); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (portalPreferences != null) { clearCache(portalPreferences); } return portalPreferences; }
/** * 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; } }
public int compareTo(PortalPreferences portalPreferences) { long primaryKey = portalPreferences.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
@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; } }
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; }
/** * Returns the portal preferences where ownerId = ? and ownerType = ? or returns <code> * null</code> if it could not be found, optionally using the finder cache. * * @param ownerId the owner ID * @param ownerType the owner type * @param retrieveFromCache whether to use the finder cache * @return the matching portal preferences, or <code>null</code> if a matching portal preferences * could not be found * @throws SystemException if a system exception occurred */ public PortalPreferences fetchByO_O(long ownerId, int ownerType, boolean retrieveFromCache) throws SystemException { Object[] finderArgs = new Object[] {ownerId, ownerType}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_O_O, finderArgs, this); } if (result instanceof PortalPreferences) { PortalPreferences portalPreferences = (PortalPreferences) result; if ((ownerId != portalPreferences.getOwnerId()) || (ownerType != portalPreferences.getOwnerType())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(3); query.append(_SQL_SELECT_PORTALPREFERENCES_WHERE); query.append(_FINDER_COLUMN_O_O_OWNERID_2); query.append(_FINDER_COLUMN_O_O_OWNERTYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(ownerId); qPos.add(ownerType); List<PortalPreferences> list = q.list(); result = list; PortalPreferences portalPreferences = null; if (list.isEmpty()) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O, finderArgs, list); } else { portalPreferences = list.get(0); cacheResult(portalPreferences); if ((portalPreferences.getOwnerId() != ownerId) || (portalPreferences.getOwnerType() != ownerType)) { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_O_O, finderArgs, portalPreferences); } } return portalPreferences; } catch (Exception e) { throw processException(e); } finally { if (result == null) { FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_O_O, finderArgs); } closeSession(session); } } else { if (result instanceof List<?>) { return null; } else { return (PortalPreferences) result; } } }
@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; }