
com.liferay.notification.service.persistence.impl.NotificationRecipientPersistenceImpl Maven / Gradle / Ivy
/**
* 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.NoSuchNotificationRecipientException;
import com.liferay.notification.model.NotificationRecipient;
import com.liferay.notification.model.NotificationRecipientTable;
import com.liferay.notification.model.impl.NotificationRecipientImpl;
import com.liferay.notification.model.impl.NotificationRecipientModelImpl;
import com.liferay.notification.service.persistence.NotificationRecipientPersistence;
import com.liferay.notification.service.persistence.NotificationRecipientUtil;
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.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
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.Collections;
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 recipient service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Gabriel Albuquerque
* @generated
*/
@Component(service = NotificationRecipientPersistence.class)
public class NotificationRecipientPersistenceImpl
extends BasePersistenceImpl
implements NotificationRecipientPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use NotificationRecipientUtil
to access the notification recipient persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
NotificationRecipientImpl.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 recipients where uuid = ?.
*
* @param uuid the uuid
* @return the matching notification recipients
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the notification recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @return the range of matching notification recipients
*/
@Override
public List findByUuid(
String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the notification recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching notification recipients
*/
@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 recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (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 recipients
*/
@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 (NotificationRecipient notificationRecipient : list) {
if (!uuid.equals(notificationRecipient.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_NOTIFICATIONRECIPIENT_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(NotificationRecipientModelImpl.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 recipient 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 recipient
* @throws NoSuchNotificationRecipientException if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient findByUuid_First(
String uuid,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByUuid_First(
uuid, orderByComparator);
if (notificationRecipient != null) {
return notificationRecipient;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchNotificationRecipientException(sb.toString());
}
/**
* Returns the first notification recipient 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 recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient 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 recipient 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 recipient
* @throws NoSuchNotificationRecipientException if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient findByUuid_Last(
String uuid,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByUuid_Last(
uuid, orderByComparator);
if (notificationRecipient != null) {
return notificationRecipient;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchNotificationRecipientException(sb.toString());
}
/**
* Returns the last notification recipient 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 recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient 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 recipients before and after the current notification recipient in the ordered set where uuid = ?.
*
* @param notificationRecipientId the primary key of the current notification recipient
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next notification recipient
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient[] findByUuid_PrevAndNext(
long notificationRecipientId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
uuid = Objects.toString(uuid, "");
NotificationRecipient notificationRecipient = findByPrimaryKey(
notificationRecipientId);
Session session = null;
try {
session = openSession();
NotificationRecipient[] array = new NotificationRecipientImpl[3];
array[0] = getByUuid_PrevAndNext(
session, notificationRecipient, uuid, orderByComparator, true);
array[1] = notificationRecipient;
array[2] = getByUuid_PrevAndNext(
session, notificationRecipient, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected NotificationRecipient getByUuid_PrevAndNext(
Session session, NotificationRecipient notificationRecipient,
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_NOTIFICATIONRECIPIENT_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(NotificationRecipientModelImpl.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(
notificationRecipient)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the notification recipients where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (NotificationRecipient notificationRecipient :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(notificationRecipient);
}
}
/**
* Returns the number of notification recipients where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching notification recipients
*/
@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_NOTIFICATIONRECIPIENT_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();
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"notificationRecipient.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(notificationRecipient.uuid IS NULL OR notificationRecipient.uuid = '')";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the notification recipients where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching notification recipients
*/
@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 recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @return the range of matching notification recipients
*/
@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 recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching notification recipients
*/
@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 recipients 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 NotificationRecipientModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (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 recipients
*/
@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 (NotificationRecipient notificationRecipient : list) {
if (!uuid.equals(notificationRecipient.getUuid()) ||
(companyId != notificationRecipient.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_NOTIFICATIONRECIPIENT_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(NotificationRecipientModelImpl.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 recipient 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 recipient
* @throws NoSuchNotificationRecipientException if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (notificationRecipient != null) {
return notificationRecipient;
}
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 NoSuchNotificationRecipientException(sb.toString());
}
/**
* Returns the first notification recipient 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 recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient 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 recipient 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 recipient
* @throws NoSuchNotificationRecipientException if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (notificationRecipient != null) {
return notificationRecipient;
}
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 NoSuchNotificationRecipientException(sb.toString());
}
/**
* Returns the last notification recipient 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 recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient 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 recipients before and after the current notification recipient in the ordered set where uuid = ? and companyId = ?.
*
* @param notificationRecipientId the primary key of the current notification recipient
* @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 recipient
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient[] findByUuid_C_PrevAndNext(
long notificationRecipientId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchNotificationRecipientException {
uuid = Objects.toString(uuid, "");
NotificationRecipient notificationRecipient = findByPrimaryKey(
notificationRecipientId);
Session session = null;
try {
session = openSession();
NotificationRecipient[] array = new NotificationRecipientImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, notificationRecipient, uuid, companyId,
orderByComparator, true);
array[1] = notificationRecipient;
array[2] = getByUuid_C_PrevAndNext(
session, notificationRecipient, uuid, companyId,
orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected NotificationRecipient getByUuid_C_PrevAndNext(
Session session, NotificationRecipient notificationRecipient,
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_NOTIFICATIONRECIPIENT_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(NotificationRecipientModelImpl.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(
notificationRecipient)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the notification recipients 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 (NotificationRecipient notificationRecipient :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(notificationRecipient);
}
}
/**
* Returns the number of notification recipients where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching notification recipients
*/
@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_NOTIFICATIONRECIPIENT_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();
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"notificationRecipient.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(notificationRecipient.uuid IS NULL OR notificationRecipient.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"notificationRecipient.companyId = ?";
private FinderPath _finderPathFetchByClassPK;
/**
* Returns the notification recipient where classPK = ? or throws a NoSuchNotificationRecipientException
if it could not be found.
*
* @param classPK the class pk
* @return the matching notification recipient
* @throws NoSuchNotificationRecipientException if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient findByClassPK(long classPK)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByClassPK(classPK);
if (notificationRecipient == null) {
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("classPK=");
sb.append(classPK);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchNotificationRecipientException(sb.toString());
}
return notificationRecipient;
}
/**
* Returns the notification recipient where classPK = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param classPK the class pk
* @return the matching notification recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient fetchByClassPK(long classPK) {
return fetchByClassPK(classPK, true);
}
/**
* Returns the notification recipient where classPK = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param classPK the class pk
* @param useFinderCache whether to use the finder cache
* @return the matching notification recipient, or null
if a matching notification recipient could not be found
*/
@Override
public NotificationRecipient fetchByClassPK(
long classPK, boolean useFinderCache) {
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {classPK};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByClassPK, finderArgs, this);
}
if (result instanceof NotificationRecipient) {
NotificationRecipient notificationRecipient =
(NotificationRecipient)result;
if (classPK != notificationRecipient.getClassPK()) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_SELECT_NOTIFICATIONRECIPIENT_WHERE);
sb.append(_FINDER_COLUMN_CLASSPK_CLASSPK_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(classPK);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByClassPK, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {classPK};
}
_log.warn(
"NotificationRecipientPersistenceImpl.fetchByClassPK(long, boolean) with parameters (" +
StringUtil.merge(finderArgs) +
") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
}
}
NotificationRecipient notificationRecipient = list.get(0);
result = notificationRecipient;
cacheResult(notificationRecipient);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (NotificationRecipient)result;
}
}
/**
* Removes the notification recipient where classPK = ? from the database.
*
* @param classPK the class pk
* @return the notification recipient that was removed
*/
@Override
public NotificationRecipient removeByClassPK(long classPK)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = findByClassPK(classPK);
return remove(notificationRecipient);
}
/**
* Returns the number of notification recipients where classPK = ?.
*
* @param classPK the class pk
* @return the number of matching notification recipients
*/
@Override
public int countByClassPK(long classPK) {
NotificationRecipient notificationRecipient = fetchByClassPK(classPK);
if (notificationRecipient == null) {
return 0;
}
return 1;
}
private static final String _FINDER_COLUMN_CLASSPK_CLASSPK_2 =
"notificationRecipient.classPK = ?";
public NotificationRecipientPersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("uuid", "uuid_");
setDBColumnNames(dbColumnNames);
setModelClass(NotificationRecipient.class);
setModelImplClass(NotificationRecipientImpl.class);
setModelPKClass(long.class);
setTable(NotificationRecipientTable.INSTANCE);
}
/**
* Caches the notification recipient in the entity cache if it is enabled.
*
* @param notificationRecipient the notification recipient
*/
@Override
public void cacheResult(NotificationRecipient notificationRecipient) {
entityCache.putResult(
NotificationRecipientImpl.class,
notificationRecipient.getPrimaryKey(), notificationRecipient);
finderCache.putResult(
_finderPathFetchByClassPK,
new Object[] {notificationRecipient.getClassPK()},
notificationRecipient);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the notification recipients in the entity cache if it is enabled.
*
* @param notificationRecipients the notification recipients
*/
@Override
public void cacheResult(
List notificationRecipients) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(notificationRecipients.size() >
_valueObjectFinderCacheListThreshold))) {
return;
}
for (NotificationRecipient notificationRecipient :
notificationRecipients) {
if (entityCache.getResult(
NotificationRecipientImpl.class,
notificationRecipient.getPrimaryKey()) == null) {
cacheResult(notificationRecipient);
}
}
}
/**
* Clears the cache for all notification recipients.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(NotificationRecipientImpl.class);
finderCache.clearCache(NotificationRecipientImpl.class);
}
/**
* Clears the cache for the notification recipient.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(NotificationRecipient notificationRecipient) {
entityCache.removeResult(
NotificationRecipientImpl.class, notificationRecipient);
}
@Override
public void clearCache(List notificationRecipients) {
for (NotificationRecipient notificationRecipient :
notificationRecipients) {
entityCache.removeResult(
NotificationRecipientImpl.class, notificationRecipient);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(NotificationRecipientImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(
NotificationRecipientImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(
NotificationRecipientModelImpl notificationRecipientModelImpl) {
Object[] args = new Object[] {
notificationRecipientModelImpl.getClassPK()
};
finderCache.putResult(
_finderPathFetchByClassPK, args, notificationRecipientModelImpl);
}
/**
* Creates a new notification recipient with the primary key. Does not add the notification recipient to the database.
*
* @param notificationRecipientId the primary key for the new notification recipient
* @return the new notification recipient
*/
@Override
public NotificationRecipient create(long notificationRecipientId) {
NotificationRecipient notificationRecipient =
new NotificationRecipientImpl();
notificationRecipient.setNew(true);
notificationRecipient.setPrimaryKey(notificationRecipientId);
String uuid = PortalUUIDUtil.generate();
notificationRecipient.setUuid(uuid);
notificationRecipient.setCompanyId(CompanyThreadLocal.getCompanyId());
return notificationRecipient;
}
/**
* Removes the notification recipient with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param notificationRecipientId the primary key of the notification recipient
* @return the notification recipient that was removed
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient remove(long notificationRecipientId)
throws NoSuchNotificationRecipientException {
return remove((Serializable)notificationRecipientId);
}
/**
* Removes the notification recipient with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the notification recipient
* @return the notification recipient that was removed
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient remove(Serializable primaryKey)
throws NoSuchNotificationRecipientException {
Session session = null;
try {
session = openSession();
NotificationRecipient notificationRecipient =
(NotificationRecipient)session.get(
NotificationRecipientImpl.class, primaryKey);
if (notificationRecipient == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchNotificationRecipientException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(notificationRecipient);
}
catch (NoSuchNotificationRecipientException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected NotificationRecipient removeImpl(
NotificationRecipient notificationRecipient) {
Session session = null;
try {
session = openSession();
if (!session.contains(notificationRecipient)) {
notificationRecipient = (NotificationRecipient)session.get(
NotificationRecipientImpl.class,
notificationRecipient.getPrimaryKeyObj());
}
if (notificationRecipient != null) {
session.delete(notificationRecipient);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (notificationRecipient != null) {
clearCache(notificationRecipient);
}
return notificationRecipient;
}
@Override
public NotificationRecipient updateImpl(
NotificationRecipient notificationRecipient) {
boolean isNew = notificationRecipient.isNew();
if (!(notificationRecipient instanceof
NotificationRecipientModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(notificationRecipient.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(
notificationRecipient);
throw new IllegalArgumentException(
"Implement ModelWrapper in notificationRecipient proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom NotificationRecipient implementation " +
notificationRecipient.getClass());
}
NotificationRecipientModelImpl notificationRecipientModelImpl =
(NotificationRecipientModelImpl)notificationRecipient;
if (Validator.isNull(notificationRecipient.getUuid())) {
String uuid = PortalUUIDUtil.generate();
notificationRecipient.setUuid(uuid);
}
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (notificationRecipient.getCreateDate() == null)) {
if (serviceContext == null) {
notificationRecipient.setCreateDate(date);
}
else {
notificationRecipient.setCreateDate(
serviceContext.getCreateDate(date));
}
}
if (!notificationRecipientModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
notificationRecipient.setModifiedDate(date);
}
else {
notificationRecipient.setModifiedDate(
serviceContext.getModifiedDate(date));
}
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(notificationRecipient);
}
else {
notificationRecipient = (NotificationRecipient)session.merge(
notificationRecipient);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(
NotificationRecipientImpl.class, notificationRecipientModelImpl,
false, true);
cacheUniqueFindersCache(notificationRecipientModelImpl);
if (isNew) {
notificationRecipient.setNew(false);
}
notificationRecipient.resetOriginalValues();
return notificationRecipient;
}
/**
* Returns the notification recipient 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 recipient
* @return the notification recipient
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient findByPrimaryKey(Serializable primaryKey)
throws NoSuchNotificationRecipientException {
NotificationRecipient notificationRecipient = fetchByPrimaryKey(
primaryKey);
if (notificationRecipient == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchNotificationRecipientException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return notificationRecipient;
}
/**
* Returns the notification recipient with the primary key or throws a NoSuchNotificationRecipientException
if it could not be found.
*
* @param notificationRecipientId the primary key of the notification recipient
* @return the notification recipient
* @throws NoSuchNotificationRecipientException if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient findByPrimaryKey(long notificationRecipientId)
throws NoSuchNotificationRecipientException {
return findByPrimaryKey((Serializable)notificationRecipientId);
}
/**
* Returns the notification recipient with the primary key or returns null
if it could not be found.
*
* @param notificationRecipientId the primary key of the notification recipient
* @return the notification recipient, or null
if a notification recipient with the primary key could not be found
*/
@Override
public NotificationRecipient fetchByPrimaryKey(
long notificationRecipientId) {
return fetchByPrimaryKey((Serializable)notificationRecipientId);
}
/**
* Returns all the notification recipients.
*
* @return the notification recipients
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the notification recipients.
*
*
* 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 NotificationRecipientModelImpl
.
*
*
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @return the range of notification recipients
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the notification recipients.
*
*
* 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 NotificationRecipientModelImpl
.
*
*
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of notification recipients
*/
@Override
public List findAll(
int start, int end,
OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the notification recipients.
*
*
* 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 NotificationRecipientModelImpl
.
*
*
* @param start the lower bound of the range of notification recipients
* @param end the upper bound of the range of notification recipients (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 recipients
*/
@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_NOTIFICATIONRECIPIENT);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_NOTIFICATIONRECIPIENT;
sql = sql.concat(NotificationRecipientModelImpl.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 recipients from the database.
*
*/
@Override
public void removeAll() {
for (NotificationRecipient notificationRecipient : findAll()) {
remove(notificationRecipient);
}
}
/**
* Returns the number of notification recipients.
*
* @return the number of notification recipients
*/
@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_NOTIFICATIONRECIPIENT);
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 "notificationRecipientId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_NOTIFICATIONRECIPIENT;
}
@Override
protected Map getTableColumnsMap() {
return NotificationRecipientModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the notification recipient 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);
_finderPathFetchByClassPK = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByClassPK",
new String[] {Long.class.getName()}, new String[] {"classPK"},
true);
NotificationRecipientUtil.setPersistence(this);
}
@Deactivate
public void deactivate() {
NotificationRecipientUtil.setPersistence(null);
entityCache.removeCache(NotificationRecipientImpl.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_NOTIFICATIONRECIPIENT =
"SELECT notificationRecipient FROM NotificationRecipient notificationRecipient";
private static final String _SQL_SELECT_NOTIFICATIONRECIPIENT_WHERE =
"SELECT notificationRecipient FROM NotificationRecipient notificationRecipient WHERE ";
private static final String _SQL_COUNT_NOTIFICATIONRECIPIENT =
"SELECT COUNT(notificationRecipient) FROM NotificationRecipient notificationRecipient";
private static final String _SQL_COUNT_NOTIFICATIONRECIPIENT_WHERE =
"SELECT COUNT(notificationRecipient) FROM NotificationRecipient notificationRecipient WHERE ";
private static final String _ORDER_BY_ENTITY_ALIAS =
"notificationRecipient.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No NotificationRecipient exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No NotificationRecipient exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
NotificationRecipientPersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"uuid"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
}