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

com.liferay.notification.service.persistence.impl.NotificationQueueEntryPersistenceImpl Maven / Gradle / Ivy

/**
 * 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.notification.service.persistence.impl;

import com.liferay.notification.exception.NoSuchNotificationQueueEntryException;
import com.liferay.notification.model.NotificationQueueEntry;
import com.liferay.notification.model.NotificationQueueEntryTable;
import com.liferay.notification.model.impl.NotificationQueueEntryImpl;
import com.liferay.notification.model.impl.NotificationQueueEntryModelImpl;
import com.liferay.notification.service.persistence.NotificationQueueEntryPersistence;
import com.liferay.notification.service.persistence.NotificationQueueEntryUtil;
import com.liferay.notification.service.persistence.impl.constants.NotificationPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
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.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.BasePersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;

import java.io.Serializable;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;

import java.sql.Timestamp;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.sql.DataSource;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;

/**
 * The persistence implementation for the notification queue entry service.
 *
 * 

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

* * @author Gabriel Albuquerque * @generated */ @Component( service = {NotificationQueueEntryPersistence.class, BasePersistence.class} ) public class NotificationQueueEntryPersistenceImpl extends BasePersistenceImpl implements NotificationQueueEntryPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use NotificationQueueEntryUtil to access the notification queue entry persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = NotificationQueueEntryImpl.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 _finderPathWithPaginationFindByNotificationTemplateId; private FinderPath _finderPathWithoutPaginationFindByNotificationTemplateId; private FinderPath _finderPathCountByNotificationTemplateId; /** * Returns all the notification queue entries where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @return the matching notification queue entries */ @Override public List findByNotificationTemplateId( long notificationTemplateId) { return findByNotificationTemplateId( notificationTemplateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries where notificationTemplateId = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param notificationTemplateId the notification template ID * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries */ @Override public List findByNotificationTemplateId( long notificationTemplateId, int start, int end) { return findByNotificationTemplateId( notificationTemplateId, start, end, null); } /** * Returns an ordered range of all the notification queue entries where notificationTemplateId = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

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

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param notificationTemplateId the notification template ID * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching notification queue entries */ @Override public List findByNotificationTemplateId( long notificationTemplateId, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByNotificationTemplateId; finderArgs = new Object[] {notificationTemplateId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByNotificationTemplateId; finderArgs = new Object[] { notificationTemplateId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs); if ((list != null) && !list.isEmpty()) { for (NotificationQueueEntry notificationQueueEntry : list) { if (notificationTemplateId != notificationQueueEntry. getNotificationTemplateId()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(notificationTemplateId); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first notification queue entry in the ordered set where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByNotificationTemplateId_First( long notificationTemplateId, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByNotificationTemplateId_First( notificationTemplateId, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("notificationTemplateId="); sb.append(notificationTemplateId); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the first notification queue entry in the ordered set where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByNotificationTemplateId_First( long notificationTemplateId, OrderByComparator orderByComparator) { List list = findByNotificationTemplateId( notificationTemplateId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification queue entry in the ordered set where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByNotificationTemplateId_Last( long notificationTemplateId, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByNotificationTemplateId_Last( notificationTemplateId, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("notificationTemplateId="); sb.append(notificationTemplateId); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the last notification queue entry in the ordered set where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByNotificationTemplateId_Last( long notificationTemplateId, OrderByComparator orderByComparator) { int count = countByNotificationTemplateId(notificationTemplateId); if (count == 0) { return null; } List list = findByNotificationTemplateId( notificationTemplateId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set where notificationTemplateId = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] findByNotificationTemplateId_PrevAndNext( long notificationQueueEntryId, long notificationTemplateId, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = getByNotificationTemplateId_PrevAndNext( session, notificationQueueEntry, notificationTemplateId, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = getByNotificationTemplateId_PrevAndNext( session, notificationQueueEntry, notificationTemplateId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry getByNotificationTemplateId_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, long notificationTemplateId, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(notificationTemplateId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification queue entries that the user has permission to view where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @return the matching notification queue entries that the user has permission to view */ @Override public List filterFindByNotificationTemplateId( long notificationTemplateId) { return filterFindByNotificationTemplateId( notificationTemplateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries that the user has permission to view where notificationTemplateId = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param notificationTemplateId the notification template ID * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByNotificationTemplateId( long notificationTemplateId, int start, int end) { return filterFindByNotificationTemplateId( notificationTemplateId, start, end, null); } /** * Returns an ordered range of all the notification queue entries that the user has permissions to view where notificationTemplateId = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param notificationTemplateId the notification template ID * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByNotificationTemplateId( long notificationTemplateId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByNotificationTemplateId( notificationTemplateId, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(notificationTemplateId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set of notification queue entries that the user has permission to view where notificationTemplateId = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param notificationTemplateId the notification template ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] filterFindByNotificationTemplateId_PrevAndNext( long notificationQueueEntryId, long notificationTemplateId, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { if (!InlineSQLHelperUtil.isEnabled()) { return findByNotificationTemplateId_PrevAndNext( notificationQueueEntryId, notificationTemplateId, orderByComparator); } NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = filterGetByNotificationTemplateId_PrevAndNext( session, notificationQueueEntry, notificationTemplateId, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = filterGetByNotificationTemplateId_PrevAndNext( session, notificationQueueEntry, notificationTemplateId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry filterGetByNotificationTemplateId_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, long notificationTemplateId, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(notificationTemplateId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification queue entries where notificationTemplateId = ? from the database. * * @param notificationTemplateId the notification template ID */ @Override public void removeByNotificationTemplateId(long notificationTemplateId) { for (NotificationQueueEntry notificationQueueEntry : findByNotificationTemplateId( notificationTemplateId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationQueueEntry); } } /** * Returns the number of notification queue entries where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @return the number of matching notification queue entries */ @Override public int countByNotificationTemplateId(long notificationTemplateId) { FinderPath finderPath = _finderPathCountByNotificationTemplateId; Object[] finderArgs = new Object[] {notificationTemplateId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(notificationTemplateId); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of notification queue entries that the user has permission to view where notificationTemplateId = ?. * * @param notificationTemplateId the notification template ID * @return the number of matching notification queue entries that the user has permission to view */ @Override public int filterCountByNotificationTemplateId( long notificationTemplateId) { if (!InlineSQLHelperUtil.isEnabled()) { return countByNotificationTemplateId(notificationTemplateId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append( _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(notificationTemplateId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_NOTIFICATIONTEMPLATEID_NOTIFICATIONTEMPLATEID_2 = "notificationQueueEntry.notificationTemplateId = ?"; private FinderPath _finderPathWithPaginationFindBySent; private FinderPath _finderPathWithoutPaginationFindBySent; private FinderPath _finderPathCountBySent; /** * Returns all the notification queue entries where sent = ?. * * @param sent the sent * @return the matching notification queue entries */ @Override public List findBySent(boolean sent) { return findBySent(sent, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries where sent = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sent the sent * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries */ @Override public List findBySent( boolean sent, int start, int end) { return findBySent(sent, start, end, null); } /** * Returns an ordered range of all the notification queue entries where sent = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sent the sent * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries */ @Override public List findBySent( boolean sent, int start, int end, OrderByComparator orderByComparator) { return findBySent(sent, start, end, orderByComparator, true); } /** * Returns an ordered range of all the notification queue entries where sent = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sent the sent * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching notification queue entries */ @Override public List findBySent( boolean sent, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindBySent; finderArgs = new Object[] {sent}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindBySent; finderArgs = new Object[] {sent, start, end, orderByComparator}; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs); if ((list != null) && !list.isEmpty()) { for (NotificationQueueEntry notificationQueueEntry : list) { if (sent != notificationQueueEntry.isSent()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_SENT_SENT_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(sent); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first notification queue entry in the ordered set where sent = ?. * * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findBySent_First( boolean sent, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchBySent_First( sent, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("sent="); sb.append(sent); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the first notification queue entry in the ordered set where sent = ?. * * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchBySent_First( boolean sent, OrderByComparator orderByComparator) { List list = findBySent( sent, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification queue entry in the ordered set where sent = ?. * * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findBySent_Last( boolean sent, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchBySent_Last( sent, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("sent="); sb.append(sent); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the last notification queue entry in the ordered set where sent = ?. * * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchBySent_Last( boolean sent, OrderByComparator orderByComparator) { int count = countBySent(sent); if (count == 0) { return null; } List list = findBySent( sent, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set where sent = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] findBySent_PrevAndNext( long notificationQueueEntryId, boolean sent, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = getBySent_PrevAndNext( session, notificationQueueEntry, sent, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = getBySent_PrevAndNext( session, notificationQueueEntry, sent, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry getBySent_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, boolean sent, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_SENT_SENT_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(sent); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification queue entries that the user has permission to view where sent = ?. * * @param sent the sent * @return the matching notification queue entries that the user has permission to view */ @Override public List filterFindBySent(boolean sent) { return filterFindBySent( sent, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries that the user has permission to view where sent = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sent the sent * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries that the user has permission to view */ @Override public List filterFindBySent( boolean sent, int start, int end) { return filterFindBySent(sent, start, end, null); } /** * Returns an ordered range of all the notification queue entries that the user has permissions to view where sent = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sent the sent * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries that the user has permission to view */ @Override public List filterFindBySent( boolean sent, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findBySent(sent, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_SENT_SENT_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(sent); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set of notification queue entries that the user has permission to view where sent = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param sent the sent * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] filterFindBySent_PrevAndNext( long notificationQueueEntryId, boolean sent, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { if (!InlineSQLHelperUtil.isEnabled()) { return findBySent_PrevAndNext( notificationQueueEntryId, sent, orderByComparator); } NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = filterGetBySent_PrevAndNext( session, notificationQueueEntry, sent, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = filterGetBySent_PrevAndNext( session, notificationQueueEntry, sent, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry filterGetBySent_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, boolean sent, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_SENT_SENT_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(sent); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification queue entries where sent = ? from the database. * * @param sent the sent */ @Override public void removeBySent(boolean sent) { for (NotificationQueueEntry notificationQueueEntry : findBySent(sent, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationQueueEntry); } } /** * Returns the number of notification queue entries where sent = ?. * * @param sent the sent * @return the number of matching notification queue entries */ @Override public int countBySent(boolean sent) { FinderPath finderPath = _finderPathCountBySent; Object[] finderArgs = new Object[] {sent}; Long count = (Long)finderCache.getResult(finderPath, finderArgs); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_SENT_SENT_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(sent); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of notification queue entries that the user has permission to view where sent = ?. * * @param sent the sent * @return the number of matching notification queue entries that the user has permission to view */ @Override public int filterCountBySent(boolean sent) { if (!InlineSQLHelperUtil.isEnabled()) { return countBySent(sent); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_SENT_SENT_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(sent); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_SENT_SENT_2 = "notificationQueueEntry.sent = ?"; private FinderPath _finderPathWithPaginationFindByLtSentDate; private FinderPath _finderPathWithPaginationCountByLtSentDate; /** * Returns all the notification queue entries where sentDate < ?. * * @param sentDate the sent date * @return the matching notification queue entries */ @Override public List findByLtSentDate(Date sentDate) { return findByLtSentDate( sentDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries where sentDate < ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sentDate the sent date * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries */ @Override public List findByLtSentDate( Date sentDate, int start, int end) { return findByLtSentDate(sentDate, start, end, null); } /** * Returns an ordered range of all the notification queue entries where sentDate < ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sentDate the sent date * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries */ @Override public List findByLtSentDate( Date sentDate, int start, int end, OrderByComparator orderByComparator) { return findByLtSentDate(sentDate, start, end, orderByComparator, true); } /** * Returns an ordered range of all the notification queue entries where sentDate < ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sentDate the sent date * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching notification queue entries */ @Override public List findByLtSentDate( Date sentDate, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; finderPath = _finderPathWithPaginationFindByLtSentDate; finderArgs = new Object[] { _getTime(sentDate), start, end, orderByComparator }; List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs); if ((list != null) && !list.isEmpty()) { for (NotificationQueueEntry notificationQueueEntry : list) { if (sentDate.getTime() <= notificationQueueEntry.getSentDate( ).getTime()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first notification queue entry in the ordered set where sentDate < ?. * * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByLtSentDate_First( Date sentDate, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByLtSentDate_First( sentDate, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("sentDate<"); sb.append(sentDate); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the first notification queue entry in the ordered set where sentDate < ?. * * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByLtSentDate_First( Date sentDate, OrderByComparator orderByComparator) { List list = findByLtSentDate( sentDate, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification queue entry in the ordered set where sentDate < ?. * * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByLtSentDate_Last( Date sentDate, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByLtSentDate_Last( sentDate, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("sentDate<"); sb.append(sentDate); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the last notification queue entry in the ordered set where sentDate < ?. * * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByLtSentDate_Last( Date sentDate, OrderByComparator orderByComparator) { int count = countByLtSentDate(sentDate); if (count == 0) { return null; } List list = findByLtSentDate( sentDate, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set where sentDate < ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] findByLtSentDate_PrevAndNext( long notificationQueueEntryId, Date sentDate, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = getByLtSentDate_PrevAndNext( session, notificationQueueEntry, sentDate, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = getByLtSentDate_PrevAndNext( session, notificationQueueEntry, sentDate, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry getByLtSentDate_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, Date sentDate, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification queue entries that the user has permission to view where sentDate < ?. * * @param sentDate the sent date * @return the matching notification queue entries that the user has permission to view */ @Override public List filterFindByLtSentDate(Date sentDate) { return filterFindByLtSentDate( sentDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries that the user has permission to view where sentDate < ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sentDate the sent date * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByLtSentDate( Date sentDate, int start, int end) { return filterFindByLtSentDate(sentDate, start, end, null); } /** * Returns an ordered range of all the notification queue entries that the user has permissions to view where sentDate < ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param sentDate the sent date * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByLtSentDate( Date sentDate, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByLtSentDate(sentDate, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set of notification queue entries that the user has permission to view where sentDate < ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param sentDate the sent date * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] filterFindByLtSentDate_PrevAndNext( long notificationQueueEntryId, Date sentDate, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { if (!InlineSQLHelperUtil.isEnabled()) { return findByLtSentDate_PrevAndNext( notificationQueueEntryId, sentDate, orderByComparator); } NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = filterGetByLtSentDate_PrevAndNext( session, notificationQueueEntry, sentDate, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = filterGetByLtSentDate_PrevAndNext( session, notificationQueueEntry, sentDate, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry filterGetByLtSentDate_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, Date sentDate, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification queue entries where sentDate < ? from the database. * * @param sentDate the sent date */ @Override public void removeByLtSentDate(Date sentDate) { for (NotificationQueueEntry notificationQueueEntry : findByLtSentDate( sentDate, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationQueueEntry); } } /** * Returns the number of notification queue entries where sentDate < ?. * * @param sentDate the sent date * @return the number of matching notification queue entries */ @Override public int countByLtSentDate(Date sentDate) { FinderPath finderPath = _finderPathWithPaginationCountByLtSentDate; Object[] finderArgs = new Object[] {_getTime(sentDate)}; Long count = (Long)finderCache.getResult(finderPath, finderArgs); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of notification queue entries that the user has permission to view where sentDate < ?. * * @param sentDate the sent date * @return the number of matching notification queue entries that the user has permission to view */ @Override public int filterCountByLtSentDate(Date sentDate) { if (!InlineSQLHelperUtil.isEnabled()) { return countByLtSentDate(sentDate); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); boolean bindSentDate = false; if (sentDate == null) { sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_1); } else { bindSentDate = true; sb.append(_FINDER_COLUMN_LTSENTDATE_SENTDATE_2); } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindSentDate) { queryPos.add(new Timestamp(sentDate.getTime())); } Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_LTSENTDATE_SENTDATE_1 = "notificationQueueEntry.sentDate IS NULL"; private static final String _FINDER_COLUMN_LTSENTDATE_SENTDATE_2 = "notificationQueueEntry.sentDate < ?"; private FinderPath _finderPathWithPaginationFindByStatus; private FinderPath _finderPathWithoutPaginationFindByStatus; private FinderPath _finderPathCountByStatus; /** * Returns all the notification queue entries where status = ?. * * @param status the status * @return the matching notification queue entries */ @Override public List findByStatus(int status) { return findByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries where status = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param status the status * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries */ @Override public List findByStatus( int status, int start, int end) { return findByStatus(status, start, end, null); } /** * Returns an ordered range of all the notification queue entries where status = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param status the status * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries */ @Override public List findByStatus( int status, int start, int end, OrderByComparator orderByComparator) { return findByStatus(status, start, end, orderByComparator, true); } /** * Returns an ordered range of all the notification queue entries where status = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param status the status * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param useFinderCache whether to use the finder cache * @return the ordered range of matching notification queue entries */ @Override public List findByStatus( int status, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByStatus; finderArgs = new Object[] {status}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByStatus; finderArgs = new Object[] {status, start, end, orderByComparator}; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs); if ((list != null) && !list.isEmpty()) { for (NotificationQueueEntry notificationQueueEntry : list) { if (status != notificationQueueEntry.getStatus()) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Returns the first notification queue entry in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByStatus_First( int status, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByStatus_First( status, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the first notification queue entry in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByStatus_First( int status, OrderByComparator orderByComparator) { List list = findByStatus( status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification queue entry in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry * @throws NoSuchNotificationQueueEntryException if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry findByStatus_Last( int status, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByStatus_Last( status, orderByComparator); if (notificationQueueEntry != null) { return notificationQueueEntry; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("status="); sb.append(status); sb.append("}"); throw new NoSuchNotificationQueueEntryException(sb.toString()); } /** * Returns the last notification queue entry in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification queue entry, or null if a matching notification queue entry could not be found */ @Override public NotificationQueueEntry fetchByStatus_Last( int status, OrderByComparator orderByComparator) { int count = countByStatus(status); if (count == 0) { return null; } List list = findByStatus( status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set where status = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] findByStatus_PrevAndNext( long notificationQueueEntryId, int status, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = getByStatus_PrevAndNext( session, notificationQueueEntry, status, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = getByStatus_PrevAndNext( session, notificationQueueEntry, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry getByStatus_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(3); } sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { sb.append(_ORDER_BY_ENTITY_ALIAS); sb.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification queue entries that the user has permission to view where status = ?. * * @param status the status * @return the matching notification queue entries that the user has permission to view */ @Override public List filterFindByStatus(int status) { return filterFindByStatus( status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries that the user has permission to view where status = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param status the status * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @return the range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByStatus( int status, int start, int end) { return filterFindByStatus(status, start, end, null); } /** * Returns an ordered range of all the notification queue entries that the user has permissions to view where status = ?. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param status the status * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification queue entries that the user has permission to view */ @Override public List filterFindByStatus( int status, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByStatus(status, start, end, orderByComparator); } StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true); } else { appendOrderByComparator( sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true); } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(status); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification queue entries before and after the current notification queue entry in the ordered set of notification queue entries that the user has permission to view where status = ?. * * @param notificationQueueEntryId the primary key of the current notification queue entry * @param status the status * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry[] filterFindByStatus_PrevAndNext( long notificationQueueEntryId, int status, OrderByComparator orderByComparator) throws NoSuchNotificationQueueEntryException { if (!InlineSQLHelperUtil.isEnabled()) { return findByStatus_PrevAndNext( notificationQueueEntryId, status, orderByComparator); } NotificationQueueEntry notificationQueueEntry = findByPrimaryKey( notificationQueueEntryId); Session session = null; try { session = openSession(); NotificationQueueEntry[] array = new NotificationQueueEntryImpl[3]; array[0] = filterGetByStatus_PrevAndNext( session, notificationQueueEntry, status, orderByComparator, true); array[1] = notificationQueueEntry; array[2] = filterGetByStatus_PrevAndNext( session, notificationQueueEntry, status, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationQueueEntry filterGetByStatus_PrevAndNext( Session session, NotificationQueueEntry notificationQueueEntry, int status, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(4); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_STATUS_STATUS_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { sb.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByConditionFields[i], true)); } if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN_HAS_NEXT); } else { sb.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(WHERE_GREATER_THAN); } else { sb.append(WHERE_LESSER_THAN); } } } sb.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { sb.append( getColumnName( _ORDER_BY_ENTITY_ALIAS, orderByFields[i], true)); } else { sb.append( getColumnName( _ORDER_BY_ENTITY_TABLE, orderByFields[i], true)); } if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC_HAS_NEXT); } else { sb.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { sb.append(ORDER_BY_ASC); } else { sb.append(ORDER_BY_DESC); } } } } else { if (getDB().isSupportsInlineDistinct()) { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } else { sb.append(NotificationQueueEntryModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.setFirstResult(0); sqlQuery.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { sqlQuery.addEntity( _FILTER_ENTITY_ALIAS, NotificationQueueEntryImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationQueueEntryImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(status); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationQueueEntry)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification queue entries where status = ? from the database. * * @param status the status */ @Override public void removeByStatus(int status) { for (NotificationQueueEntry notificationQueueEntry : findByStatus( status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationQueueEntry); } } /** * Returns the number of notification queue entries where status = ?. * * @param status the status * @return the number of matching notification queue entries */ @Override public int countByStatus(int status) { FinderPath finderPath = _finderPathCountByStatus; Object[] finderArgs = new Object[] {status}; Long count = (Long)finderCache.getResult(finderPath, finderArgs); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(status); count = (Long)query.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } /** * Returns the number of notification queue entries that the user has permission to view where status = ?. * * @param status the status * @return the number of matching notification queue entries that the user has permission to view */ @Override public int filterCountByStatus(int status) { if (!InlineSQLHelperUtil.isEnabled()) { return countByStatus(status); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE); sb.append(_FINDER_COLUMN_STATUS_STATUS_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationQueueEntry.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql); sqlQuery.addScalar( COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(status); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_STATUS_STATUS_2 = "notificationQueueEntry.status = ?"; public NotificationQueueEntryPersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("from", "from_"); dbColumnNames.put("to", "to_"); setDBColumnNames(dbColumnNames); setModelClass(NotificationQueueEntry.class); setModelImplClass(NotificationQueueEntryImpl.class); setModelPKClass(long.class); setTable(NotificationQueueEntryTable.INSTANCE); } /** * Caches the notification queue entry in the entity cache if it is enabled. * * @param notificationQueueEntry the notification queue entry */ @Override public void cacheResult(NotificationQueueEntry notificationQueueEntry) { entityCache.putResult( NotificationQueueEntryImpl.class, notificationQueueEntry.getPrimaryKey(), notificationQueueEntry); } private int _valueObjectFinderCacheListThreshold; /** * Caches the notification queue entries in the entity cache if it is enabled. * * @param notificationQueueEntries the notification queue entries */ @Override public void cacheResult( List notificationQueueEntries) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (notificationQueueEntries.size() > _valueObjectFinderCacheListThreshold))) { return; } for (NotificationQueueEntry notificationQueueEntry : notificationQueueEntries) { if (entityCache.getResult( NotificationQueueEntryImpl.class, notificationQueueEntry.getPrimaryKey()) == null) { cacheResult(notificationQueueEntry); } } } /** * Clears the cache for all notification queue entries. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { entityCache.clearCache(NotificationQueueEntryImpl.class); finderCache.clearCache(NotificationQueueEntryImpl.class); } /** * Clears the cache for the notification queue entry. * *

* The EntityCache and FinderCache are both cleared by this method. *

*/ @Override public void clearCache(NotificationQueueEntry notificationQueueEntry) { entityCache.removeResult( NotificationQueueEntryImpl.class, notificationQueueEntry); } @Override public void clearCache( List notificationQueueEntries) { for (NotificationQueueEntry notificationQueueEntry : notificationQueueEntries) { entityCache.removeResult( NotificationQueueEntryImpl.class, notificationQueueEntry); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(NotificationQueueEntryImpl.class); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult( NotificationQueueEntryImpl.class, primaryKey); } } /** * Creates a new notification queue entry with the primary key. Does not add the notification queue entry to the database. * * @param notificationQueueEntryId the primary key for the new notification queue entry * @return the new notification queue entry */ @Override public NotificationQueueEntry create(long notificationQueueEntryId) { NotificationQueueEntry notificationQueueEntry = new NotificationQueueEntryImpl(); notificationQueueEntry.setNew(true); notificationQueueEntry.setPrimaryKey(notificationQueueEntryId); notificationQueueEntry.setCompanyId(CompanyThreadLocal.getCompanyId()); return notificationQueueEntry; } /** * Removes the notification queue entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param notificationQueueEntryId the primary key of the notification queue entry * @return the notification queue entry that was removed * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry remove(long notificationQueueEntryId) throws NoSuchNotificationQueueEntryException { return remove((Serializable)notificationQueueEntryId); } /** * Removes the notification queue entry with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the notification queue entry * @return the notification queue entry that was removed * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry remove(Serializable primaryKey) throws NoSuchNotificationQueueEntryException { Session session = null; try { session = openSession(); NotificationQueueEntry notificationQueueEntry = (NotificationQueueEntry)session.get( NotificationQueueEntryImpl.class, primaryKey); if (notificationQueueEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchNotificationQueueEntryException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(notificationQueueEntry); } catch (NoSuchNotificationQueueEntryException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected NotificationQueueEntry removeImpl( NotificationQueueEntry notificationQueueEntry) { Session session = null; try { session = openSession(); if (!session.contains(notificationQueueEntry)) { notificationQueueEntry = (NotificationQueueEntry)session.get( NotificationQueueEntryImpl.class, notificationQueueEntry.getPrimaryKeyObj()); } if (notificationQueueEntry != null) { session.delete(notificationQueueEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (notificationQueueEntry != null) { clearCache(notificationQueueEntry); } return notificationQueueEntry; } @Override public NotificationQueueEntry updateImpl( NotificationQueueEntry notificationQueueEntry) { boolean isNew = notificationQueueEntry.isNew(); if (!(notificationQueueEntry instanceof NotificationQueueEntryModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(notificationQueueEntry.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( notificationQueueEntry); throw new IllegalArgumentException( "Implement ModelWrapper in notificationQueueEntry proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom NotificationQueueEntry implementation " + notificationQueueEntry.getClass()); } NotificationQueueEntryModelImpl notificationQueueEntryModelImpl = (NotificationQueueEntryModelImpl)notificationQueueEntry; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date date = new Date(); if (isNew && (notificationQueueEntry.getCreateDate() == null)) { if (serviceContext == null) { notificationQueueEntry.setCreateDate(date); } else { notificationQueueEntry.setCreateDate( serviceContext.getCreateDate(date)); } } if (!notificationQueueEntryModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { notificationQueueEntry.setModifiedDate(date); } else { notificationQueueEntry.setModifiedDate( serviceContext.getModifiedDate(date)); } } Session session = null; try { session = openSession(); if (isNew) { session.save(notificationQueueEntry); } else { notificationQueueEntry = (NotificationQueueEntry)session.merge( notificationQueueEntry); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult( NotificationQueueEntryImpl.class, notificationQueueEntryModelImpl, false, true); if (isNew) { notificationQueueEntry.setNew(false); } notificationQueueEntry.resetOriginalValues(); return notificationQueueEntry; } /** * Returns the notification queue entry 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 notification queue entry * @return the notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry findByPrimaryKey(Serializable primaryKey) throws NoSuchNotificationQueueEntryException { NotificationQueueEntry notificationQueueEntry = fetchByPrimaryKey( primaryKey); if (notificationQueueEntry == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchNotificationQueueEntryException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return notificationQueueEntry; } /** * Returns the notification queue entry with the primary key or throws a NoSuchNotificationQueueEntryException if it could not be found. * * @param notificationQueueEntryId the primary key of the notification queue entry * @return the notification queue entry * @throws NoSuchNotificationQueueEntryException if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry findByPrimaryKey( long notificationQueueEntryId) throws NoSuchNotificationQueueEntryException { return findByPrimaryKey((Serializable)notificationQueueEntryId); } /** * Returns the notification queue entry with the primary key or returns null if it could not be found. * * @param notificationQueueEntryId the primary key of the notification queue entry * @return the notification queue entry, or null if a notification queue entry with the primary key could not be found */ @Override public NotificationQueueEntry fetchByPrimaryKey( long notificationQueueEntryId) { return fetchByPrimaryKey((Serializable)notificationQueueEntryId); } /** * Returns all the notification queue entries. * * @return the notification queue entries */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification queue entries. * *

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

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

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

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

* 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, then the query will include the default ORDER BY logic from NotificationQueueEntryModelImpl. *

* * @param start the lower bound of the range of notification queue entries * @param end the upper bound of the range of notification queue entries (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param useFinderCache whether to use the finder cache * @return the ordered range of notification queue entries */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs); } if (list == null) { StringBundler sb = null; String sql = null; if (orderByComparator != null) { sb = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); sb.append(_SQL_SELECT_NOTIFICATIONQUEUEENTRY); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_NOTIFICATIONQUEUEENTRY; sql = sql.concat(NotificationQueueEntryModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query query = session.createQuery(sql); list = (List)QueryUtil.list( query, getDialect(), start, end); cacheResult(list); if (useFinderCache) { finderCache.putResult(finderPath, finderArgs, list); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return list; } /** * Removes all the notification queue entries from the database. * */ @Override public void removeAll() { for (NotificationQueueEntry notificationQueueEntry : findAll()) { remove(notificationQueueEntry); } } /** * Returns the number of notification queue entries. * * @return the number of notification queue entries */ @Override public int countAll() { Long count = (Long)finderCache.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY); if (count == null) { Session session = null; try { session = openSession(); Query query = session.createQuery( _SQL_COUNT_NOTIFICATIONQUEUEENTRY); count = (Long)query.uniqueResult(); finderCache.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } return count.intValue(); } @Override public Set getBadColumnNames() { return _badColumnNames; } @Override protected EntityCache getEntityCache() { return entityCache; } @Override protected String getPKDBName() { return "notificationQueueEntryId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_NOTIFICATIONQUEUEENTRY; } @Override protected Map getTableColumnsMap() { return NotificationQueueEntryModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the notification queue entry persistence. */ @Activate public void activate() { _valueObjectFinderCacheListThreshold = GetterUtil.getInteger( PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD)); _finderPathWithPaginationFindAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathWithoutPaginationFindAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0], new String[0], true); _finderPathCountAll = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0], new String[0], false); _finderPathWithPaginationFindByNotificationTemplateId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByNotificationTemplateId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"notificationTemplateId"}, true); _finderPathWithoutPaginationFindByNotificationTemplateId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByNotificationTemplateId", new String[] {Long.class.getName()}, new String[] {"notificationTemplateId"}, true); _finderPathCountByNotificationTemplateId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByNotificationTemplateId", new String[] {Long.class.getName()}, new String[] {"notificationTemplateId"}, false); _finderPathWithPaginationFindBySent = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySent", new String[] { Boolean.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"sent"}, true); _finderPathWithoutPaginationFindBySent = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySent", new String[] {Boolean.class.getName()}, new String[] {"sent"}, true); _finderPathCountBySent = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySent", new String[] {Boolean.class.getName()}, new String[] {"sent"}, false); _finderPathWithPaginationFindByLtSentDate = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLtSentDate", new String[] { Date.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"sentDate"}, true); _finderPathWithPaginationCountByLtSentDate = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByLtSentDate", new String[] {Date.class.getName()}, new String[] {"sentDate"}, false); _finderPathWithPaginationFindByStatus = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStatus", new String[] { Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"status"}, true); _finderPathWithoutPaginationFindByStatus = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStatus", new String[] {Integer.class.getName()}, new String[] {"status"}, true); _finderPathCountByStatus = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStatus", new String[] {Integer.class.getName()}, new String[] {"status"}, false); _setNotificationQueueEntryUtilPersistence(this); } @Deactivate public void deactivate() { _setNotificationQueueEntryUtilPersistence(null); entityCache.removeCache(NotificationQueueEntryImpl.class.getName()); } private void _setNotificationQueueEntryUtilPersistence( NotificationQueueEntryPersistence notificationQueueEntryPersistence) { try { Field field = NotificationQueueEntryUtil.class.getDeclaredField( "_persistence"); field.setAccessible(true); field.set(null, notificationQueueEntryPersistence); } catch (ReflectiveOperationException reflectiveOperationException) { throw new RuntimeException(reflectiveOperationException); } } @Override @Reference( target = NotificationPersistenceConstants.SERVICE_CONFIGURATION_FILTER, unbind = "-" ) public void setConfiguration(Configuration configuration) { } @Override @Reference( target = NotificationPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setDataSource(DataSource dataSource) { super.setDataSource(dataSource); } @Override @Reference( target = NotificationPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER, unbind = "-" ) public void setSessionFactory(SessionFactory sessionFactory) { super.setSessionFactory(sessionFactory); } @Reference protected EntityCache entityCache; @Reference protected FinderCache finderCache; private static Long _getTime(Date date) { if (date == null) { return null; } return date.getTime(); } private static final String _SQL_SELECT_NOTIFICATIONQUEUEENTRY = "SELECT notificationQueueEntry FROM NotificationQueueEntry notificationQueueEntry"; private static final String _SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE = "SELECT notificationQueueEntry FROM NotificationQueueEntry notificationQueueEntry WHERE "; private static final String _SQL_COUNT_NOTIFICATIONQUEUEENTRY = "SELECT COUNT(notificationQueueEntry) FROM NotificationQueueEntry notificationQueueEntry"; private static final String _SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE = "SELECT COUNT(notificationQueueEntry) FROM NotificationQueueEntry notificationQueueEntry WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "notificationQueueEntry.notificationQueueEntryId"; private static final String _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_WHERE = "SELECT DISTINCT {notificationQueueEntry.*} FROM NotificationQueueEntry notificationQueueEntry WHERE "; private static final String _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {NotificationQueueEntry.*} FROM (SELECT DISTINCT notificationQueueEntry.notificationQueueEntryId FROM NotificationQueueEntry notificationQueueEntry WHERE "; private static final String _FILTER_SQL_SELECT_NOTIFICATIONQUEUEENTRY_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN NotificationQueueEntry ON TEMP_TABLE.notificationQueueEntryId = NotificationQueueEntry.notificationQueueEntryId"; private static final String _FILTER_SQL_COUNT_NOTIFICATIONQUEUEENTRY_WHERE = "SELECT COUNT(DISTINCT notificationQueueEntry.notificationQueueEntryId) AS COUNT_VALUE FROM NotificationQueueEntry notificationQueueEntry WHERE "; private static final String _FILTER_ENTITY_ALIAS = "notificationQueueEntry"; private static final String _FILTER_ENTITY_TABLE = "NotificationQueueEntry"; private static final String _ORDER_BY_ENTITY_ALIAS = "notificationQueueEntry."; private static final String _ORDER_BY_ENTITY_TABLE = "NotificationQueueEntry."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No NotificationQueueEntry exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No NotificationQueueEntry exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( NotificationQueueEntryPersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"from", "to"}); @Override protected FinderCache getFinderCache() { return finderCache; } @Reference private NotificationQueueEntryModelArgumentsResolver _notificationQueueEntryModelArgumentsResolver; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy