All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.portlet.announcements.service.persistence.impl.AnnouncementsFlagPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.portlet.announcements.service.persistence.impl;

import aQute.bnd.annotation.ProviderType;

import com.liferay.announcements.kernel.exception.NoSuchFlagException;
import com.liferay.announcements.kernel.model.AnnouncementsFlag;
import com.liferay.announcements.kernel.service.persistence.AnnouncementsFlagPersistence;
import com.liferay.portal.kernel.bean.BeanReference;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portlet.announcements.model.impl.AnnouncementsFlagImpl;
import com.liferay.portlet.announcements.model.impl.AnnouncementsFlagModelImpl;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The persistence implementation for the announcements flag service.
 *
 * 

* Caching information and settings can be found in portal.properties *

* * @author Brian Wing Shun Chan * @generated */ @ProviderType public class AnnouncementsFlagPersistenceImpl extends BasePersistenceImpl implements AnnouncementsFlagPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use AnnouncementsFlagUtil to access the announcements flag persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = AnnouncementsFlagImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathWithPaginationFindByEntryId; private FinderPath _finderPathWithoutPaginationFindByEntryId; private FinderPath _finderPathCountByEntryId; /** * Returns all the announcements flags where entryId = ?. * * @param entryId the entry ID * @return the matching announcements flags */ @Override public List findByEntryId(long entryId) { return findByEntryId( entryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the announcements flags where entryId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param entryId the entry ID * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @return the range of matching announcements flags */ @Override public List findByEntryId( long entryId, int start, int end) { return findByEntryId(entryId, start, end, null); } /** * Returns an ordered range of all the announcements flags where entryId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param entryId the entry ID * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching announcements flags */ @Override public List findByEntryId( long entryId, int start, int end, OrderByComparator orderByComparator) { return findByEntryId(entryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the announcements flags where entryId = ?. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param entryId the entry ID * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching announcements flags */ @Override public List findByEntryId( long entryId, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByEntryId; finderArgs = new Object[] {entryId}; } else { finderPath = _finderPathWithPaginationFindByEntryId; finderArgs = new Object[] {entryId, start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AnnouncementsFlag announcementsFlag : list) { if ((entryId != announcementsFlag.getEntryId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE); query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2); if (orderByComparator != null) { appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AnnouncementsFlagModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(entryId); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first announcements flag in the ordered set where entryId = ?. * * @param entryId the entry ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching announcements flag * @throws NoSuchFlagException if a matching announcements flag could not be found */ @Override public AnnouncementsFlag findByEntryId_First( long entryId, OrderByComparator orderByComparator) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = fetchByEntryId_First( entryId, orderByComparator); if (announcementsFlag != null) { return announcementsFlag; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("entryId="); msg.append(entryId); msg.append("}"); throw new NoSuchFlagException(msg.toString()); } /** * Returns the first announcements flag in the ordered set where entryId = ?. * * @param entryId the entry ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching announcements flag, or null if a matching announcements flag could not be found */ @Override public AnnouncementsFlag fetchByEntryId_First( long entryId, OrderByComparator orderByComparator) { List list = findByEntryId( entryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last announcements flag in the ordered set where entryId = ?. * * @param entryId the entry ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching announcements flag * @throws NoSuchFlagException if a matching announcements flag could not be found */ @Override public AnnouncementsFlag findByEntryId_Last( long entryId, OrderByComparator orderByComparator) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = fetchByEntryId_Last( entryId, orderByComparator); if (announcementsFlag != null) { return announcementsFlag; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("entryId="); msg.append(entryId); msg.append("}"); throw new NoSuchFlagException(msg.toString()); } /** * Returns the last announcements flag in the ordered set where entryId = ?. * * @param entryId the entry ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching announcements flag, or null if a matching announcements flag could not be found */ @Override public AnnouncementsFlag fetchByEntryId_Last( long entryId, OrderByComparator orderByComparator) { int count = countByEntryId(entryId); if (count == 0) { return null; } List list = findByEntryId( entryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the announcements flags before and after the current announcements flag in the ordered set where entryId = ?. * * @param flagId the primary key of the current announcements flag * @param entryId the entry ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next announcements flag * @throws NoSuchFlagException if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag[] findByEntryId_PrevAndNext( long flagId, long entryId, OrderByComparator orderByComparator) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = findByPrimaryKey(flagId); Session session = null; try { session = openSession(); AnnouncementsFlag[] array = new AnnouncementsFlagImpl[3]; array[0] = getByEntryId_PrevAndNext( session, announcementsFlag, entryId, orderByComparator, true); array[1] = announcementsFlag; array[2] = getByEntryId_PrevAndNext( session, announcementsFlag, entryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AnnouncementsFlag getByEntryId_PrevAndNext( Session session, AnnouncementsFlag announcementsFlag, long entryId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE); query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(AnnouncementsFlagModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(entryId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( announcementsFlag)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the announcements flags where entryId = ? from the database. * * @param entryId the entry ID */ @Override public void removeByEntryId(long entryId) { for (AnnouncementsFlag announcementsFlag : findByEntryId( entryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(announcementsFlag); } } /** * Returns the number of announcements flags where entryId = ?. * * @param entryId the entry ID * @return the number of matching announcements flags */ @Override public int countByEntryId(long entryId) { FinderPath finderPath = _finderPathCountByEntryId; Object[] finderArgs = new Object[] {entryId}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ANNOUNCEMENTSFLAG_WHERE); query.append(_FINDER_COLUMN_ENTRYID_ENTRYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(entryId); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_ENTRYID_ENTRYID_2 = "announcementsFlag.entryId = ?"; private FinderPath _finderPathFetchByU_E_V; private FinderPath _finderPathCountByU_E_V; /** * Returns the announcements flag where userId = ? and entryId = ? and value = ? or throws a NoSuchFlagException if it could not be found. * * @param userId the user ID * @param entryId the entry ID * @param value the value * @return the matching announcements flag * @throws NoSuchFlagException if a matching announcements flag could not be found */ @Override public AnnouncementsFlag findByU_E_V(long userId, long entryId, int value) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = fetchByU_E_V( userId, entryId, value); if (announcementsFlag == null) { StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId="); msg.append(userId); msg.append(", entryId="); msg.append(entryId); msg.append(", value="); msg.append(value); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchFlagException(msg.toString()); } return announcementsFlag; } /** * Returns the announcements flag where userId = ? and entryId = ? and value = ? or returns null if it could not be found. Uses the finder cache. * * @param userId the user ID * @param entryId the entry ID * @param value the value * @return the matching announcements flag, or null if a matching announcements flag could not be found */ @Override public AnnouncementsFlag fetchByU_E_V( long userId, long entryId, int value) { return fetchByU_E_V(userId, entryId, value, true); } /** * Returns the announcements flag where userId = ? and entryId = ? and value = ? or returns null if it could not be found, optionally using the finder cache. * * @param userId the user ID * @param entryId the entry ID * @param value the value * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching announcements flag, or null if a matching announcements flag could not be found */ @Override public AnnouncementsFlag fetchByU_E_V( long userId, long entryId, int value, boolean retrieveFromCache) { Object[] finderArgs = new Object[] {userId, entryId, value}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult( _finderPathFetchByU_E_V, finderArgs, this); } if (result instanceof AnnouncementsFlag) { AnnouncementsFlag announcementsFlag = (AnnouncementsFlag)result; if ((userId != announcementsFlag.getUserId()) || (entryId != announcementsFlag.getEntryId()) || (value != announcementsFlag.getValue())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(5); query.append(_SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE); query.append(_FINDER_COLUMN_U_E_V_USERID_2); query.append(_FINDER_COLUMN_U_E_V_ENTRYID_2); query.append(_FINDER_COLUMN_U_E_V_VALUE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(entryId); qPos.add(value); List list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult( _finderPathFetchByU_E_V, finderArgs, list); } else { AnnouncementsFlag announcementsFlag = list.get(0); result = announcementsFlag; cacheResult(announcementsFlag); } } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathFetchByU_E_V, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (AnnouncementsFlag)result; } } /** * Removes the announcements flag where userId = ? and entryId = ? and value = ? from the database. * * @param userId the user ID * @param entryId the entry ID * @param value the value * @return the announcements flag that was removed */ @Override public AnnouncementsFlag removeByU_E_V(long userId, long entryId, int value) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = findByU_E_V( userId, entryId, value); return remove(announcementsFlag); } /** * Returns the number of announcements flags where userId = ? and entryId = ? and value = ?. * * @param userId the user ID * @param entryId the entry ID * @param value the value * @return the number of matching announcements flags */ @Override public int countByU_E_V(long userId, long entryId, int value) { FinderPath finderPath = _finderPathCountByU_E_V; Object[] finderArgs = new Object[] {userId, entryId, value}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_ANNOUNCEMENTSFLAG_WHERE); query.append(_FINDER_COLUMN_U_E_V_USERID_2); query.append(_FINDER_COLUMN_U_E_V_ENTRYID_2); query.append(_FINDER_COLUMN_U_E_V_VALUE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(entryId); qPos.add(value); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U_E_V_USERID_2 = "announcementsFlag.userId = ? AND "; private static final String _FINDER_COLUMN_U_E_V_ENTRYID_2 = "announcementsFlag.entryId = ? AND "; private static final String _FINDER_COLUMN_U_E_V_VALUE_2 = "announcementsFlag.value = ?"; public AnnouncementsFlagPersistenceImpl() { setModelClass(AnnouncementsFlag.class); } /** * Caches the announcements flag in the entity cache if it is enabled. * * @param announcementsFlag the announcements flag */ @Override public void cacheResult(AnnouncementsFlag announcementsFlag) { EntityCacheUtil.putResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKey(), announcementsFlag); FinderCacheUtil.putResult( _finderPathFetchByU_E_V, new Object[] { announcementsFlag.getUserId(), announcementsFlag.getEntryId(), announcementsFlag.getValue() }, announcementsFlag); announcementsFlag.resetOriginalValues(); } /** * Caches the announcements flags in the entity cache if it is enabled. * * @param announcementsFlags the announcements flags */ @Override public void cacheResult(List announcementsFlags) { for (AnnouncementsFlag announcementsFlag : announcementsFlags) { if (EntityCacheUtil.getResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKey()) == null) { cacheResult(announcementsFlag); } else { announcementsFlag.resetOriginalValues(); } } } /** * Clears the cache for all announcements flags. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { EntityCacheUtil.clearCache(AnnouncementsFlagImpl.class); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the announcements flag. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache(AnnouncementsFlag announcementsFlag) { EntityCacheUtil.removeResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache( (AnnouncementsFlagModelImpl)announcementsFlag, true); } @Override public void clearCache(List announcementsFlags) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (AnnouncementsFlag announcementsFlag : announcementsFlags) { EntityCacheUtil.removeResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKey()); clearUniqueFindersCache( (AnnouncementsFlagModelImpl)announcementsFlag, true); } } protected void cacheUniqueFindersCache( AnnouncementsFlagModelImpl announcementsFlagModelImpl) { Object[] args = new Object[] { announcementsFlagModelImpl.getUserId(), announcementsFlagModelImpl.getEntryId(), announcementsFlagModelImpl.getValue() }; FinderCacheUtil.putResult( _finderPathCountByU_E_V, args, Long.valueOf(1), false); FinderCacheUtil.putResult( _finderPathFetchByU_E_V, args, announcementsFlagModelImpl, false); } protected void clearUniqueFindersCache( AnnouncementsFlagModelImpl announcementsFlagModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { announcementsFlagModelImpl.getUserId(), announcementsFlagModelImpl.getEntryId(), announcementsFlagModelImpl.getValue() }; FinderCacheUtil.removeResult(_finderPathCountByU_E_V, args); FinderCacheUtil.removeResult(_finderPathFetchByU_E_V, args); } if ((announcementsFlagModelImpl.getColumnBitmask() & _finderPathFetchByU_E_V.getColumnBitmask()) != 0) { Object[] args = new Object[] { announcementsFlagModelImpl.getOriginalUserId(), announcementsFlagModelImpl.getOriginalEntryId(), announcementsFlagModelImpl.getOriginalValue() }; FinderCacheUtil.removeResult(_finderPathCountByU_E_V, args); FinderCacheUtil.removeResult(_finderPathFetchByU_E_V, args); } } /** * Creates a new announcements flag with the primary key. Does not add the announcements flag to the database. * * @param flagId the primary key for the new announcements flag * @return the new announcements flag */ @Override public AnnouncementsFlag create(long flagId) { AnnouncementsFlag announcementsFlag = new AnnouncementsFlagImpl(); announcementsFlag.setNew(true); announcementsFlag.setPrimaryKey(flagId); announcementsFlag.setCompanyId(companyProvider.getCompanyId()); return announcementsFlag; } /** * Removes the announcements flag with the primary key from the database. Also notifies the appropriate model listeners. * * @param flagId the primary key of the announcements flag * @return the announcements flag that was removed * @throws NoSuchFlagException if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag remove(long flagId) throws NoSuchFlagException { return remove((Serializable)flagId); } /** * Removes the announcements flag with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the announcements flag * @return the announcements flag that was removed * @throws NoSuchFlagException if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag remove(Serializable primaryKey) throws NoSuchFlagException { Session session = null; try { session = openSession(); AnnouncementsFlag announcementsFlag = (AnnouncementsFlag)session.get( AnnouncementsFlagImpl.class, primaryKey); if (announcementsFlag == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchFlagException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(announcementsFlag); } catch (NoSuchFlagException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected AnnouncementsFlag removeImpl( AnnouncementsFlag announcementsFlag) { Session session = null; try { session = openSession(); if (!session.contains(announcementsFlag)) { announcementsFlag = (AnnouncementsFlag)session.get( AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKeyObj()); } if (announcementsFlag != null) { session.delete(announcementsFlag); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (announcementsFlag != null) { clearCache(announcementsFlag); } return announcementsFlag; } @Override public AnnouncementsFlag updateImpl(AnnouncementsFlag announcementsFlag) { boolean isNew = announcementsFlag.isNew(); if (!(announcementsFlag instanceof AnnouncementsFlagModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(announcementsFlag.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( announcementsFlag); throw new IllegalArgumentException( "Implement ModelWrapper in announcementsFlag proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom AnnouncementsFlag implementation " + announcementsFlag.getClass()); } AnnouncementsFlagModelImpl announcementsFlagModelImpl = (AnnouncementsFlagModelImpl)announcementsFlag; Session session = null; try { session = openSession(); if (announcementsFlag.isNew()) { session.save(announcementsFlag); announcementsFlag.setNew(false); } else { announcementsFlag = (AnnouncementsFlag)session.merge( announcementsFlag); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!AnnouncementsFlagModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { announcementsFlagModelImpl.getEntryId() }; FinderCacheUtil.removeResult(_finderPathCountByEntryId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByEntryId, args); FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((announcementsFlagModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByEntryId. getColumnBitmask()) != 0) { Object[] args = new Object[] { announcementsFlagModelImpl.getOriginalEntryId() }; FinderCacheUtil.removeResult(_finderPathCountByEntryId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByEntryId, args); args = new Object[] {announcementsFlagModelImpl.getEntryId()}; FinderCacheUtil.removeResult(_finderPathCountByEntryId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByEntryId, args); } } EntityCacheUtil.putResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, announcementsFlag.getPrimaryKey(), announcementsFlag, false); clearUniqueFindersCache(announcementsFlagModelImpl, false); cacheUniqueFindersCache(announcementsFlagModelImpl); announcementsFlag.resetOriginalValues(); return announcementsFlag; } /** * Returns the announcements flag with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found. * * @param primaryKey the primary key of the announcements flag * @return the announcements flag * @throws NoSuchFlagException if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag findByPrimaryKey(Serializable primaryKey) throws NoSuchFlagException { AnnouncementsFlag announcementsFlag = fetchByPrimaryKey(primaryKey); if (announcementsFlag == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchFlagException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return announcementsFlag; } /** * Returns the announcements flag with the primary key or throws a NoSuchFlagException if it could not be found. * * @param flagId the primary key of the announcements flag * @return the announcements flag * @throws NoSuchFlagException if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag findByPrimaryKey(long flagId) throws NoSuchFlagException { return findByPrimaryKey((Serializable)flagId); } /** * Returns the announcements flag with the primary key or returns null if it could not be found. * * @param primaryKey the primary key of the announcements flag * @return the announcements flag, or null if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = EntityCacheUtil.getResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, primaryKey); if (serializable == nullModel) { return null; } AnnouncementsFlag announcementsFlag = (AnnouncementsFlag)serializable; if (announcementsFlag == null) { Session session = null; try { session = openSession(); announcementsFlag = (AnnouncementsFlag)session.get( AnnouncementsFlagImpl.class, primaryKey); if (announcementsFlag != null) { cacheResult(announcementsFlag); } else { EntityCacheUtil.putResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, primaryKey, nullModel); } } catch (Exception e) { EntityCacheUtil.removeResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return announcementsFlag; } /** * Returns the announcements flag with the primary key or returns null if it could not be found. * * @param flagId the primary key of the announcements flag * @return the announcements flag, or null if a announcements flag with the primary key could not be found */ @Override public AnnouncementsFlag fetchByPrimaryKey(long flagId) { return fetchByPrimaryKey((Serializable)flagId); } @Override public Map fetchByPrimaryKeys( Set primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); AnnouncementsFlag announcementsFlag = fetchByPrimaryKey(primaryKey); if (announcementsFlag != null) { map.put(primaryKey, announcementsFlag); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = EntityCacheUtil.getResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (AnnouncementsFlag)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler( uncachedPrimaryKeys.size() * 2 + 1); query.append(_SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(","); } query.setIndex(query.index() - 1); query.append(")"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (AnnouncementsFlag announcementsFlag : (List)q.list()) { map.put( announcementsFlag.getPrimaryKeyObj(), announcementsFlag); cacheResult(announcementsFlag); uncachedPrimaryKeys.remove( announcementsFlag.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the announcements flags. * * @return the announcements flags */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the announcements flags. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @return the range of announcements flags */ @Override public List findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the announcements flags. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of announcements flags */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the announcements flags. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from AnnouncementsFlagModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of announcements flags * @param end the upper bound of the range of announcements flags (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of announcements flags */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_ANNOUNCEMENTSFLAG); appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_ANNOUNCEMENTSFLAG; if (pagination) { sql = sql.concat(AnnouncementsFlagModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the announcements flags from the database. * */ @Override public void removeAll() { for (AnnouncementsFlag announcementsFlag : findAll()) { remove(announcementsFlag); } } /** * Returns the number of announcements flags. * * @return the number of announcements flags */ @Override public int countAll() { Long count = (Long)FinderCacheUtil.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_ANNOUNCEMENTSFLAG); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override protected Map getTableColumnsMap() { return AnnouncementsFlagModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the announcements flag persistence. */ public void afterPropertiesSet() { _finderPathWithPaginationFindAll = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, AnnouncementsFlagImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, AnnouncementsFlagImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathWithPaginationFindByEntryId = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, AnnouncementsFlagImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByEntryId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByEntryId = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, AnnouncementsFlagImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByEntryId", new String[] {Long.class.getName()}, AnnouncementsFlagModelImpl.ENTRYID_COLUMN_BITMASK | AnnouncementsFlagModelImpl.USERID_COLUMN_BITMASK | AnnouncementsFlagModelImpl.CREATEDATE_COLUMN_BITMASK); _finderPathCountByEntryId = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByEntryId", new String[] {Long.class.getName()}); _finderPathFetchByU_E_V = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, AnnouncementsFlagImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByU_E_V", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, AnnouncementsFlagModelImpl.USERID_COLUMN_BITMASK | AnnouncementsFlagModelImpl.ENTRYID_COLUMN_BITMASK | AnnouncementsFlagModelImpl.VALUE_COLUMN_BITMASK); _finderPathCountByU_E_V = new FinderPath( AnnouncementsFlagModelImpl.ENTITY_CACHE_ENABLED, AnnouncementsFlagModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_E_V", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); } public void destroy() { EntityCacheUtil.removeCache(AnnouncementsFlagImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; private static final String _SQL_SELECT_ANNOUNCEMENTSFLAG = "SELECT announcementsFlag FROM AnnouncementsFlag announcementsFlag"; private static final String _SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE_PKS_IN = "SELECT announcementsFlag FROM AnnouncementsFlag announcementsFlag WHERE flagId IN ("; private static final String _SQL_SELECT_ANNOUNCEMENTSFLAG_WHERE = "SELECT announcementsFlag FROM AnnouncementsFlag announcementsFlag WHERE "; private static final String _SQL_COUNT_ANNOUNCEMENTSFLAG = "SELECT COUNT(announcementsFlag) FROM AnnouncementsFlag announcementsFlag"; private static final String _SQL_COUNT_ANNOUNCEMENTSFLAG_WHERE = "SELECT COUNT(announcementsFlag) FROM AnnouncementsFlag announcementsFlag WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "announcementsFlag."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AnnouncementsFlag exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AnnouncementsFlag exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( AnnouncementsFlagPersistenceImpl.class); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy