com.liferay.account.service.persistence.impl.AccountEntryPersistenceImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.account.service.persistence.impl;
import com.liferay.account.exception.NoSuchEntryException;
import com.liferay.account.model.AccountEntry;
import com.liferay.account.model.AccountEntryTable;
import com.liferay.account.model.impl.AccountEntryImpl;
import com.liferay.account.model.impl.AccountEntryModelImpl;
import com.liferay.account.service.persistence.AccountEntryPersistence;
import com.liferay.account.service.persistence.impl.constants.AccountPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.BasePersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the account entry service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Brian Wing Shun Chan
* @generated
*/
@Component(service = {AccountEntryPersistence.class, BasePersistence.class})
public class AccountEntryPersistenceImpl
extends BasePersistenceImpl
implements AccountEntryPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use AccountEntryUtil
to access the account entry persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
AccountEntryImpl.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 _finderPathWithPaginationFindByCompanyId;
private FinderPath _finderPathWithoutPaginationFindByCompanyId;
private FinderPath _finderPathCountByCompanyId;
/**
* Returns all the account entries where companyId = ?.
*
* @param companyId the company ID
* @return the matching account entries
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the account entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByCompanyId(companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the account entries where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching account entries
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByCompanyId;
finderArgs = new Object[] {companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCompanyId;
finderArgs = new Object[] {
companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (AccountEntry accountEntry : list) {
if (companyId != accountEntry.getCompanyId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first account entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByCompanyId_First(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByCompanyId_First(
companyId, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first account entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByCompanyId_First(
long companyId, OrderByComparator orderByComparator) {
List list = findByCompanyId(
companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last account entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByCompanyId_Last(
long companyId, OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByCompanyId_Last(
companyId, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last account entry in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByCompanyId_Last(
long companyId, OrderByComparator orderByComparator) {
int count = countByCompanyId(companyId);
if (count == 0) {
return null;
}
List list = findByCompanyId(
companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the account entries before and after the current account entry in the ordered set where companyId = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] findByCompanyId_PrevAndNext(
long accountEntryId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = getByCompanyId_PrevAndNext(
session, accountEntry, companyId, orderByComparator, true);
array[1] = accountEntry;
array[2] = getByCompanyId_PrevAndNext(
session, accountEntry, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry getByCompanyId_PrevAndNext(
Session session, AccountEntry accountEntry, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the account entries that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the matching account entries that the user has permission to view
*/
@Override
public List filterFindByCompanyId(long companyId) {
return filterFindByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries that the user has permission to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end) {
return filterFindByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the account entries that the user has permissions to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId(companyId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the account entries before and after the current account entry in the ordered set of account entries that the user has permission to view where companyId = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] filterFindByCompanyId_PrevAndNext(
long accountEntryId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId_PrevAndNext(
accountEntryId, companyId, orderByComparator);
}
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = filterGetByCompanyId_PrevAndNext(
session, accountEntry, companyId, orderByComparator, true);
array[1] = accountEntry;
array[2] = filterGetByCompanyId_PrevAndNext(
session, accountEntry, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry filterGetByCompanyId_PrevAndNext(
Session session, AccountEntry accountEntry, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the account entries where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (AccountEntry accountEntry :
findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(accountEntry);
}
}
/**
* Returns the number of account entries where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching account entries
*/
@Override
public int countByCompanyId(long companyId) {
FinderPath finderPath = _finderPathCountByCompanyId;
Object[] finderArgs = new Object[] {companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of account entries that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching account entries that the user has permission to view
*/
@Override
public int filterCountByCompanyId(long companyId) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByCompanyId(companyId);
}
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 =
"accountEntry.companyId = ?";
private FinderPath _finderPathWithPaginationFindByC_S;
private FinderPath _finderPathWithoutPaginationFindByC_S;
private FinderPath _finderPathCountByC_S;
/**
* Returns all the account entries where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the matching account entries
*/
@Override
public List findByC_S(long companyId, int status) {
return findByC_S(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries
*/
@Override
public List findByC_S(
long companyId, int status, int start, int end) {
return findByC_S(companyId, status, start, end, null);
}
/**
* Returns an ordered range of all the account entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries
*/
@Override
public List findByC_S(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator) {
return findByC_S(
companyId, status, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the account entries where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching account entries
*/
@Override
public List findByC_S(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByC_S;
finderArgs = new Object[] {companyId, status};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByC_S;
finderArgs = new Object[] {
companyId, status, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (AccountEntry accountEntry : list) {
if ((companyId != accountEntry.getCompanyId()) ||
(status != accountEntry.getStatus())) {
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_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first account entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByC_S_First(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByC_S_First(
companyId, status, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first account entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByC_S_First(
long companyId, int status,
OrderByComparator orderByComparator) {
List list = findByC_S(
companyId, status, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last account entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByC_S_Last(
long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByC_S_Last(
companyId, status, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", status=");
sb.append(status);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last account entry in the ordered set where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByC_S_Last(
long companyId, int status,
OrderByComparator orderByComparator) {
int count = countByC_S(companyId, status);
if (count == 0) {
return null;
}
List list = findByC_S(
companyId, status, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the account entries before and after the current account entry in the ordered set where companyId = ? and status = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] findByC_S_PrevAndNext(
long accountEntryId, long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = getByC_S_PrevAndNext(
session, accountEntry, companyId, status, orderByComparator,
true);
array[1] = accountEntry;
array[2] = getByC_S_PrevAndNext(
session, accountEntry, companyId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry getByC_S_PrevAndNext(
Session session, AccountEntry accountEntry, long companyId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the account entries that the user has permission to view where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the matching account entries that the user has permission to view
*/
@Override
public List filterFindByC_S(long companyId, int status) {
return filterFindByC_S(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries that the user has permission to view where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByC_S(
long companyId, int status, int start, int end) {
return filterFindByC_S(companyId, status, start, end, null);
}
/**
* Returns an ordered range of all the account entries that the user has permissions to view where companyId = ? and status = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param companyId the company ID
* @param status the status
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByC_S(
long companyId, int status, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_S(companyId, status, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(status);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the account entries before and after the current account entry in the ordered set of account entries that the user has permission to view where companyId = ? and status = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param companyId the company ID
* @param status the status
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] filterFindByC_S_PrevAndNext(
long accountEntryId, long companyId, int status,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByC_S_PrevAndNext(
accountEntryId, companyId, status, orderByComparator);
}
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = filterGetByC_S_PrevAndNext(
session, accountEntry, companyId, status, orderByComparator,
true);
array[1] = accountEntry;
array[2] = filterGetByC_S_PrevAndNext(
session, accountEntry, companyId, status, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry filterGetByC_S_PrevAndNext(
Session session, AccountEntry accountEntry, long companyId, int status,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(status);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the account entries where companyId = ? and status = ? from the database.
*
* @param companyId the company ID
* @param status the status
*/
@Override
public void removeByC_S(long companyId, int status) {
for (AccountEntry accountEntry :
findByC_S(
companyId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(accountEntry);
}
}
/**
* Returns the number of account entries where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the number of matching account entries
*/
@Override
public int countByC_S(long companyId, int status) {
FinderPath finderPath = _finderPathCountByC_S;
Object[] finderArgs = new Object[] {companyId, status};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
queryPos.add(status);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of account entries that the user has permission to view where companyId = ? and status = ?.
*
* @param companyId the company ID
* @param status the status
* @return the number of matching account entries that the user has permission to view
*/
@Override
public int filterCountByC_S(long companyId, int status) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByC_S(companyId, status);
}
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_S_COMPANYID_2);
sb.append(_FINDER_COLUMN_C_S_STATUS_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
queryPos.add(status);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_C_S_COMPANYID_2 =
"accountEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_S_STATUS_2 =
"accountEntry.status = ?";
private FinderPath _finderPathWithPaginationFindByU_T;
private FinderPath _finderPathWithoutPaginationFindByU_T;
private FinderPath _finderPathCountByU_T;
/**
* Returns all the account entries where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the matching account entries
*/
@Override
public List findByU_T(long userId, String type) {
return findByU_T(
userId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries where userId = ? and type = ?.
*
*
* 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 AccountEntryModelImpl
.
*
*
* @param userId the user ID
* @param type the type
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries
*/
@Override
public List findByU_T(
long userId, String type, int start, int end) {
return findByU_T(userId, type, start, end, null);
}
/**
* Returns an ordered range of all the account entries where userId = ? and type = ?.
*
*
* 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 AccountEntryModelImpl
.
*
*
* @param userId the user ID
* @param type the type
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries
*/
@Override
public List findByU_T(
long userId, String type, int start, int end,
OrderByComparator orderByComparator) {
return findByU_T(userId, type, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the account entries where userId = ? and type = ?.
*
*
* 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 AccountEntryModelImpl
.
*
*
* @param userId the user ID
* @param type the type
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching account entries
*/
@Override
public List findByU_T(
long userId, String type, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
type = Objects.toString(type, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByU_T;
finderArgs = new Object[] {userId, type};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByU_T;
finderArgs = new Object[] {
userId, type, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
if ((list != null) && !list.isEmpty()) {
for (AccountEntry accountEntry : list) {
if ((userId != accountEntry.getUserId()) ||
!type.equals(accountEntry.getType())) {
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_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(AccountEntryModelImpl.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(userId);
if (bindType) {
queryPos.add(type);
}
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 account entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByU_T_First(
long userId, String type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByU_T_First(
userId, type, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append(", type=");
sb.append(type);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the first account entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByU_T_First(
long userId, String type,
OrderByComparator orderByComparator) {
List list = findByU_T(
userId, type, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last account entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByU_T_Last(
long userId, String type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByU_T_Last(
userId, type, orderByComparator);
if (accountEntry != null) {
return accountEntry;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("userId=");
sb.append(userId);
sb.append(", type=");
sb.append(type);
sb.append("}");
throw new NoSuchEntryException(sb.toString());
}
/**
* Returns the last account entry in the ordered set where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByU_T_Last(
long userId, String type,
OrderByComparator orderByComparator) {
int count = countByU_T(userId, type);
if (count == 0) {
return null;
}
List list = findByU_T(
userId, type, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the account entries before and after the current account entry in the ordered set where userId = ? and type = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] findByU_T_PrevAndNext(
long accountEntryId, long userId, String type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
type = Objects.toString(type, "");
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = getByU_T_PrevAndNext(
session, accountEntry, userId, type, orderByComparator, true);
array[1] = accountEntry;
array[2] = getByU_T_PrevAndNext(
session, accountEntry, userId, type, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry getByU_T_PrevAndNext(
Session session, AccountEntry accountEntry, long userId, String type,
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_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_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(AccountEntryModelImpl.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(userId);
if (bindType) {
queryPos.add(type);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the account entries that the user has permission to view where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the matching account entries that the user has permission to view
*/
@Override
public List filterFindByU_T(long userId, String type) {
return filterFindByU_T(
userId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries that the user has permission to view where userId = ? and type = ?.
*
*
* 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 AccountEntryModelImpl
.
*
*
* @param userId the user ID
* @param type the type
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByU_T(
long userId, String type, int start, int end) {
return filterFindByU_T(userId, type, start, end, null);
}
/**
* Returns an ordered range of all the account entries that the user has permissions to view where userId = ? and type = ?.
*
*
* 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 AccountEntryModelImpl
.
*
*
* @param userId the user ID
* @param type the type
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching account entries that the user has permission to view
*/
@Override
public List filterFindByU_T(
long userId, String type, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByU_T(userId, type, start, end, orderByComparator);
}
type = Objects.toString(type, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3_SQL);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(userId);
if (bindType) {
queryPos.add(type);
}
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the account entries before and after the current account entry in the ordered set of account entries that the user has permission to view where userId = ? and type = ?.
*
* @param accountEntryId the primary key of the current account entry
* @param userId the user ID
* @param type the type
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry[] filterFindByU_T_PrevAndNext(
long accountEntryId, long userId, String type,
OrderByComparator orderByComparator)
throws NoSuchEntryException {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByU_T_PrevAndNext(
accountEntryId, userId, type, orderByComparator);
}
type = Objects.toString(type, "");
AccountEntry accountEntry = findByPrimaryKey(accountEntryId);
Session session = null;
try {
session = openSession();
AccountEntry[] array = new AccountEntryImpl[3];
array[0] = filterGetByU_T_PrevAndNext(
session, accountEntry, userId, type, orderByComparator, true);
array[1] = accountEntry;
array[2] = filterGetByU_T_PrevAndNext(
session, accountEntry, userId, type, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected AccountEntry filterGetByU_T_PrevAndNext(
Session session, AccountEntry accountEntry, long userId, String type,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3_SQL);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(AccountEntryModelImpl.ORDER_BY_JPQL);
}
else {
sb.append(AccountEntryModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, AccountEntryImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, AccountEntryImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(userId);
if (bindType) {
queryPos.add(type);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(accountEntry)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the account entries where userId = ? and type = ? from the database.
*
* @param userId the user ID
* @param type the type
*/
@Override
public void removeByU_T(long userId, String type) {
for (AccountEntry accountEntry :
findByU_T(
userId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(accountEntry);
}
}
/**
* Returns the number of account entries where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the number of matching account entries
*/
@Override
public int countByU_T(long userId, String type) {
type = Objects.toString(type, "");
FinderPath finderPath = _finderPathCountByU_T;
Object[] finderArgs = new Object[] {userId, type};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(userId);
if (bindType) {
queryPos.add(type);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of account entries that the user has permission to view where userId = ? and type = ?.
*
* @param userId the user ID
* @param type the type
* @return the number of matching account entries that the user has permission to view
*/
@Override
public int filterCountByU_T(long userId, String type) {
if (!InlineSQLHelperUtil.isEnabled()) {
return countByU_T(userId, type);
}
type = Objects.toString(type, "");
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_U_T_USERID_2);
boolean bindType = false;
if (type.isEmpty()) {
sb.append(_FINDER_COLUMN_U_T_TYPE_3_SQL);
}
else {
bindType = true;
sb.append(_FINDER_COLUMN_U_T_TYPE_2_SQL);
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), AccountEntry.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(userId);
if (bindType) {
queryPos.add(type);
}
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_U_T_USERID_2 =
"accountEntry.userId = ? AND ";
private static final String _FINDER_COLUMN_U_T_TYPE_2 =
"accountEntry.type = ?";
private static final String _FINDER_COLUMN_U_T_TYPE_3 =
"(accountEntry.type IS NULL OR accountEntry.type = '')";
private static final String _FINDER_COLUMN_U_T_TYPE_2_SQL =
"accountEntry.type_ = ?";
private static final String _FINDER_COLUMN_U_T_TYPE_3_SQL =
"(accountEntry.type_ IS NULL OR accountEntry.type_ = '')";
private FinderPath _finderPathFetchByC_ERC;
private FinderPath _finderPathCountByC_ERC;
/**
* Returns the account entry where companyId = ? and externalReferenceCode = ? or throws a NoSuchEntryException
if it could not be found.
*
* @param companyId the company ID
* @param externalReferenceCode the external reference code
* @return the matching account entry
* @throws NoSuchEntryException if a matching account entry could not be found
*/
@Override
public AccountEntry findByC_ERC(
long companyId, String externalReferenceCode)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByC_ERC(
companyId, externalReferenceCode);
if (accountEntry == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", externalReferenceCode=");
sb.append(externalReferenceCode);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchEntryException(sb.toString());
}
return accountEntry;
}
/**
* Returns the account entry where companyId = ? and externalReferenceCode = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param companyId the company ID
* @param externalReferenceCode the external reference code
* @return the matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByC_ERC(
long companyId, String externalReferenceCode) {
return fetchByC_ERC(companyId, externalReferenceCode, true);
}
/**
* Returns the account entry where companyId = ? and externalReferenceCode = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param companyId the company ID
* @param externalReferenceCode the external reference code
* @param useFinderCache whether to use the finder cache
* @return the matching account entry, or null
if a matching account entry could not be found
*/
@Override
public AccountEntry fetchByC_ERC(
long companyId, String externalReferenceCode, boolean useFinderCache) {
externalReferenceCode = Objects.toString(externalReferenceCode, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {companyId, externalReferenceCode};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(_finderPathFetchByC_ERC, finderArgs);
}
if (result instanceof AccountEntry) {
AccountEntry accountEntry = (AccountEntry)result;
if ((companyId != accountEntry.getCompanyId()) ||
!Objects.equals(
externalReferenceCode,
accountEntry.getExternalReferenceCode())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_ERC_COMPANYID_2);
boolean bindExternalReferenceCode = false;
if (externalReferenceCode.isEmpty()) {
sb.append(_FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_3);
}
else {
bindExternalReferenceCode = true;
sb.append(_FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (bindExternalReferenceCode) {
queryPos.add(externalReferenceCode);
}
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByC_ERC, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {
companyId, externalReferenceCode
};
}
_log.warn(
"AccountEntryPersistenceImpl.fetchByC_ERC(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.");
}
}
AccountEntry accountEntry = list.get(0);
result = accountEntry;
cacheResult(accountEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (AccountEntry)result;
}
}
/**
* Removes the account entry where companyId = ? and externalReferenceCode = ? from the database.
*
* @param companyId the company ID
* @param externalReferenceCode the external reference code
* @return the account entry that was removed
*/
@Override
public AccountEntry removeByC_ERC(
long companyId, String externalReferenceCode)
throws NoSuchEntryException {
AccountEntry accountEntry = findByC_ERC(
companyId, externalReferenceCode);
return remove(accountEntry);
}
/**
* Returns the number of account entries where companyId = ? and externalReferenceCode = ?.
*
* @param companyId the company ID
* @param externalReferenceCode the external reference code
* @return the number of matching account entries
*/
@Override
public int countByC_ERC(long companyId, String externalReferenceCode) {
externalReferenceCode = Objects.toString(externalReferenceCode, "");
FinderPath finderPath = _finderPathCountByC_ERC;
Object[] finderArgs = new Object[] {companyId, externalReferenceCode};
Long count = (Long)finderCache.getResult(finderPath, finderArgs);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_ACCOUNTENTRY_WHERE);
sb.append(_FINDER_COLUMN_C_ERC_COMPANYID_2);
boolean bindExternalReferenceCode = false;
if (externalReferenceCode.isEmpty()) {
sb.append(_FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_3);
}
else {
bindExternalReferenceCode = true;
sb.append(_FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (bindExternalReferenceCode) {
queryPos.add(externalReferenceCode);
}
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_C_ERC_COMPANYID_2 =
"accountEntry.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_2 =
"accountEntry.externalReferenceCode = ?";
private static final String _FINDER_COLUMN_C_ERC_EXTERNALREFERENCECODE_3 =
"(accountEntry.externalReferenceCode IS NULL OR accountEntry.externalReferenceCode = '')";
public AccountEntryPersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("type", "type_");
setDBColumnNames(dbColumnNames);
setModelClass(AccountEntry.class);
setModelImplClass(AccountEntryImpl.class);
setModelPKClass(long.class);
setTable(AccountEntryTable.INSTANCE);
}
/**
* Caches the account entry in the entity cache if it is enabled.
*
* @param accountEntry the account entry
*/
@Override
public void cacheResult(AccountEntry accountEntry) {
entityCache.putResult(
AccountEntryImpl.class, accountEntry.getPrimaryKey(), accountEntry);
finderCache.putResult(
_finderPathFetchByC_ERC,
new Object[] {
accountEntry.getCompanyId(),
accountEntry.getExternalReferenceCode()
},
accountEntry);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the account entries in the entity cache if it is enabled.
*
* @param accountEntries the account entries
*/
@Override
public void cacheResult(List accountEntries) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(accountEntries.size() > _valueObjectFinderCacheListThreshold))) {
return;
}
for (AccountEntry accountEntry : accountEntries) {
if (entityCache.getResult(
AccountEntryImpl.class, accountEntry.getPrimaryKey()) ==
null) {
cacheResult(accountEntry);
}
}
}
/**
* Clears the cache for all account entries.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(AccountEntryImpl.class);
finderCache.clearCache(AccountEntryImpl.class);
}
/**
* Clears the cache for the account entry.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(AccountEntry accountEntry) {
entityCache.removeResult(AccountEntryImpl.class, accountEntry);
}
@Override
public void clearCache(List accountEntries) {
for (AccountEntry accountEntry : accountEntries) {
entityCache.removeResult(AccountEntryImpl.class, accountEntry);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(AccountEntryImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(AccountEntryImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(
AccountEntryModelImpl accountEntryModelImpl) {
Object[] args = new Object[] {
accountEntryModelImpl.getCompanyId(),
accountEntryModelImpl.getExternalReferenceCode()
};
finderCache.putResult(_finderPathCountByC_ERC, args, Long.valueOf(1));
finderCache.putResult(
_finderPathFetchByC_ERC, args, accountEntryModelImpl);
}
/**
* Creates a new account entry with the primary key. Does not add the account entry to the database.
*
* @param accountEntryId the primary key for the new account entry
* @return the new account entry
*/
@Override
public AccountEntry create(long accountEntryId) {
AccountEntry accountEntry = new AccountEntryImpl();
accountEntry.setNew(true);
accountEntry.setPrimaryKey(accountEntryId);
accountEntry.setCompanyId(CompanyThreadLocal.getCompanyId());
return accountEntry;
}
/**
* Removes the account entry with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param accountEntryId the primary key of the account entry
* @return the account entry that was removed
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry remove(long accountEntryId)
throws NoSuchEntryException {
return remove((Serializable)accountEntryId);
}
/**
* Removes the account entry with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the account entry
* @return the account entry that was removed
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry remove(Serializable primaryKey)
throws NoSuchEntryException {
Session session = null;
try {
session = openSession();
AccountEntry accountEntry = (AccountEntry)session.get(
AccountEntryImpl.class, primaryKey);
if (accountEntry == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchEntryException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(accountEntry);
}
catch (NoSuchEntryException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected AccountEntry removeImpl(AccountEntry accountEntry) {
Session session = null;
try {
session = openSession();
if (!session.contains(accountEntry)) {
accountEntry = (AccountEntry)session.get(
AccountEntryImpl.class, accountEntry.getPrimaryKeyObj());
}
if (accountEntry != null) {
session.delete(accountEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (accountEntry != null) {
clearCache(accountEntry);
}
return accountEntry;
}
@Override
public AccountEntry updateImpl(AccountEntry accountEntry) {
boolean isNew = accountEntry.isNew();
if (!(accountEntry instanceof AccountEntryModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(accountEntry.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(
accountEntry);
throw new IllegalArgumentException(
"Implement ModelWrapper in accountEntry proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom AccountEntry implementation " +
accountEntry.getClass());
}
AccountEntryModelImpl accountEntryModelImpl =
(AccountEntryModelImpl)accountEntry;
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (accountEntry.getCreateDate() == null)) {
if (serviceContext == null) {
accountEntry.setCreateDate(date);
}
else {
accountEntry.setCreateDate(serviceContext.getCreateDate(date));
}
}
if (!accountEntryModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
accountEntry.setModifiedDate(date);
}
else {
accountEntry.setModifiedDate(
serviceContext.getModifiedDate(date));
}
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(accountEntry);
}
else {
accountEntry = (AccountEntry)session.merge(accountEntry);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(
AccountEntryImpl.class, accountEntryModelImpl, false, true);
cacheUniqueFindersCache(accountEntryModelImpl);
if (isNew) {
accountEntry.setNew(false);
}
accountEntry.resetOriginalValues();
return accountEntry;
}
/**
* Returns the account entry with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException
if it could not be found.
*
* @param primaryKey the primary key of the account entry
* @return the account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry findByPrimaryKey(Serializable primaryKey)
throws NoSuchEntryException {
AccountEntry accountEntry = fetchByPrimaryKey(primaryKey);
if (accountEntry == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchEntryException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return accountEntry;
}
/**
* Returns the account entry with the primary key or throws a NoSuchEntryException
if it could not be found.
*
* @param accountEntryId the primary key of the account entry
* @return the account entry
* @throws NoSuchEntryException if a account entry with the primary key could not be found
*/
@Override
public AccountEntry findByPrimaryKey(long accountEntryId)
throws NoSuchEntryException {
return findByPrimaryKey((Serializable)accountEntryId);
}
/**
* Returns the account entry with the primary key or returns null
if it could not be found.
*
* @param accountEntryId the primary key of the account entry
* @return the account entry, or null
if a account entry with the primary key could not be found
*/
@Override
public AccountEntry fetchByPrimaryKey(long accountEntryId) {
return fetchByPrimaryKey((Serializable)accountEntryId);
}
/**
* Returns all the account entries.
*
* @return the account entries
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the account entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @return the range of account entries
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the account entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of account entries
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the account entries.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from AccountEntryModelImpl
.
*
*
* @param start the lower bound of the range of account entries
* @param end the upper bound of the range of account entries (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of account entries
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(
2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_ACCOUNTENTRY);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_ACCOUNTENTRY;
sql = sql.concat(AccountEntryModelImpl.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 account entries from the database.
*
*/
@Override
public void removeAll() {
for (AccountEntry accountEntry : findAll()) {
remove(accountEntry);
}
}
/**
* Returns the number of account entries.
*
* @return the number of account entries
*/
@Override
public int countAll() {
Long count = (Long)finderCache.getResult(
_finderPathCountAll, FINDER_ARGS_EMPTY);
if (count == null) {
Session session = null;
try {
session = openSession();
Query query = session.createQuery(_SQL_COUNT_ACCOUNTENTRY);
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 "accountEntryId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_ACCOUNTENTRY;
}
@Override
protected Map getTableColumnsMap() {
return AccountEntryModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the account entry persistence.
*/
@Activate
public void activate() {
_valueObjectFinderCacheListThreshold = GetterUtil.getInteger(
PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD));
_finderPathWithPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathWithoutPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathCountAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
new String[0], new String[0], false);
_finderPathWithPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"companyId"}, true);
_finderPathWithoutPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
true);
_finderPathCountByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
false);
_finderPathWithPaginationFindByC_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"companyId", "status"}, true);
_finderPathWithoutPaginationFindByC_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
new String[] {Long.class.getName(), Integer.class.getName()},
new String[] {"companyId", "status"}, true);
_finderPathCountByC_S = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
new String[] {Long.class.getName(), Integer.class.getName()},
new String[] {"companyId", "status"}, false);
_finderPathWithPaginationFindByU_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU_T",
new String[] {
Long.class.getName(), String.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"userId", "type_"}, true);
_finderPathWithoutPaginationFindByU_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU_T",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"userId", "type_"}, true);
_finderPathCountByU_T = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU_T",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"userId", "type_"}, false);
_finderPathFetchByC_ERC = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByC_ERC",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"companyId", "externalReferenceCode"}, true);
_finderPathCountByC_ERC = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_ERC",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"companyId", "externalReferenceCode"}, false);
}
@Deactivate
public void deactivate() {
entityCache.removeCache(AccountEntryImpl.class.getName());
}
@Override
@Reference(
target = AccountPersistenceConstants.SERVICE_CONFIGURATION_FILTER,
unbind = "-"
)
public void setConfiguration(Configuration configuration) {
}
@Override
@Reference(
target = AccountPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
@Override
@Reference(
target = AccountPersistenceConstants.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_ACCOUNTENTRY =
"SELECT accountEntry FROM AccountEntry accountEntry";
private static final String _SQL_SELECT_ACCOUNTENTRY_WHERE =
"SELECT accountEntry FROM AccountEntry accountEntry WHERE ";
private static final String _SQL_COUNT_ACCOUNTENTRY =
"SELECT COUNT(accountEntry) FROM AccountEntry accountEntry";
private static final String _SQL_COUNT_ACCOUNTENTRY_WHERE =
"SELECT COUNT(accountEntry) FROM AccountEntry accountEntry WHERE ";
private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN =
"accountEntry.accountEntryId";
private static final String _FILTER_SQL_SELECT_ACCOUNTENTRY_WHERE =
"SELECT DISTINCT {accountEntry.*} FROM AccountEntry accountEntry WHERE ";
private static final String
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_1 =
"SELECT {AccountEntry.*} FROM (SELECT DISTINCT accountEntry.accountEntryId FROM AccountEntry accountEntry WHERE ";
private static final String
_FILTER_SQL_SELECT_ACCOUNTENTRY_NO_INLINE_DISTINCT_WHERE_2 =
") TEMP_TABLE INNER JOIN AccountEntry ON TEMP_TABLE.accountEntryId = AccountEntry.accountEntryId";
private static final String _FILTER_SQL_COUNT_ACCOUNTENTRY_WHERE =
"SELECT COUNT(DISTINCT accountEntry.accountEntryId) AS COUNT_VALUE FROM AccountEntry accountEntry WHERE ";
private static final String _FILTER_ENTITY_ALIAS = "accountEntry";
private static final String _FILTER_ENTITY_TABLE = "AccountEntry";
private static final String _ORDER_BY_ENTITY_ALIAS = "accountEntry.";
private static final String _ORDER_BY_ENTITY_TABLE = "AccountEntry.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No AccountEntry exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No AccountEntry exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
AccountEntryPersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"type"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
@Reference
private AccountEntryModelArgumentsResolver
_accountEntryModelArgumentsResolver;
}