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

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

There is a newer version: 1.0.83
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.notification.service.persistence.impl;

import com.liferay.notification.exception.DuplicateNotificationTemplateExternalReferenceCodeException;
import com.liferay.notification.exception.NoSuchNotificationTemplateException;
import com.liferay.notification.model.NotificationTemplate;
import com.liferay.notification.model.NotificationTemplateTable;
import com.liferay.notification.model.impl.NotificationTemplateImpl;
import com.liferay.notification.model.impl.NotificationTemplateModelImpl;
import com.liferay.notification.service.persistence.NotificationTemplatePersistence;
import com.liferay.notification.service.persistence.NotificationTemplateUtil;
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.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
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.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ContentTypes;
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 com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
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 template service.
 *
 * 

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

* * @author Gabriel Albuquerque * @generated */ @Component(service = NotificationTemplatePersistence.class) public class NotificationTemplatePersistenceImpl extends BasePersistenceImpl implements NotificationTemplatePersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use NotificationTemplateUtil to access the notification template persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = NotificationTemplateImpl.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 _finderPathWithPaginationFindByUuid; private FinderPath _finderPathWithoutPaginationFindByUuid; private FinderPath _finderPathCountByUuid; /** * Returns all the notification templates where uuid = ?. * * @param uuid the uuid * @return the matching notification templates */ @Override public List findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates where uuid = ?. * *

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (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 templates */ @Override public List findByUuid( String uuid, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid; finderArgs = new Object[] {uuid}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid; finderArgs = new Object[] {uuid, start, end, orderByComparator}; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (NotificationTemplate notificationTemplate : list) { if (!uuid.equals(notificationTemplate.getUuid())) { 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_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } 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 template in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByUuid_First( String uuid, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByUuid_First( uuid, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the first notification template in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByUuid_First( String uuid, OrderByComparator orderByComparator) { List list = findByUuid( uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification template in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByUuid_Last( String uuid, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByUuid_Last( uuid, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the last notification template in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByUuid_Last( String uuid, OrderByComparator orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List list = findByUuid( uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification templates before and after the current notification template in the ordered set where uuid = ?. * * @param notificationTemplateId the primary key of the current notification template * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] findByUuid_PrevAndNext( long notificationTemplateId, String uuid, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { uuid = Objects.toString(uuid, ""); NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = getByUuid_PrevAndNext( session, notificationTemplate, uuid, orderByComparator, true); array[1] = notificationTemplate; array[2] = getByUuid_PrevAndNext( session, notificationTemplate, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate getByUuid_PrevAndNext( Session session, NotificationTemplate notificationTemplate, String uuid, 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_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_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(NotificationTemplateModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification templates that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the matching notification templates that the user has permission to view */ @Override public List filterFindByUuid(String uuid) { return filterFindByUuid( uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates that the user has permission to view where uuid = ?. * *

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification templates that the user has permission to view */ @Override public List filterFindByUuid( String uuid, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid(uuid, start, end, orderByComparator); } uuid = Objects.toString(uuid, ""); 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_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification templates before and after the current notification template in the ordered set of notification templates that the user has permission to view where uuid = ?. * * @param notificationTemplateId the primary key of the current notification template * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] filterFindByUuid_PrevAndNext( long notificationTemplateId, String uuid, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { if (!InlineSQLHelperUtil.isEnabled()) { return findByUuid_PrevAndNext( notificationTemplateId, uuid, orderByComparator); } uuid = Objects.toString(uuid, ""); NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = filterGetByUuid_PrevAndNext( session, notificationTemplate, uuid, orderByComparator, true); array[1] = notificationTemplate; array[2] = filterGetByUuid_PrevAndNext( session, notificationTemplate, uuid, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate filterGetByUuid_PrevAndNext( Session session, NotificationTemplate notificationTemplate, String uuid, 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_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification templates where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (NotificationTemplate notificationTemplate : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationTemplate); } } /** * Returns the number of notification templates where uuid = ?. * * @param uuid the uuid * @return the number of matching notification templates */ @Override public int countByUuid(String uuid) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid; Object[] finderArgs = new Object[] {uuid}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } 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 templates that the user has permission to view where uuid = ?. * * @param uuid the uuid * @return the number of matching notification templates that the user has permission to view */ @Override public int filterCountByUuid(String uuid) { if (!InlineSQLHelperUtil.isEnabled()) { return countByUuid(uuid); } uuid = Objects.toString(uuid, ""); StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL); } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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 (bindUuid) { queryPos.add(uuid); } Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_UUID_2 = "notificationTemplate.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(notificationTemplate.uuid IS NULL OR notificationTemplate.uuid = '')"; private static final String _FINDER_COLUMN_UUID_UUID_2_SQL = "notificationTemplate.uuid_ = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3_SQL = "(notificationTemplate.uuid_ IS NULL OR notificationTemplate.uuid_ = '')"; private FinderPath _finderPathWithPaginationFindByUuid_C; private FinderPath _finderPathWithoutPaginationFindByUuid_C; private FinderPath _finderPathCountByUuid_C; /** * Returns all the notification templates where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching notification templates */ @Override public List findByUuid_C( String uuid, long companyId) { return findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates where uuid = ? and companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @return the range of matching notification templates */ @Override public List findByUuid_C( String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the notification templates where uuid = ? and companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification templates */ @Override public List findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator) { return findByUuid_C( uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the notification templates where uuid = ? and companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (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 templates */ @Override public List findByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator, boolean useFinderCache) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { if (useFinderCache) { finderPath = _finderPathWithoutPaginationFindByUuid_C; finderArgs = new Object[] {uuid, companyId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByUuid_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (NotificationTemplate notificationTemplate : list) { if (!uuid.equals(notificationTemplate.getUuid()) || (companyId != notificationTemplate.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(4); } sb.append(_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); 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 template in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByUuid_C_First( uuid, companyId, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the first notification template in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByUuid_C_First( String uuid, long companyId, OrderByComparator orderByComparator) { List list = findByUuid_C( uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification template in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByUuid_C_Last( uuid, companyId, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("uuid="); sb.append(uuid); sb.append(", companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the last notification template in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByUuid_C_Last( String uuid, long companyId, OrderByComparator orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List list = findByUuid_C( uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification templates before and after the current notification template in the ordered set where uuid = ? and companyId = ?. * * @param notificationTemplateId the primary key of the current notification template * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] findByUuid_C_PrevAndNext( long notificationTemplateId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { uuid = Objects.toString(uuid, ""); NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = getByUuid_C_PrevAndNext( session, notificationTemplate, uuid, companyId, orderByComparator, true); array[1] = notificationTemplate; array[2] = getByUuid_C_PrevAndNext( session, notificationTemplate, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate getByUuid_C_PrevAndNext( Session session, NotificationTemplate notificationTemplate, String uuid, long companyId, 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); } sb.append(_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_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(NotificationTemplateModelImpl.ORDER_BY_JPQL); } String sql = sb.toString(); Query query = session.createQuery(sql); query.setFirstResult(0); query.setMaxResults(2); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification templates that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching notification templates that the user has permission to view */ @Override public List filterFindByUuid_C( String uuid, long companyId) { return filterFindByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates that the user has permission to view where uuid = ? and companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @return the range of matching notification templates that the user has permission to view */ @Override public List filterFindByUuid_C( String uuid, long companyId, int start, int end) { return filterFindByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the notification templates that the user has permissions to view where uuid = ? and companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

* * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification templates that the user has permission to view */ @Override public List filterFindByUuid_C( String uuid, long companyId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C(uuid, companyId, start, end, orderByComparator); } uuid = Objects.toString(uuid, ""); StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification templates before and after the current notification template in the ordered set of notification templates that the user has permission to view where uuid = ? and companyId = ?. * * @param notificationTemplateId the primary key of the current notification template * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] filterFindByUuid_C_PrevAndNext( long notificationTemplateId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByUuid_C_PrevAndNext( notificationTemplateId, uuid, companyId, orderByComparator); } uuid = Objects.toString(uuid, ""); NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = filterGetByUuid_C_PrevAndNext( session, notificationTemplate, uuid, companyId, orderByComparator, true); array[1] = notificationTemplate; array[2] = filterGetByUuid_C_PrevAndNext( session, notificationTemplate, uuid, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate filterGetByUuid_C_PrevAndNext( Session session, NotificationTemplate notificationTemplate, String uuid, long companyId, OrderByComparator orderByComparator, boolean previous) { StringBundler sb = null; if (orderByComparator != null) { sb = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { sb = new StringBundler(5); } if (getDB().isSupportsInlineDistinct()) { sb.append(_FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification templates where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (NotificationTemplate notificationTemplate : findByUuid_C( uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationTemplate); } } /** * Returns the number of notification templates where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching notification templates */ @Override public int countByUuid_C(String uuid, long companyId) { uuid = Objects.toString(uuid, ""); FinderPath finderPath = _finderPathCountByUuid_C; Object[] finderArgs = new Object[] {uuid, companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(3); sb.append(_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); 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 templates that the user has permission to view where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching notification templates that the user has permission to view */ @Override public int filterCountByUuid_C(String uuid, long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByUuid_C(uuid, companyId); } uuid = Objects.toString(uuid, ""); StringBundler sb = new StringBundler(3); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); boolean bindUuid = false; if (uuid.isEmpty()) { sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL); } else { bindUuid = true; sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL); } sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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 (bindUuid) { queryPos.add(uuid); } queryPos.add(companyId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "notificationTemplate.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(notificationTemplate.uuid IS NULL OR notificationTemplate.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL = "notificationTemplate.uuid_ = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL = "(notificationTemplate.uuid_ IS NULL OR notificationTemplate.uuid_ = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "notificationTemplate.companyId = ?"; private FinderPath _finderPathWithPaginationFindByCompanyId; private FinderPath _finderPathWithoutPaginationFindByCompanyId; private FinderPath _finderPathCountByCompanyId; /** * Returns all the notification templates where companyId = ?. * * @param companyId the company ID * @return the matching notification templates */ @Override public List findByCompanyId(long companyId) { return findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates where companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (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 templates */ @Override public List findByCompanyId( long companyId, 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 = _finderPathWithoutPaginationFindByCompanyId; finderArgs = new Object[] {companyId}; } } else if (useFinderCache) { finderPath = _finderPathWithPaginationFindByCompanyId; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List list = null; if (useFinderCache) { list = (List)finderCache.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (NotificationTemplate notificationTemplate : list) { if (companyId != notificationTemplate.getCompanyId()) { 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_NOTIFICATIONTEMPLATE_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { sb.append(NotificationTemplateModelImpl.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(companyId); 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 template in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByCompanyId_First( long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByCompanyId_First( companyId, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the first notification template in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByCompanyId_First( long companyId, OrderByComparator orderByComparator) { List list = findByCompanyId( companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last notification template in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByCompanyId_Last( long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByCompanyId_Last( companyId, orderByComparator); if (notificationTemplate != null) { return notificationTemplate; } StringBundler sb = new StringBundler(4); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("companyId="); sb.append(companyId); sb.append("}"); throw new NoSuchNotificationTemplateException(sb.toString()); } /** * Returns the last notification template in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByCompanyId_Last( long companyId, OrderByComparator orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List list = findByCompanyId( companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the notification templates before and after the current notification template in the ordered set where companyId = ?. * * @param notificationTemplateId the primary key of the current notification template * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] findByCompanyId_PrevAndNext( long notificationTemplateId, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = getByCompanyId_PrevAndNext( session, notificationTemplate, companyId, orderByComparator, true); array[1] = notificationTemplate; array[2] = getByCompanyId_PrevAndNext( session, notificationTemplate, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate getByCompanyId_PrevAndNext( Session session, NotificationTemplate notificationTemplate, long companyId, 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_NOTIFICATIONTEMPLATE_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_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(NotificationTemplateModelImpl.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(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = query.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the notification templates that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the matching notification templates that the user has permission to view */ @Override public List filterFindByCompanyId(long companyId) { return filterFindByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates that the user has permission to view where companyId = ?. * *

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

* * @param companyId the company ID * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching notification templates that the user has permission to view */ @Override public List filterFindByCompanyId( long companyId, int start, int end, OrderByComparator orderByComparator) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId(companyId, 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_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); return (List)QueryUtil.list( sqlQuery, getDialect(), start, end); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } /** * Returns the notification templates before and after the current notification template in the ordered set of notification templates that the user has permission to view where companyId = ?. * * @param notificationTemplateId the primary key of the current notification template * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate[] filterFindByCompanyId_PrevAndNext( long notificationTemplateId, long companyId, OrderByComparator orderByComparator) throws NoSuchNotificationTemplateException { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return findByCompanyId_PrevAndNext( notificationTemplateId, companyId, orderByComparator); } NotificationTemplate notificationTemplate = findByPrimaryKey( notificationTemplateId); Session session = null; try { session = openSession(); NotificationTemplate[] array = new NotificationTemplateImpl[3]; array[0] = filterGetByCompanyId_PrevAndNext( session, notificationTemplate, companyId, orderByComparator, true); array[1] = notificationTemplate; array[2] = filterGetByCompanyId_PrevAndNext( session, notificationTemplate, companyId, orderByComparator, false); return array; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } protected NotificationTemplate filterGetByCompanyId_PrevAndNext( Session session, NotificationTemplate notificationTemplate, long companyId, 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_NOTIFICATIONTEMPLATE_WHERE); } else { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1); } sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (!getDB().isSupportsInlineDistinct()) { sb.append( _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_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( NotificationTemplateModelImpl.ORDER_BY_SQL_INLINE_DISTINCT); } else { sb.append(NotificationTemplateModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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, NotificationTemplateImpl.class); } else { sqlQuery.addEntity( _FILTER_ENTITY_TABLE, NotificationTemplateImpl.class); } QueryPos queryPos = QueryPos.getInstance(sqlQuery); queryPos.add(companyId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues( notificationTemplate)) { queryPos.add(orderByConditionValue); } } List list = sqlQuery.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the notification templates where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (NotificationTemplate notificationTemplate : findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(notificationTemplate); } } /** * Returns the number of notification templates where companyId = ?. * * @param companyId the company ID * @return the number of matching notification templates */ @Override public int countByCompanyId(long companyId) { FinderPath finderPath = _finderPathCountByCompanyId; Object[] finderArgs = new Object[] {companyId}; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler sb = new StringBundler(2); sb.append(_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); queryPos.add(companyId); 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 templates that the user has permission to view where companyId = ?. * * @param companyId the company ID * @return the number of matching notification templates that the user has permission to view */ @Override public int filterCountByCompanyId(long companyId) { if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) { return countByCompanyId(companyId); } StringBundler sb = new StringBundler(2); sb.append(_FILTER_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE); sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = InlineSQLHelperUtil.replacePermissionCheck( sb.toString(), NotificationTemplate.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(companyId); Long count = (Long)sqlQuery.uniqueResult(); return count.intValue(); } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "notificationTemplate.companyId = ?"; private FinderPath _finderPathFetchByERC_C; /** * Returns the notification template where externalReferenceCode = ? and companyId = ? or throws a NoSuchNotificationTemplateException if it could not be found. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching notification template * @throws NoSuchNotificationTemplateException if a matching notification template could not be found */ @Override public NotificationTemplate findByERC_C( String externalReferenceCode, long companyId) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByERC_C( externalReferenceCode, companyId); if (notificationTemplate == null) { StringBundler sb = new StringBundler(6); sb.append(_NO_SUCH_ENTITY_WITH_KEY); sb.append("externalReferenceCode="); sb.append(externalReferenceCode); sb.append(", companyId="); sb.append(companyId); sb.append("}"); if (_log.isDebugEnabled()) { _log.debug(sb.toString()); } throw new NoSuchNotificationTemplateException(sb.toString()); } return notificationTemplate; } /** * Returns the notification template where externalReferenceCode = ? and companyId = ? or returns null if it could not be found. Uses the finder cache. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByERC_C( String externalReferenceCode, long companyId) { return fetchByERC_C(externalReferenceCode, companyId, true); } /** * Returns the notification template where externalReferenceCode = ? and companyId = ? or returns null if it could not be found, optionally using the finder cache. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @param useFinderCache whether to use the finder cache * @return the matching notification template, or null if a matching notification template could not be found */ @Override public NotificationTemplate fetchByERC_C( String externalReferenceCode, long companyId, boolean useFinderCache) { externalReferenceCode = Objects.toString(externalReferenceCode, ""); Object[] finderArgs = null; if (useFinderCache) { finderArgs = new Object[] {externalReferenceCode, companyId}; } Object result = null; if (useFinderCache) { result = finderCache.getResult( _finderPathFetchByERC_C, finderArgs, this); } if (result instanceof NotificationTemplate) { NotificationTemplate notificationTemplate = (NotificationTemplate)result; if (!Objects.equals( externalReferenceCode, notificationTemplate.getExternalReferenceCode()) || (companyId != notificationTemplate.getCompanyId())) { result = null; } } if (result == null) { StringBundler sb = new StringBundler(4); sb.append(_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE); boolean bindExternalReferenceCode = false; if (externalReferenceCode.isEmpty()) { sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3); } else { bindExternalReferenceCode = true; sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2); } sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2); String sql = sb.toString(); Session session = null; try { session = openSession(); Query query = session.createQuery(sql); QueryPos queryPos = QueryPos.getInstance(query); if (bindExternalReferenceCode) { queryPos.add(externalReferenceCode); } queryPos.add(companyId); List list = query.list(); if (list.isEmpty()) { if (useFinderCache) { finderCache.putResult( _finderPathFetchByERC_C, finderArgs, list); } } else { NotificationTemplate notificationTemplate = list.get(0); result = notificationTemplate; cacheResult(notificationTemplate); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (NotificationTemplate)result; } } /** * Removes the notification template where externalReferenceCode = ? and companyId = ? from the database. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the notification template that was removed */ @Override public NotificationTemplate removeByERC_C( String externalReferenceCode, long companyId) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = findByERC_C( externalReferenceCode, companyId); return remove(notificationTemplate); } /** * Returns the number of notification templates where externalReferenceCode = ? and companyId = ?. * * @param externalReferenceCode the external reference code * @param companyId the company ID * @return the number of matching notification templates */ @Override public int countByERC_C(String externalReferenceCode, long companyId) { NotificationTemplate notificationTemplate = fetchByERC_C( externalReferenceCode, companyId); if (notificationTemplate == null) { return 0; } return 1; } private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2 = "notificationTemplate.externalReferenceCode = ? AND "; private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 = "(notificationTemplate.externalReferenceCode IS NULL OR notificationTemplate.externalReferenceCode = '') AND "; private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 = "notificationTemplate.companyId = ?"; public NotificationTemplatePersistenceImpl() { Map dbColumnNames = new HashMap(); dbColumnNames.put("uuid", "uuid_"); dbColumnNames.put("system", "system_"); dbColumnNames.put("type", "type_"); setDBColumnNames(dbColumnNames); setModelClass(NotificationTemplate.class); setModelImplClass(NotificationTemplateImpl.class); setModelPKClass(long.class); setTable(NotificationTemplateTable.INSTANCE); } /** * Caches the notification template in the entity cache if it is enabled. * * @param notificationTemplate the notification template */ @Override public void cacheResult(NotificationTemplate notificationTemplate) { entityCache.putResult( NotificationTemplateImpl.class, notificationTemplate.getPrimaryKey(), notificationTemplate); finderCache.putResult( _finderPathFetchByERC_C, new Object[] { notificationTemplate.getExternalReferenceCode(), notificationTemplate.getCompanyId() }, notificationTemplate); } private int _valueObjectFinderCacheListThreshold; /** * Caches the notification templates in the entity cache if it is enabled. * * @param notificationTemplates the notification templates */ @Override public void cacheResult(List notificationTemplates) { if ((_valueObjectFinderCacheListThreshold == 0) || ((_valueObjectFinderCacheListThreshold > 0) && (notificationTemplates.size() > _valueObjectFinderCacheListThreshold))) { return; } for (NotificationTemplate notificationTemplate : notificationTemplates) { if (entityCache.getResult( NotificationTemplateImpl.class, notificationTemplate.getPrimaryKey()) == null) { cacheResult(notificationTemplate); } } } /** * Clears the cache for all notification templates. * *

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

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

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

*/ @Override public void clearCache(NotificationTemplate notificationTemplate) { entityCache.removeResult( NotificationTemplateImpl.class, notificationTemplate); } @Override public void clearCache(List notificationTemplates) { for (NotificationTemplate notificationTemplate : notificationTemplates) { entityCache.removeResult( NotificationTemplateImpl.class, notificationTemplate); } } @Override public void clearCache(Set primaryKeys) { finderCache.clearCache(NotificationTemplateImpl.class); for (Serializable primaryKey : primaryKeys) { entityCache.removeResult( NotificationTemplateImpl.class, primaryKey); } } protected void cacheUniqueFindersCache( NotificationTemplateModelImpl notificationTemplateModelImpl) { Object[] args = new Object[] { notificationTemplateModelImpl.getExternalReferenceCode(), notificationTemplateModelImpl.getCompanyId() }; finderCache.putResult( _finderPathFetchByERC_C, args, notificationTemplateModelImpl); } /** * Creates a new notification template with the primary key. Does not add the notification template to the database. * * @param notificationTemplateId the primary key for the new notification template * @return the new notification template */ @Override public NotificationTemplate create(long notificationTemplateId) { NotificationTemplate notificationTemplate = new NotificationTemplateImpl(); notificationTemplate.setNew(true); notificationTemplate.setPrimaryKey(notificationTemplateId); String uuid = PortalUUIDUtil.generate(); notificationTemplate.setUuid(uuid); notificationTemplate.setCompanyId(CompanyThreadLocal.getCompanyId()); return notificationTemplate; } /** * Removes the notification template with the primary key from the database. Also notifies the appropriate model listeners. * * @param notificationTemplateId the primary key of the notification template * @return the notification template that was removed * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate remove(long notificationTemplateId) throws NoSuchNotificationTemplateException { return remove((Serializable)notificationTemplateId); } /** * Removes the notification template with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the notification template * @return the notification template that was removed * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate remove(Serializable primaryKey) throws NoSuchNotificationTemplateException { Session session = null; try { session = openSession(); NotificationTemplate notificationTemplate = (NotificationTemplate)session.get( NotificationTemplateImpl.class, primaryKey); if (notificationTemplate == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchNotificationTemplateException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(notificationTemplate); } catch (NoSuchNotificationTemplateException noSuchEntityException) { throw noSuchEntityException; } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } } @Override protected NotificationTemplate removeImpl( NotificationTemplate notificationTemplate) { Session session = null; try { session = openSession(); if (!session.contains(notificationTemplate)) { notificationTemplate = (NotificationTemplate)session.get( NotificationTemplateImpl.class, notificationTemplate.getPrimaryKeyObj()); } if (notificationTemplate != null) { session.delete(notificationTemplate); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } if (notificationTemplate != null) { clearCache(notificationTemplate); } return notificationTemplate; } @Override public NotificationTemplate updateImpl( NotificationTemplate notificationTemplate) { boolean isNew = notificationTemplate.isNew(); if (!(notificationTemplate instanceof NotificationTemplateModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(notificationTemplate.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( notificationTemplate); throw new IllegalArgumentException( "Implement ModelWrapper in notificationTemplate proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom NotificationTemplate implementation " + notificationTemplate.getClass()); } NotificationTemplateModelImpl notificationTemplateModelImpl = (NotificationTemplateModelImpl)notificationTemplate; if (Validator.isNull(notificationTemplate.getUuid())) { String uuid = PortalUUIDUtil.generate(); notificationTemplate.setUuid(uuid); } if (Validator.isNull(notificationTemplate.getExternalReferenceCode())) { notificationTemplate.setExternalReferenceCode( notificationTemplate.getUuid()); } else { if (!Objects.equals( notificationTemplateModelImpl.getColumnOriginalValue( "externalReferenceCode"), notificationTemplate.getExternalReferenceCode())) { long userId = GetterUtil.getLong( PrincipalThreadLocal.getName()); if (userId > 0) { long companyId = notificationTemplate.getCompanyId(); long groupId = 0; long classPK = 0; if (!isNew) { classPK = notificationTemplate.getPrimaryKey(); } try { notificationTemplate.setExternalReferenceCode( SanitizerUtil.sanitize( companyId, groupId, userId, NotificationTemplate.class.getName(), classPK, ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL, notificationTemplate.getExternalReferenceCode(), null)); } catch (SanitizerException sanitizerException) { throw new SystemException(sanitizerException); } } } NotificationTemplate ercNotificationTemplate = fetchByERC_C( notificationTemplate.getExternalReferenceCode(), notificationTemplate.getCompanyId()); if (isNew) { if (ercNotificationTemplate != null) { throw new DuplicateNotificationTemplateExternalReferenceCodeException( "Duplicate notification template with external reference code " + notificationTemplate.getExternalReferenceCode() + " and company " + notificationTemplate.getCompanyId()); } } else { if ((ercNotificationTemplate != null) && (notificationTemplate.getNotificationTemplateId() != ercNotificationTemplate.getNotificationTemplateId())) { throw new DuplicateNotificationTemplateExternalReferenceCodeException( "Duplicate notification template with external reference code " + notificationTemplate.getExternalReferenceCode() + " and company " + notificationTemplate.getCompanyId()); } } } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date date = new Date(); if (isNew && (notificationTemplate.getCreateDate() == null)) { if (serviceContext == null) { notificationTemplate.setCreateDate(date); } else { notificationTemplate.setCreateDate( serviceContext.getCreateDate(date)); } } if (!notificationTemplateModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { notificationTemplate.setModifiedDate(date); } else { notificationTemplate.setModifiedDate( serviceContext.getModifiedDate(date)); } } Session session = null; try { session = openSession(); if (isNew) { session.save(notificationTemplate); } else { notificationTemplate = (NotificationTemplate)session.merge( notificationTemplate); } } catch (Exception exception) { throw processException(exception); } finally { closeSession(session); } entityCache.putResult( NotificationTemplateImpl.class, notificationTemplateModelImpl, false, true); cacheUniqueFindersCache(notificationTemplateModelImpl); if (isNew) { notificationTemplate.setNew(false); } notificationTemplate.resetOriginalValues(); return notificationTemplate; } /** * Returns the notification template 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 template * @return the notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate findByPrimaryKey(Serializable primaryKey) throws NoSuchNotificationTemplateException { NotificationTemplate notificationTemplate = fetchByPrimaryKey( primaryKey); if (notificationTemplate == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchNotificationTemplateException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return notificationTemplate; } /** * Returns the notification template with the primary key or throws a NoSuchNotificationTemplateException if it could not be found. * * @param notificationTemplateId the primary key of the notification template * @return the notification template * @throws NoSuchNotificationTemplateException if a notification template with the primary key could not be found */ @Override public NotificationTemplate findByPrimaryKey(long notificationTemplateId) throws NoSuchNotificationTemplateException { return findByPrimaryKey((Serializable)notificationTemplateId); } /** * Returns the notification template with the primary key or returns null if it could not be found. * * @param notificationTemplateId the primary key of the notification template * @return the notification template, or null if a notification template with the primary key could not be found */ @Override public NotificationTemplate fetchByPrimaryKey(long notificationTemplateId) { return fetchByPrimaryKey((Serializable)notificationTemplateId); } /** * Returns all the notification templates. * * @return the notification templates */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the notification templates. * *

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

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

* 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 NotificationTemplateModelImpl. *

* * @param start the lower bound of the range of notification templates * @param end the upper bound of the range of notification templates (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 templates */ @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, this); } if (list == null) { StringBundler sb = null; String sql = null; if (orderByComparator != null) { sb = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); sb.append(_SQL_SELECT_NOTIFICATIONTEMPLATE); appendOrderByComparator( sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = sb.toString(); } else { sql = _SQL_SELECT_NOTIFICATIONTEMPLATE; sql = sql.concat(NotificationTemplateModelImpl.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 templates from the database. * */ @Override public void removeAll() { for (NotificationTemplate notificationTemplate : findAll()) { remove(notificationTemplate); } } /** * Returns the number of notification templates. * * @return the number of notification templates */ @Override public int countAll() { Long count = (Long)finderCache.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query query = session.createQuery( _SQL_COUNT_NOTIFICATIONTEMPLATE); 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 "notificationTemplateId"; } @Override protected String getSelectSQL() { return _SQL_SELECT_NOTIFICATIONTEMPLATE; } @Override protected Map getTableColumnsMap() { return NotificationTemplateModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the notification template 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); _finderPathWithPaginationFindByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"uuid_"}, true); _finderPathWithoutPaginationFindByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] {String.class.getName()}, new String[] {"uuid_"}, true); _finderPathCountByUuid = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] {String.class.getName()}, new String[] {"uuid_"}, false); _finderPathWithPaginationFindByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"uuid_", "companyId"}, true); _finderPathWithoutPaginationFindByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"uuid_", "companyId"}, true); _finderPathCountByUuid_C = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"uuid_", "companyId"}, false); _finderPathWithPaginationFindByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }, new String[] {"companyId"}, true); _finderPathWithoutPaginationFindByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] {Long.class.getName()}, new String[] {"companyId"}, true); _finderPathCountByCompanyId = new FinderPath( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] {Long.class.getName()}, new String[] {"companyId"}, false); _finderPathFetchByERC_C = new FinderPath( FINDER_CLASS_NAME_ENTITY, "fetchByERC_C", new String[] {String.class.getName(), Long.class.getName()}, new String[] {"externalReferenceCode", "companyId"}, true); NotificationTemplateUtil.setPersistence(this); } @Deactivate public void deactivate() { NotificationTemplateUtil.setPersistence(null); entityCache.removeCache(NotificationTemplateImpl.class.getName()); } @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 final String _SQL_SELECT_NOTIFICATIONTEMPLATE = "SELECT notificationTemplate FROM NotificationTemplate notificationTemplate"; private static final String _SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE = "SELECT notificationTemplate FROM NotificationTemplate notificationTemplate WHERE "; private static final String _SQL_COUNT_NOTIFICATIONTEMPLATE = "SELECT COUNT(notificationTemplate) FROM NotificationTemplate notificationTemplate"; private static final String _SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE = "SELECT COUNT(notificationTemplate) FROM NotificationTemplate notificationTemplate WHERE "; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "notificationTemplate.notificationTemplateId"; private static final String _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_WHERE = "SELECT DISTINCT {notificationTemplate.*} FROM NotificationTemplate notificationTemplate WHERE "; private static final String _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {NotificationTemplate.*} FROM (SELECT DISTINCT notificationTemplate.notificationTemplateId FROM NotificationTemplate notificationTemplate WHERE "; private static final String _FILTER_SQL_SELECT_NOTIFICATIONTEMPLATE_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN NotificationTemplate ON TEMP_TABLE.notificationTemplateId = NotificationTemplate.notificationTemplateId"; private static final String _FILTER_SQL_COUNT_NOTIFICATIONTEMPLATE_WHERE = "SELECT COUNT(DISTINCT notificationTemplate.notificationTemplateId) AS COUNT_VALUE FROM NotificationTemplate notificationTemplate WHERE "; private static final String _FILTER_ENTITY_ALIAS = "notificationTemplate"; private static final String _FILTER_ENTITY_TABLE = "NotificationTemplate"; private static final String _ORDER_BY_ENTITY_ALIAS = "notificationTemplate."; private static final String _ORDER_BY_ENTITY_TABLE = "NotificationTemplate."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No NotificationTemplate exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No NotificationTemplate exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( NotificationTemplatePersistenceImpl.class); private static final Set _badColumnNames = SetUtil.fromArray( new String[] {"uuid", "system", "type"}); @Override protected FinderCache getFinderCache() { return finderCache; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy