com.liferay.marketplace.service.persistence.impl.ModulePersistenceImpl Maven / Gradle / Ivy
Show all versions of com.liferay.marketplace.service
/**
* 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.marketplace.service.persistence.impl;
import com.liferay.marketplace.exception.NoSuchModuleException;
import com.liferay.marketplace.model.Module;
import com.liferay.marketplace.model.ModuleTable;
import com.liferay.marketplace.model.impl.ModuleImpl;
import com.liferay.marketplace.model.impl.ModuleModelImpl;
import com.liferay.marketplace.service.persistence.ModulePersistence;
import com.liferay.marketplace.service.persistence.ModuleUtil;
import com.liferay.marketplace.service.persistence.impl.constants.MarketplacePersistenceConstants;
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.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.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 module service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Ryan Park
* @generated
*/
@Component(service = ModulePersistence.class)
public class ModulePersistenceImpl
extends BasePersistenceImpl implements ModulePersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use ModuleUtil
to access the module persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
ModuleImpl.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 modules where uuid = ?.
*
* @param uuid the uuid
* @return the matching modules
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of matching modules
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching modules
*/
@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 modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@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 (Module module : list) {
if (!uuid.equals(module.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_MODULE_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(ModuleModelImpl.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 module 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 module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByUuid_First(uuid, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the first module 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 module, or null
if a matching module could not be found
*/
@Override
public Module 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 module 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 module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByUuid_Last(uuid, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the last module 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 module, or null
if a matching module could not be found
*/
@Override
public Module 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 modules before and after the current module in the ordered set where uuid = ?.
*
* @param moduleId the primary key of the current module
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module[] findByUuid_PrevAndNext(
long moduleId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
uuid = Objects.toString(uuid, "");
Module module = findByPrimaryKey(moduleId);
Session session = null;
try {
session = openSession();
Module[] array = new ModuleImpl[3];
array[0] = getByUuid_PrevAndNext(
session, module, uuid, orderByComparator, true);
array[1] = module;
array[2] = getByUuid_PrevAndNext(
session, module, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected Module getByUuid_PrevAndNext(
Session session, Module module, 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_MODULE_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(ModuleModelImpl.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(module)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the modules where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (Module module :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(module);
}
}
/**
* Returns the number of modules where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching modules
*/
@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_MODULE_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 = "module.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(module.uuid IS NULL OR module.uuid = '')";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the modules where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching modules
*/
@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 modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of matching modules
*/
@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 modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching modules
*/
@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 modules 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 ModuleModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@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 (Module module : list) {
if (!uuid.equals(module.getUuid()) ||
(companyId != module.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_MODULE_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(ModuleModelImpl.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 module 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 module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByUuid_C_First(uuid, companyId, orderByComparator);
if (module != null) {
return module;
}
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 NoSuchModuleException(sb.toString());
}
/**
* Returns the first module 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 module, or null
if a matching module could not be found
*/
@Override
public Module 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 module 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 module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
if (module != null) {
return module;
}
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 NoSuchModuleException(sb.toString());
}
/**
* Returns the last module 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 module, or null
if a matching module could not be found
*/
@Override
public Module 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 modules before and after the current module in the ordered set where uuid = ? and companyId = ?.
*
* @param moduleId the primary key of the current module
* @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 module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module[] findByUuid_C_PrevAndNext(
long moduleId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
uuid = Objects.toString(uuid, "");
Module module = findByPrimaryKey(moduleId);
Session session = null;
try {
session = openSession();
Module[] array = new ModuleImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, module, uuid, companyId, orderByComparator, true);
array[1] = module;
array[2] = getByUuid_C_PrevAndNext(
session, module, uuid, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected Module getByUuid_C_PrevAndNext(
Session session, Module module, 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_MODULE_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(ModuleModelImpl.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(module)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the modules 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 (Module module :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(module);
}
}
/**
* Returns the number of modules where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching modules
*/
@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_MODULE_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 =
"module.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(module.uuid IS NULL OR module.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"module.companyId = ?";
private FinderPath _finderPathWithPaginationFindByAppId;
private FinderPath _finderPathWithoutPaginationFindByAppId;
private FinderPath _finderPathCountByAppId;
/**
* Returns all the modules where appId = ?.
*
* @param appId the app ID
* @return the matching modules
*/
@Override
public List findByAppId(long appId) {
return findByAppId(appId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the modules where appId = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param appId the app ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of matching modules
*/
@Override
public List findByAppId(long appId, int start, int end) {
return findByAppId(appId, start, end, null);
}
/**
* Returns an ordered range of all the modules where appId = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param appId the app ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching modules
*/
@Override
public List findByAppId(
long appId, int start, int end,
OrderByComparator orderByComparator) {
return findByAppId(appId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the modules where appId = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param appId the app ID
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@Override
public List findByAppId(
long appId, 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 = _finderPathWithoutPaginationFindByAppId;
finderArgs = new Object[] {appId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByAppId;
finderArgs = new Object[] {appId, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Module module : list) {
if (appId != module.getAppId()) {
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_MODULE_WHERE);
sb.append(_FINDER_COLUMN_APPID_APPID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ModuleModelImpl.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(appId);
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 module in the ordered set where appId = ?.
*
* @param appId the app ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByAppId_First(
long appId, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByAppId_First(appId, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("appId=");
sb.append(appId);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the first module in the ordered set where appId = ?.
*
* @param appId the app ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByAppId_First(
long appId, OrderByComparator orderByComparator) {
List list = findByAppId(appId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last module in the ordered set where appId = ?.
*
* @param appId the app ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByAppId_Last(
long appId, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByAppId_Last(appId, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("appId=");
sb.append(appId);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the last module in the ordered set where appId = ?.
*
* @param appId the app ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByAppId_Last(
long appId, OrderByComparator orderByComparator) {
int count = countByAppId(appId);
if (count == 0) {
return null;
}
List list = findByAppId(
appId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the modules before and after the current module in the ordered set where appId = ?.
*
* @param moduleId the primary key of the current module
* @param appId the app ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module[] findByAppId_PrevAndNext(
long moduleId, long appId,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = findByPrimaryKey(moduleId);
Session session = null;
try {
session = openSession();
Module[] array = new ModuleImpl[3];
array[0] = getByAppId_PrevAndNext(
session, module, appId, orderByComparator, true);
array[1] = module;
array[2] = getByAppId_PrevAndNext(
session, module, appId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected Module getByAppId_PrevAndNext(
Session session, Module module, long appId,
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_MODULE_WHERE);
sb.append(_FINDER_COLUMN_APPID_APPID_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(ModuleModelImpl.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(appId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(module)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the modules where appId = ? from the database.
*
* @param appId the app ID
*/
@Override
public void removeByAppId(long appId) {
for (Module module :
findByAppId(
appId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(module);
}
}
/**
* Returns the number of modules where appId = ?.
*
* @param appId the app ID
* @return the number of matching modules
*/
@Override
public int countByAppId(long appId) {
FinderPath finderPath = _finderPathCountByAppId;
Object[] finderArgs = new Object[] {appId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MODULE_WHERE);
sb.append(_FINDER_COLUMN_APPID_APPID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(appId);
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_APPID_APPID_2 =
"module.appId = ?";
private FinderPath _finderPathWithPaginationFindByBundleSymbolicName;
private FinderPath _finderPathWithoutPaginationFindByBundleSymbolicName;
private FinderPath _finderPathCountByBundleSymbolicName;
/**
* Returns all the modules where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @return the matching modules
*/
@Override
public List findByBundleSymbolicName(String bundleSymbolicName) {
return findByBundleSymbolicName(
bundleSymbolicName, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the modules where bundleSymbolicName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param bundleSymbolicName the bundle symbolic name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of matching modules
*/
@Override
public List findByBundleSymbolicName(
String bundleSymbolicName, int start, int end) {
return findByBundleSymbolicName(bundleSymbolicName, start, end, null);
}
/**
* Returns an ordered range of all the modules where bundleSymbolicName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param bundleSymbolicName the bundle symbolic name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching modules
*/
@Override
public List findByBundleSymbolicName(
String bundleSymbolicName, int start, int end,
OrderByComparator orderByComparator) {
return findByBundleSymbolicName(
bundleSymbolicName, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the modules where bundleSymbolicName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param bundleSymbolicName the bundle symbolic name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@Override
public List findByBundleSymbolicName(
String bundleSymbolicName, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
bundleSymbolicName = Objects.toString(bundleSymbolicName, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath =
_finderPathWithoutPaginationFindByBundleSymbolicName;
finderArgs = new Object[] {bundleSymbolicName};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByBundleSymbolicName;
finderArgs = new Object[] {
bundleSymbolicName, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Module module : list) {
if (!bundleSymbolicName.equals(
module.getBundleSymbolicName())) {
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_MODULE_WHERE);
boolean bindBundleSymbolicName = false;
if (bundleSymbolicName.isEmpty()) {
sb.append(
_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_3);
}
else {
bindBundleSymbolicName = true;
sb.append(
_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ModuleModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindBundleSymbolicName) {
queryPos.add(bundleSymbolicName);
}
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 module in the ordered set where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByBundleSymbolicName_First(
String bundleSymbolicName,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByBundleSymbolicName_First(
bundleSymbolicName, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("bundleSymbolicName=");
sb.append(bundleSymbolicName);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the first module in the ordered set where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByBundleSymbolicName_First(
String bundleSymbolicName,
OrderByComparator orderByComparator) {
List list = findByBundleSymbolicName(
bundleSymbolicName, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last module in the ordered set where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByBundleSymbolicName_Last(
String bundleSymbolicName,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByBundleSymbolicName_Last(
bundleSymbolicName, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("bundleSymbolicName=");
sb.append(bundleSymbolicName);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the last module in the ordered set where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByBundleSymbolicName_Last(
String bundleSymbolicName,
OrderByComparator orderByComparator) {
int count = countByBundleSymbolicName(bundleSymbolicName);
if (count == 0) {
return null;
}
List list = findByBundleSymbolicName(
bundleSymbolicName, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the modules before and after the current module in the ordered set where bundleSymbolicName = ?.
*
* @param moduleId the primary key of the current module
* @param bundleSymbolicName the bundle symbolic name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module[] findByBundleSymbolicName_PrevAndNext(
long moduleId, String bundleSymbolicName,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
bundleSymbolicName = Objects.toString(bundleSymbolicName, "");
Module module = findByPrimaryKey(moduleId);
Session session = null;
try {
session = openSession();
Module[] array = new ModuleImpl[3];
array[0] = getByBundleSymbolicName_PrevAndNext(
session, module, bundleSymbolicName, orderByComparator, true);
array[1] = module;
array[2] = getByBundleSymbolicName_PrevAndNext(
session, module, bundleSymbolicName, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected Module getByBundleSymbolicName_PrevAndNext(
Session session, Module module, String bundleSymbolicName,
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_MODULE_WHERE);
boolean bindBundleSymbolicName = false;
if (bundleSymbolicName.isEmpty()) {
sb.append(_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_3);
}
else {
bindBundleSymbolicName = true;
sb.append(_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_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(ModuleModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindBundleSymbolicName) {
queryPos.add(bundleSymbolicName);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(module)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the modules where bundleSymbolicName = ? from the database.
*
* @param bundleSymbolicName the bundle symbolic name
*/
@Override
public void removeByBundleSymbolicName(String bundleSymbolicName) {
for (Module module :
findByBundleSymbolicName(
bundleSymbolicName, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(module);
}
}
/**
* Returns the number of modules where bundleSymbolicName = ?.
*
* @param bundleSymbolicName the bundle symbolic name
* @return the number of matching modules
*/
@Override
public int countByBundleSymbolicName(String bundleSymbolicName) {
bundleSymbolicName = Objects.toString(bundleSymbolicName, "");
FinderPath finderPath = _finderPathCountByBundleSymbolicName;
Object[] finderArgs = new Object[] {bundleSymbolicName};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MODULE_WHERE);
boolean bindBundleSymbolicName = false;
if (bundleSymbolicName.isEmpty()) {
sb.append(
_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_3);
}
else {
bindBundleSymbolicName = true;
sb.append(
_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindBundleSymbolicName) {
queryPos.add(bundleSymbolicName);
}
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_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_2 =
"module.bundleSymbolicName = ?";
private static final String
_FINDER_COLUMN_BUNDLESYMBOLICNAME_BUNDLESYMBOLICNAME_3 =
"(module.bundleSymbolicName IS NULL OR module.bundleSymbolicName = '')";
private FinderPath _finderPathWithPaginationFindByContextName;
private FinderPath _finderPathWithoutPaginationFindByContextName;
private FinderPath _finderPathCountByContextName;
/**
* Returns all the modules where contextName = ?.
*
* @param contextName the context name
* @return the matching modules
*/
@Override
public List findByContextName(String contextName) {
return findByContextName(
contextName, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the modules where contextName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param contextName the context name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of matching modules
*/
@Override
public List findByContextName(
String contextName, int start, int end) {
return findByContextName(contextName, start, end, null);
}
/**
* Returns an ordered range of all the modules where contextName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param contextName the context name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching modules
*/
@Override
public List findByContextName(
String contextName, int start, int end,
OrderByComparator orderByComparator) {
return findByContextName(
contextName, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the modules where contextName = ?.
*
*
* 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 ModuleModelImpl
.
*
*
* @param contextName the context name
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@Override
public List findByContextName(
String contextName, int start, int end,
OrderByComparator orderByComparator, boolean useFinderCache) {
contextName = Objects.toString(contextName, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByContextName;
finderArgs = new Object[] {contextName};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByContextName;
finderArgs = new Object[] {
contextName, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Module module : list) {
if (!contextName.equals(module.getContextName())) {
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_MODULE_WHERE);
boolean bindContextName = false;
if (contextName.isEmpty()) {
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_3);
}
else {
bindContextName = true;
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ModuleModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindContextName) {
queryPos.add(contextName);
}
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 module in the ordered set where contextName = ?.
*
* @param contextName the context name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByContextName_First(
String contextName, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByContextName_First(
contextName, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("contextName=");
sb.append(contextName);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the first module in the ordered set where contextName = ?.
*
* @param contextName the context name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByContextName_First(
String contextName, OrderByComparator orderByComparator) {
List list = findByContextName(
contextName, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last module in the ordered set where contextName = ?.
*
* @param contextName the context name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByContextName_Last(
String contextName, OrderByComparator orderByComparator)
throws NoSuchModuleException {
Module module = fetchByContextName_Last(contextName, orderByComparator);
if (module != null) {
return module;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("contextName=");
sb.append(contextName);
sb.append("}");
throw new NoSuchModuleException(sb.toString());
}
/**
* Returns the last module in the ordered set where contextName = ?.
*
* @param contextName the context name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByContextName_Last(
String contextName, OrderByComparator orderByComparator) {
int count = countByContextName(contextName);
if (count == 0) {
return null;
}
List list = findByContextName(
contextName, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the modules before and after the current module in the ordered set where contextName = ?.
*
* @param moduleId the primary key of the current module
* @param contextName the context name
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module[] findByContextName_PrevAndNext(
long moduleId, String contextName,
OrderByComparator orderByComparator)
throws NoSuchModuleException {
contextName = Objects.toString(contextName, "");
Module module = findByPrimaryKey(moduleId);
Session session = null;
try {
session = openSession();
Module[] array = new ModuleImpl[3];
array[0] = getByContextName_PrevAndNext(
session, module, contextName, orderByComparator, true);
array[1] = module;
array[2] = getByContextName_PrevAndNext(
session, module, contextName, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected Module getByContextName_PrevAndNext(
Session session, Module module, String contextName,
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_MODULE_WHERE);
boolean bindContextName = false;
if (contextName.isEmpty()) {
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_3);
}
else {
bindContextName = true;
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_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(ModuleModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindContextName) {
queryPos.add(contextName);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(module)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the modules where contextName = ? from the database.
*
* @param contextName the context name
*/
@Override
public void removeByContextName(String contextName) {
for (Module module :
findByContextName(
contextName, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(module);
}
}
/**
* Returns the number of modules where contextName = ?.
*
* @param contextName the context name
* @return the number of matching modules
*/
@Override
public int countByContextName(String contextName) {
contextName = Objects.toString(contextName, "");
FinderPath finderPath = _finderPathCountByContextName;
Object[] finderArgs = new Object[] {contextName};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_MODULE_WHERE);
boolean bindContextName = false;
if (contextName.isEmpty()) {
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_3);
}
else {
bindContextName = true;
sb.append(_FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindContextName) {
queryPos.add(contextName);
}
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_CONTEXTNAME_CONTEXTNAME_2 =
"module.contextName = ?";
private static final String _FINDER_COLUMN_CONTEXTNAME_CONTEXTNAME_3 =
"(module.contextName IS NULL OR module.contextName = '')";
private FinderPath _finderPathFetchByA_CN;
private FinderPath _finderPathCountByA_CN;
/**
* Returns the module where appId = ? and contextName = ? or throws a NoSuchModuleException
if it could not be found.
*
* @param appId the app ID
* @param contextName the context name
* @return the matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByA_CN(long appId, String contextName)
throws NoSuchModuleException {
Module module = fetchByA_CN(appId, contextName);
if (module == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("appId=");
sb.append(appId);
sb.append(", contextName=");
sb.append(contextName);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchModuleException(sb.toString());
}
return module;
}
/**
* Returns the module where appId = ? and contextName = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param appId the app ID
* @param contextName the context name
* @return the matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByA_CN(long appId, String contextName) {
return fetchByA_CN(appId, contextName, true);
}
/**
* Returns the module where appId = ? and contextName = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param appId the app ID
* @param contextName the context name
* @param useFinderCache whether to use the finder cache
* @return the matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByA_CN(
long appId, String contextName, boolean useFinderCache) {
contextName = Objects.toString(contextName, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {appId, contextName};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByA_CN, finderArgs, this);
}
if (result instanceof Module) {
Module module = (Module)result;
if ((appId != module.getAppId()) ||
!Objects.equals(contextName, module.getContextName())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_MODULE_WHERE);
sb.append(_FINDER_COLUMN_A_CN_APPID_2);
boolean bindContextName = false;
if (contextName.isEmpty()) {
sb.append(_FINDER_COLUMN_A_CN_CONTEXTNAME_3);
}
else {
bindContextName = true;
sb.append(_FINDER_COLUMN_A_CN_CONTEXTNAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(appId);
if (bindContextName) {
queryPos.add(contextName);
}
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByA_CN, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {appId, contextName};
}
_log.warn(
"ModulePersistenceImpl.fetchByA_CN(long, String, 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.");
}
}
Module module = list.get(0);
result = module;
cacheResult(module);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (Module)result;
}
}
/**
* Removes the module where appId = ? and contextName = ? from the database.
*
* @param appId the app ID
* @param contextName the context name
* @return the module that was removed
*/
@Override
public Module removeByA_CN(long appId, String contextName)
throws NoSuchModuleException {
Module module = findByA_CN(appId, contextName);
return remove(module);
}
/**
* Returns the number of modules where appId = ? and contextName = ?.
*
* @param appId the app ID
* @param contextName the context name
* @return the number of matching modules
*/
@Override
public int countByA_CN(long appId, String contextName) {
contextName = Objects.toString(contextName, "");
FinderPath finderPath = _finderPathCountByA_CN;
Object[] finderArgs = new Object[] {appId, contextName};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_MODULE_WHERE);
sb.append(_FINDER_COLUMN_A_CN_APPID_2);
boolean bindContextName = false;
if (contextName.isEmpty()) {
sb.append(_FINDER_COLUMN_A_CN_CONTEXTNAME_3);
}
else {
bindContextName = true;
sb.append(_FINDER_COLUMN_A_CN_CONTEXTNAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(appId);
if (bindContextName) {
queryPos.add(contextName);
}
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_A_CN_APPID_2 =
"module.appId = ? AND ";
private static final String _FINDER_COLUMN_A_CN_CONTEXTNAME_2 =
"module.contextName = ?";
private static final String _FINDER_COLUMN_A_CN_CONTEXTNAME_3 =
"(module.contextName IS NULL OR module.contextName = '')";
private FinderPath _finderPathFetchByA_BSN_BV;
private FinderPath _finderPathCountByA_BSN_BV;
/**
* Returns the module where appId = ? and bundleSymbolicName = ? and bundleVersion = ? or throws a NoSuchModuleException
if it could not be found.
*
* @param appId the app ID
* @param bundleSymbolicName the bundle symbolic name
* @param bundleVersion the bundle version
* @return the matching module
* @throws NoSuchModuleException if a matching module could not be found
*/
@Override
public Module findByA_BSN_BV(
long appId, String bundleSymbolicName, String bundleVersion)
throws NoSuchModuleException {
Module module = fetchByA_BSN_BV(
appId, bundleSymbolicName, bundleVersion);
if (module == null) {
StringBundler sb = new StringBundler(8);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("appId=");
sb.append(appId);
sb.append(", bundleSymbolicName=");
sb.append(bundleSymbolicName);
sb.append(", bundleVersion=");
sb.append(bundleVersion);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchModuleException(sb.toString());
}
return module;
}
/**
* Returns the module where appId = ? and bundleSymbolicName = ? and bundleVersion = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param appId the app ID
* @param bundleSymbolicName the bundle symbolic name
* @param bundleVersion the bundle version
* @return the matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByA_BSN_BV(
long appId, String bundleSymbolicName, String bundleVersion) {
return fetchByA_BSN_BV(appId, bundleSymbolicName, bundleVersion, true);
}
/**
* Returns the module where appId = ? and bundleSymbolicName = ? and bundleVersion = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param appId the app ID
* @param bundleSymbolicName the bundle symbolic name
* @param bundleVersion the bundle version
* @param useFinderCache whether to use the finder cache
* @return the matching module, or null
if a matching module could not be found
*/
@Override
public Module fetchByA_BSN_BV(
long appId, String bundleSymbolicName, String bundleVersion,
boolean useFinderCache) {
bundleSymbolicName = Objects.toString(bundleSymbolicName, "");
bundleVersion = Objects.toString(bundleVersion, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {
appId, bundleSymbolicName, bundleVersion
};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByA_BSN_BV, finderArgs, this);
}
if (result instanceof Module) {
Module module = (Module)result;
if ((appId != module.getAppId()) ||
!Objects.equals(
bundleSymbolicName, module.getBundleSymbolicName()) ||
!Objects.equals(bundleVersion, module.getBundleVersion())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(5);
sb.append(_SQL_SELECT_MODULE_WHERE);
sb.append(_FINDER_COLUMN_A_BSN_BV_APPID_2);
boolean bindBundleSymbolicName = false;
if (bundleSymbolicName.isEmpty()) {
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_3);
}
else {
bindBundleSymbolicName = true;
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_2);
}
boolean bindBundleVersion = false;
if (bundleVersion.isEmpty()) {
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_3);
}
else {
bindBundleVersion = true;
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(appId);
if (bindBundleSymbolicName) {
queryPos.add(bundleSymbolicName);
}
if (bindBundleVersion) {
queryPos.add(bundleVersion);
}
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByA_BSN_BV, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {
appId, bundleSymbolicName, bundleVersion
};
}
_log.warn(
"ModulePersistenceImpl.fetchByA_BSN_BV(long, String, String, 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.");
}
}
Module module = list.get(0);
result = module;
cacheResult(module);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (Module)result;
}
}
/**
* Removes the module where appId = ? and bundleSymbolicName = ? and bundleVersion = ? from the database.
*
* @param appId the app ID
* @param bundleSymbolicName the bundle symbolic name
* @param bundleVersion the bundle version
* @return the module that was removed
*/
@Override
public Module removeByA_BSN_BV(
long appId, String bundleSymbolicName, String bundleVersion)
throws NoSuchModuleException {
Module module = findByA_BSN_BV(
appId, bundleSymbolicName, bundleVersion);
return remove(module);
}
/**
* Returns the number of modules where appId = ? and bundleSymbolicName = ? and bundleVersion = ?.
*
* @param appId the app ID
* @param bundleSymbolicName the bundle symbolic name
* @param bundleVersion the bundle version
* @return the number of matching modules
*/
@Override
public int countByA_BSN_BV(
long appId, String bundleSymbolicName, String bundleVersion) {
bundleSymbolicName = Objects.toString(bundleSymbolicName, "");
bundleVersion = Objects.toString(bundleVersion, "");
FinderPath finderPath = _finderPathCountByA_BSN_BV;
Object[] finderArgs = new Object[] {
appId, bundleSymbolicName, bundleVersion
};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_COUNT_MODULE_WHERE);
sb.append(_FINDER_COLUMN_A_BSN_BV_APPID_2);
boolean bindBundleSymbolicName = false;
if (bundleSymbolicName.isEmpty()) {
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_3);
}
else {
bindBundleSymbolicName = true;
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_2);
}
boolean bindBundleVersion = false;
if (bundleVersion.isEmpty()) {
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_3);
}
else {
bindBundleVersion = true;
sb.append(_FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(appId);
if (bindBundleSymbolicName) {
queryPos.add(bundleSymbolicName);
}
if (bindBundleVersion) {
queryPos.add(bundleVersion);
}
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_A_BSN_BV_APPID_2 =
"module.appId = ? AND ";
private static final String _FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_2 =
"module.bundleSymbolicName = ? AND ";
private static final String _FINDER_COLUMN_A_BSN_BV_BUNDLESYMBOLICNAME_3 =
"(module.bundleSymbolicName IS NULL OR module.bundleSymbolicName = '') AND ";
private static final String _FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_2 =
"module.bundleVersion = ?";
private static final String _FINDER_COLUMN_A_BSN_BV_BUNDLEVERSION_3 =
"(module.bundleVersion IS NULL OR module.bundleVersion = '')";
public ModulePersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("uuid", "uuid_");
setDBColumnNames(dbColumnNames);
setModelClass(Module.class);
setModelImplClass(ModuleImpl.class);
setModelPKClass(long.class);
setTable(ModuleTable.INSTANCE);
}
/**
* Caches the module in the entity cache if it is enabled.
*
* @param module the module
*/
@Override
public void cacheResult(Module module) {
entityCache.putResult(ModuleImpl.class, module.getPrimaryKey(), module);
finderCache.putResult(
_finderPathFetchByA_CN,
new Object[] {module.getAppId(), module.getContextName()}, module);
finderCache.putResult(
_finderPathFetchByA_BSN_BV,
new Object[] {
module.getAppId(), module.getBundleSymbolicName(),
module.getBundleVersion()
},
module);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the modules in the entity cache if it is enabled.
*
* @param modules the modules
*/
@Override
public void cacheResult(List modules) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(modules.size() > _valueObjectFinderCacheListThreshold))) {
return;
}
for (Module module : modules) {
if (entityCache.getResult(
ModuleImpl.class, module.getPrimaryKey()) == null) {
cacheResult(module);
}
}
}
/**
* Clears the cache for all modules.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(ModuleImpl.class);
finderCache.clearCache(ModuleImpl.class);
}
/**
* Clears the cache for the module.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(Module module) {
entityCache.removeResult(ModuleImpl.class, module);
}
@Override
public void clearCache(List modules) {
for (Module module : modules) {
entityCache.removeResult(ModuleImpl.class, module);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(ModuleImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(ModuleImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(ModuleModelImpl moduleModelImpl) {
Object[] args = new Object[] {
moduleModelImpl.getAppId(), moduleModelImpl.getContextName()
};
finderCache.putResult(_finderPathCountByA_CN, args, Long.valueOf(1));
finderCache.putResult(_finderPathFetchByA_CN, args, moduleModelImpl);
args = new Object[] {
moduleModelImpl.getAppId(), moduleModelImpl.getBundleSymbolicName(),
moduleModelImpl.getBundleVersion()
};
finderCache.putResult(
_finderPathCountByA_BSN_BV, args, Long.valueOf(1));
finderCache.putResult(
_finderPathFetchByA_BSN_BV, args, moduleModelImpl);
}
/**
* Creates a new module with the primary key. Does not add the module to the database.
*
* @param moduleId the primary key for the new module
* @return the new module
*/
@Override
public Module create(long moduleId) {
Module module = new ModuleImpl();
module.setNew(true);
module.setPrimaryKey(moduleId);
String uuid = PortalUUIDUtil.generate();
module.setUuid(uuid);
module.setCompanyId(CompanyThreadLocal.getCompanyId());
return module;
}
/**
* Removes the module with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param moduleId the primary key of the module
* @return the module that was removed
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module remove(long moduleId) throws NoSuchModuleException {
return remove((Serializable)moduleId);
}
/**
* Removes the module with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the module
* @return the module that was removed
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module remove(Serializable primaryKey) throws NoSuchModuleException {
Session session = null;
try {
session = openSession();
Module module = (Module)session.get(ModuleImpl.class, primaryKey);
if (module == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchModuleException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(module);
}
catch (NoSuchModuleException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected Module removeImpl(Module module) {
Session session = null;
try {
session = openSession();
if (!session.contains(module)) {
module = (Module)session.get(
ModuleImpl.class, module.getPrimaryKeyObj());
}
if (module != null) {
session.delete(module);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (module != null) {
clearCache(module);
}
return module;
}
@Override
public Module updateImpl(Module module) {
boolean isNew = module.isNew();
if (!(module instanceof ModuleModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(module.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(module);
throw new IllegalArgumentException(
"Implement ModelWrapper in module proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom Module implementation " +
module.getClass());
}
ModuleModelImpl moduleModelImpl = (ModuleModelImpl)module;
if (Validator.isNull(module.getUuid())) {
String uuid = PortalUUIDUtil.generate();
module.setUuid(uuid);
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(module);
}
else {
module = (Module)session.merge(module);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(ModuleImpl.class, moduleModelImpl, false, true);
cacheUniqueFindersCache(moduleModelImpl);
if (isNew) {
module.setNew(false);
}
module.resetOriginalValues();
return module;
}
/**
* Returns the module 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 module
* @return the module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module findByPrimaryKey(Serializable primaryKey)
throws NoSuchModuleException {
Module module = fetchByPrimaryKey(primaryKey);
if (module == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchModuleException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return module;
}
/**
* Returns the module with the primary key or throws a NoSuchModuleException
if it could not be found.
*
* @param moduleId the primary key of the module
* @return the module
* @throws NoSuchModuleException if a module with the primary key could not be found
*/
@Override
public Module findByPrimaryKey(long moduleId) throws NoSuchModuleException {
return findByPrimaryKey((Serializable)moduleId);
}
/**
* Returns the module with the primary key or returns null
if it could not be found.
*
* @param moduleId the primary key of the module
* @return the module, or null
if a module with the primary key could not be found
*/
@Override
public Module fetchByPrimaryKey(long moduleId) {
return fetchByPrimaryKey((Serializable)moduleId);
}
/**
* Returns all the modules.
*
* @return the modules
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the modules.
*
*
* 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 ModuleModelImpl
.
*
*
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @return the range of modules
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the modules.
*
*
* 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 ModuleModelImpl
.
*
*
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of modules
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the modules.
*
*
* 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 ModuleModelImpl
.
*
*
* @param start the lower bound of the range of modules
* @param end the upper bound of the range of modules (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 modules
*/
@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_MODULE);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_MODULE;
sql = sql.concat(ModuleModelImpl.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 modules from the database.
*
*/
@Override
public void removeAll() {
for (Module module : findAll()) {
remove(module);
}
}
/**
* Returns the number of modules.
*
* @return the number of modules
*/
@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_MODULE);
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 "moduleId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_MODULE;
}
@Override
protected Map getTableColumnsMap() {
return ModuleModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the module 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);
_finderPathWithPaginationFindByAppId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByAppId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"appId"}, true);
_finderPathWithoutPaginationFindByAppId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByAppId",
new String[] {Long.class.getName()}, new String[] {"appId"}, true);
_finderPathCountByAppId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByAppId",
new String[] {Long.class.getName()}, new String[] {"appId"}, false);
_finderPathWithPaginationFindByBundleSymbolicName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByBundleSymbolicName",
new String[] {
String.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"bundleSymbolicName"}, true);
_finderPathWithoutPaginationFindByBundleSymbolicName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
"findByBundleSymbolicName", new String[] {String.class.getName()},
new String[] {"bundleSymbolicName"}, true);
_finderPathCountByBundleSymbolicName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
"countByBundleSymbolicName", new String[] {String.class.getName()},
new String[] {"bundleSymbolicName"}, false);
_finderPathWithPaginationFindByContextName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByContextName",
new String[] {
String.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"contextName"}, true);
_finderPathWithoutPaginationFindByContextName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByContextName",
new String[] {String.class.getName()}, new String[] {"contextName"},
true);
_finderPathCountByContextName = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByContextName",
new String[] {String.class.getName()}, new String[] {"contextName"},
false);
_finderPathFetchByA_CN = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByA_CN",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"appId", "contextName"}, true);
_finderPathCountByA_CN = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_CN",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"appId", "contextName"}, false);
_finderPathFetchByA_BSN_BV = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByA_BSN_BV",
new String[] {
Long.class.getName(), String.class.getName(),
String.class.getName()
},
new String[] {"appId", "bundleSymbolicName", "bundleVersion"},
true);
_finderPathCountByA_BSN_BV = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByA_BSN_BV",
new String[] {
Long.class.getName(), String.class.getName(),
String.class.getName()
},
new String[] {"appId", "bundleSymbolicName", "bundleVersion"},
false);
ModuleUtil.setPersistence(this);
}
@Deactivate
public void deactivate() {
ModuleUtil.setPersistence(null);
entityCache.removeCache(ModuleImpl.class.getName());
}
@Override
@Reference(
target = MarketplacePersistenceConstants.SERVICE_CONFIGURATION_FILTER,
unbind = "-"
)
public void setConfiguration(Configuration configuration) {
}
@Override
@Reference(
target = MarketplacePersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
@Override
@Reference(
target = MarketplacePersistenceConstants.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_MODULE =
"SELECT module FROM Module module";
private static final String _SQL_SELECT_MODULE_WHERE =
"SELECT module FROM Module module WHERE ";
private static final String _SQL_COUNT_MODULE =
"SELECT COUNT(module) FROM Module module";
private static final String _SQL_COUNT_MODULE_WHERE =
"SELECT COUNT(module) FROM Module module WHERE ";
private static final String _ORDER_BY_ENTITY_ALIAS = "module.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No Module exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No Module exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
ModulePersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"uuid"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
}