/** * 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.portlet.social.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.portal.kernel.bean.BeanReference; import com.liferay.portal.kernel.dao.orm.EntityCache; import com.liferay.portal.kernel.dao.orm.EntityCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderCache; import com.liferay.portal.kernel.dao.orm.FinderCacheUtil; import com.liferay.portal.kernel.dao.orm.FinderPath; import com.liferay.portal.kernel.dao.orm.Query; import com.liferay.portal.kernel.dao.orm.QueryPos; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.dao.orm.Session; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.service.persistence.CompanyProvider; import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper; import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.util.ReflectionUtil; import com.liferay.portal.kernel.util.SetUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.uuid.PortalUUIDUtil; import com.liferay.portlet.social.model.impl.SocialRelationImpl; import com.liferay.portlet.social.model.impl.SocialRelationModelImpl; import com.liferay.social.kernel.exception.NoSuchRelationException; import com.liferay.social.kernel.model.SocialRelation; import com.liferay.social.kernel.service.persistence.SocialRelationPersistence; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; /** * The persistence implementation for the social relation service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see SocialRelationPersistence * @see com.liferay.social.kernel.service.persistence.SocialRelationUtil * @generated */ @ProviderType public class SocialRelationPersistenceImpl extends BasePersistenceImpl<SocialRelation> implements SocialRelationPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link SocialRelationUtil} to access the social relation persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = SocialRelationImpl.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"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid", new String[] { String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid", new String[] { String.class.getName() }, SocialRelationModelImpl.UUID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid", new String[] { String.class.getName() }); /** * Returns all the social relations where uuid = ?. * * @param uuid the uuid * @return the matching social relations */ @Override public List<SocialRelation> findByUuid(String uuid) { return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByUuid(String uuid, int start, int end) { return findByUuid(uuid, start, end, null); } /** * Returns an ordered range of all the social relations where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUuid(String uuid, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByUuid(uuid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where uuid = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUuid(String uuid, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID; finderArgs = new Object[] { uuid, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if (!Objects.equals(uuid, socialRelation.getUuid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUuid_First(String uuid, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUuid_First(uuid, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUuid_First(String uuid, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByUuid(uuid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUuid_Last(String uuid, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUuid_Last(uuid, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where uuid = ?. * * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUuid_Last(String uuid, OrderByComparator<SocialRelation> orderByComparator) { int count = countByUuid(uuid); if (count == 0) { return null; } List<SocialRelation> list = findByUuid(uuid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where uuid = ?. * * @param relationId the primary key of the current social relation * @param uuid the uuid * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByUuid_PrevAndNext(long relationId, String uuid, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByUuid_PrevAndNext(session, socialRelation, uuid, orderByComparator, true); array[1] = socialRelation; array[2] = getByUuid_PrevAndNext(session, socialRelation, uuid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByUuid_PrevAndNext(Session session, SocialRelation socialRelation, String uuid, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where uuid = ? from the database. * * @param uuid the uuid */ @Override public void removeByUuid(String uuid) { for (SocialRelation socialRelation : findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where uuid = ?. * * @param uuid the uuid * @return the number of matching social relations */ @Override public int countByUuid(String uuid) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID; Object[] finderArgs = new Object[] { uuid }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_UUID_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_UUID_1 = "socialRelation.uuid IS NULL"; private static final String _FINDER_COLUMN_UUID_UUID_2 = "socialRelation.uuid = ?"; private static final String _FINDER_COLUMN_UUID_UUID_3 = "(socialRelation.uuid IS NULL OR socialRelation.uuid = '')"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C", new String[] { String.class.getName(), Long.class.getName() }, SocialRelationModelImpl.UUID_COLUMN_BITMASK | SocialRelationModelImpl.COMPANYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C", new String[] { String.class.getName(), Long.class.getName() }); /** * Returns all the social relations where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the matching social relations */ @Override public List<SocialRelation> findByUuid_C(String uuid, long companyId) { return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByUuid_C(String uuid, long companyId, int start, int end) { return findByUuid_C(uuid, companyId, start, end, null); } /** * Returns an ordered range of all the social relations where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByUuid_C(uuid, companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where uuid = ? and companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param uuid the uuid * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C; finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if (!Objects.equals(uuid, socialRelation.getUuid()) || (companyId != socialRelation.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUuid_C_First(String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUuid_C_First(uuid, companyId, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUuid_C_First(String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByUuid_C(uuid, companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUuid_C_Last(String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUuid_C_Last(uuid, companyId, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("uuid="); msg.append(uuid); msg.append(", companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUuid_C_Last(String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator) { int count = countByUuid_C(uuid, companyId); if (count == 0) { return null; } List<SocialRelation> list = findByUuid_C(uuid, companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where uuid = ? and companyId = ?. * * @param relationId the primary key of the current social relation * @param uuid the uuid * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByUuid_C_PrevAndNext(long relationId, String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByUuid_C_PrevAndNext(session, socialRelation, uuid, companyId, orderByComparator, true); array[1] = socialRelation; array[2] = getByUuid_C_PrevAndNext(session, socialRelation, uuid, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByUuid_C_PrevAndNext(Session session, SocialRelation socialRelation, String uuid, long companyId, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where uuid = ? and companyId = ? from the database. * * @param uuid the uuid * @param companyId the company ID */ @Override public void removeByUuid_C(String uuid, long companyId) { for (SocialRelation socialRelation : findByUuid_C(uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where uuid = ? and companyId = ?. * * @param uuid the uuid * @param companyId the company ID * @return the number of matching social relations */ @Override public int countByUuid_C(String uuid, long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C; Object[] finderArgs = new Object[] { uuid, companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); boolean bindUuid = false; if (uuid == null) { query.append(_FINDER_COLUMN_UUID_C_UUID_1); } else if (uuid.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_UUID_C_UUID_3); } else { bindUuid = true; query.append(_FINDER_COLUMN_UUID_C_UUID_2); } query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (bindUuid) { qPos.add(uuid); } qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "socialRelation.uuid IS NULL AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "socialRelation.uuid = ? AND "; private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(socialRelation.uuid IS NULL OR socialRelation.uuid = '') AND "; private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "socialRelation.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, SocialRelationModelImpl.COMPANYID_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the social relations where companyId = ?. * * @param companyId the company ID * @return the matching social relations */ @Override public List<SocialRelation> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the social relations where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByCompanyId(long companyId, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where companyId = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByCompanyId(long companyId, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID; finderArgs = new Object[] { companyId, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((companyId != socialRelation.getCompanyId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByCompanyId_First(long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByCompanyId_First(companyId, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByCompanyId_First(long companyId, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByCompanyId(companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByCompanyId_Last(long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByCompanyId_Last(companyId, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where companyId = ?. * * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByCompanyId_Last(long companyId, OrderByComparator<SocialRelation> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<SocialRelation> list = findByCompanyId(companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where companyId = ?. * * @param relationId the primary key of the current social relation * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByCompanyId_PrevAndNext(long relationId, long companyId, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByCompanyId_PrevAndNext(session, socialRelation, companyId, orderByComparator, true); array[1] = socialRelation; array[2] = getByCompanyId_PrevAndNext(session, socialRelation, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByCompanyId_PrevAndNext(Session session, SocialRelation socialRelation, long companyId, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (SocialRelation socialRelation : findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where companyId = ?. * * @param companyId the company ID * @return the number of matching social relations */ @Override public int countByCompanyId(long companyId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID; Object[] finderArgs = new Object[] { companyId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "socialRelation.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID1 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId1", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId1", new String[] { Long.class.getName() }, SocialRelationModelImpl.USERID1_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_USERID1 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId1", new String[] { Long.class.getName() }); /** * Returns all the social relations where userId1 = ?. * * @param userId1 the user id1 * @return the matching social relations */ @Override public List<SocialRelation> findByUserId1(long userId1) { return findByUserId1(userId1, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where userId1 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByUserId1(long userId1, int start, int end) { return findByUserId1(userId1, start, end, null); } /** * Returns an ordered range of all the social relations where userId1 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUserId1(long userId1, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByUserId1(userId1, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where userId1 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUserId1(long userId1, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1; finderArgs = new Object[] { userId1 }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID1; finderArgs = new Object[] { userId1, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((userId1 != socialRelation.getUserId1())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID1_USERID1_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where userId1 = ?. * * @param userId1 the user id1 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUserId1_First(long userId1, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUserId1_First(userId1, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where userId1 = ?. * * @param userId1 the user id1 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUserId1_First(long userId1, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByUserId1(userId1, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where userId1 = ?. * * @param userId1 the user id1 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUserId1_Last(long userId1, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUserId1_Last(userId1, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where userId1 = ?. * * @param userId1 the user id1 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUserId1_Last(long userId1, OrderByComparator<SocialRelation> orderByComparator) { int count = countByUserId1(userId1); if (count == 0) { return null; } List<SocialRelation> list = findByUserId1(userId1, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where userId1 = ?. * * @param relationId the primary key of the current social relation * @param userId1 the user id1 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByUserId1_PrevAndNext(long relationId, long userId1, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByUserId1_PrevAndNext(session, socialRelation, userId1, orderByComparator, true); array[1] = socialRelation; array[2] = getByUserId1_PrevAndNext(session, socialRelation, userId1, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByUserId1_PrevAndNext(Session session, SocialRelation socialRelation, long userId1, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID1_USERID1_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where userId1 = ? from the database. * * @param userId1 the user id1 */ @Override public void removeByUserId1(long userId1) { for (SocialRelation socialRelation : findByUserId1(userId1, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where userId1 = ?. * * @param userId1 the user id1 * @return the number of matching social relations */ @Override public int countByUserId1(long userId1) { FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID1; Object[] finderArgs = new Object[] { userId1 }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID1_USERID1_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_USERID1_USERID1_2 = "socialRelation.userId1 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId2", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId2", new String[] { Long.class.getName() }, SocialRelationModelImpl.USERID2_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_USERID2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId2", new String[] { Long.class.getName() }); /** * Returns all the social relations where userId2 = ?. * * @param userId2 the user id2 * @return the matching social relations */ @Override public List<SocialRelation> findByUserId2(long userId2) { return findByUserId2(userId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByUserId2(long userId2, int start, int end) { return findByUserId2(userId2, start, end, null); } /** * Returns an ordered range of all the social relations where userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUserId2(long userId2, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByUserId2(userId2, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByUserId2(long userId2, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2; finderArgs = new Object[] { userId2 }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID2; finderArgs = new Object[] { userId2, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((userId2 != socialRelation.getUserId2())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID2_USERID2_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where userId2 = ?. * * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUserId2_First(long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUserId2_First(userId2, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId2="); msg.append(userId2); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where userId2 = ?. * * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUserId2_First(long userId2, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByUserId2(userId2, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where userId2 = ?. * * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByUserId2_Last(long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByUserId2_Last(userId2, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId2="); msg.append(userId2); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where userId2 = ?. * * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByUserId2_Last(long userId2, OrderByComparator<SocialRelation> orderByComparator) { int count = countByUserId2(userId2); if (count == 0) { return null; } List<SocialRelation> list = findByUserId2(userId2, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where userId2 = ?. * * @param relationId the primary key of the current social relation * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByUserId2_PrevAndNext(long relationId, long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByUserId2_PrevAndNext(session, socialRelation, userId2, orderByComparator, true); array[1] = socialRelation; array[2] = getByUserId2_PrevAndNext(session, socialRelation, userId2, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByUserId2_PrevAndNext(Session session, SocialRelation socialRelation, long userId2, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID2_USERID2_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where userId2 = ? from the database. * * @param userId2 the user id2 */ @Override public void removeByUserId2(long userId2) { for (SocialRelation socialRelation : findByUserId2(userId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where userId2 = ?. * * @param userId2 the user id2 * @return the number of matching social relations */ @Override public int countByUserId2(long userId2) { FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID2; Object[] finderArgs = new Object[] { userId2 }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_USERID2_USERID2_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_USERID2_USERID2_2 = "socialRelation.userId2 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByType", new String[] { Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByType", new String[] { Integer.class.getName() }, SocialRelationModelImpl.TYPE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_TYPE = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByType", new String[] { Integer.class.getName() }); /** * Returns all the social relations where type = ?. * * @param type the type * @return the matching social relations */ @Override public List<SocialRelation> findByType(int type) { return findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByType(int type, int start, int end) { return findByType(type, start, end, null); } /** * Returns an ordered range of all the social relations where type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByType(int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByType(type, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByType(int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE; finderArgs = new Object[] { type }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TYPE; finderArgs = new Object[] { type, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((type != socialRelation.getType())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_TYPE_TYPE_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(type); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where type = ?. * * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByType_First(int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByType_First(type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where type = ?. * * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByType_First(int type, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByType(type, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where type = ?. * * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByType_Last(int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByType_Last(type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where type = ?. * * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByType_Last(int type, OrderByComparator<SocialRelation> orderByComparator) { int count = countByType(type); if (count == 0) { return null; } List<SocialRelation> list = findByType(type, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where type = ?. * * @param relationId the primary key of the current social relation * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByType_PrevAndNext(long relationId, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByType_PrevAndNext(session, socialRelation, type, orderByComparator, true); array[1] = socialRelation; array[2] = getByType_PrevAndNext(session, socialRelation, type, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByType_PrevAndNext(Session session, SocialRelation socialRelation, int type, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_TYPE_TYPE_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(type); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where type = ? from the database. * * @param type the type */ @Override public void removeByType(int type) { for (SocialRelation socialRelation : findByType(type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where type = ?. * * @param type the type * @return the number of matching social relations */ @Override public int countByType(int type) { FinderPath finderPath = FINDER_PATH_COUNT_BY_TYPE; Object[] finderArgs = new Object[] { type }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_TYPE_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(type); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_TYPE_TYPE_2 = "socialRelation.type = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_T", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_T", new String[] { Long.class.getName(), Integer.class.getName() }, SocialRelationModelImpl.COMPANYID_COLUMN_BITMASK | SocialRelationModelImpl.TYPE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_T", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the social relations where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @return the matching social relations */ @Override public List<SocialRelation> findByC_T(long companyId, int type) { return findByC_T(companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where companyId = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByC_T(long companyId, int type, int start, int end) { return findByC_T(companyId, type, start, end, null); } /** * Returns an ordered range of all the social relations where companyId = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByC_T(long companyId, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByC_T(companyId, type, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where companyId = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param companyId the company ID * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByC_T(long companyId, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T; finderArgs = new Object[] { companyId, type }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_T; finderArgs = new Object[] { companyId, type, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((companyId != socialRelation.getCompanyId()) || (type != socialRelation.getType())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_C_T_COMPANYID_2); query.append(_FINDER_COLUMN_C_T_TYPE_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(type); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByC_T_First(long companyId, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByC_T_First(companyId, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByC_T_First(long companyId, int type, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByC_T(companyId, type, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByC_T_Last(long companyId, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByC_T_Last(companyId, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByC_T_Last(long companyId, int type, OrderByComparator<SocialRelation> orderByComparator) { int count = countByC_T(companyId, type); if (count == 0) { return null; } List<SocialRelation> list = findByC_T(companyId, type, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where companyId = ? and type = ?. * * @param relationId the primary key of the current social relation * @param companyId the company ID * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByC_T_PrevAndNext(long relationId, long companyId, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByC_T_PrevAndNext(session, socialRelation, companyId, type, orderByComparator, true); array[1] = socialRelation; array[2] = getByC_T_PrevAndNext(session, socialRelation, companyId, type, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByC_T_PrevAndNext(Session session, SocialRelation socialRelation, long companyId, int type, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_C_T_COMPANYID_2); query.append(_FINDER_COLUMN_C_T_TYPE_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(type); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where companyId = ? and type = ? from the database. * * @param companyId the company ID * @param type the type */ @Override public void removeByC_T(long companyId, int type) { for (SocialRelation socialRelation : findByC_T(companyId, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where companyId = ? and type = ?. * * @param companyId the company ID * @param type the type * @return the number of matching social relations */ @Override public int countByC_T(long companyId, int type) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_T; Object[] finderArgs = new Object[] { companyId, type }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_C_T_COMPANYID_2); query.append(_FINDER_COLUMN_C_T_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(type); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_T_COMPANYID_2 = "socialRelation.companyId = ? AND "; private static final String _FINDER_COLUMN_C_T_TYPE_2 = "socialRelation.type = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU1_U2", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU1_U2", new String[] { Long.class.getName(), Long.class.getName() }, SocialRelationModelImpl.USERID1_COLUMN_BITMASK | SocialRelationModelImpl.USERID2_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U1_U2 = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_U2", new String[] { Long.class.getName(), Long.class.getName() }); /** * Returns all the social relations where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @return the matching social relations */ @Override public List<SocialRelation> findByU1_U2(long userId1, long userId2) { return findByU1_U2(userId1, userId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where userId1 = ? and userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByU1_U2(long userId1, long userId2, int start, int end) { return findByU1_U2(userId1, userId2, start, end, null); } /** * Returns an ordered range of all the social relations where userId1 = ? and userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU1_U2(long userId1, long userId2, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByU1_U2(userId1, userId2, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where userId1 = ? and userId2 = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param userId2 the user id2 * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU1_U2(long userId1, long userId2, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2; finderArgs = new Object[] { userId1, userId2 }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_U2; finderArgs = new Object[] { userId1, userId2, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((userId1 != socialRelation.getUserId1()) || (userId2 != socialRelation.getUserId2())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_U2_USERID1_2); query.append(_FINDER_COLUMN_U1_U2_USERID2_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(userId2); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU1_U2_First(long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU1_U2_First(userId1, userId2, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(", userId2="); msg.append(userId2); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_U2_First(long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByU1_U2(userId1, userId2, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU1_U2_Last(long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU1_U2_Last(userId1, userId2, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(", userId2="); msg.append(userId2); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_U2_Last(long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator) { int count = countByU1_U2(userId1, userId2); if (count == 0) { return null; } List<SocialRelation> list = findByU1_U2(userId1, userId2, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where userId1 = ? and userId2 = ?. * * @param relationId the primary key of the current social relation * @param userId1 the user id1 * @param userId2 the user id2 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByU1_U2_PrevAndNext(long relationId, long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByU1_U2_PrevAndNext(session, socialRelation, userId1, userId2, orderByComparator, true); array[1] = socialRelation; array[2] = getByU1_U2_PrevAndNext(session, socialRelation, userId1, userId2, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByU1_U2_PrevAndNext(Session session, SocialRelation socialRelation, long userId1, long userId2, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_U2_USERID1_2); query.append(_FINDER_COLUMN_U1_U2_USERID2_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(userId2); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where userId1 = ? and userId2 = ? from the database. * * @param userId1 the user id1 * @param userId2 the user id2 */ @Override public void removeByU1_U2(long userId1, long userId2) { for (SocialRelation socialRelation : findByU1_U2(userId1, userId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where userId1 = ? and userId2 = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @return the number of matching social relations */ @Override public int countByU1_U2(long userId1, long userId2) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U1_U2; Object[] finderArgs = new Object[] { userId1, userId2 }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_U2_USERID1_2); query.append(_FINDER_COLUMN_U1_U2_USERID2_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(userId2); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U1_U2_USERID1_2 = "socialRelation.userId1 = ? AND "; private static final String _FINDER_COLUMN_U1_U2_USERID2_2 = "socialRelation.userId2 = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU1_T", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU1_T", new String[] { Long.class.getName(), Integer.class.getName() }, SocialRelationModelImpl.USERID1_COLUMN_BITMASK | SocialRelationModelImpl.TYPE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U1_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_T", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the social relations where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @return the matching social relations */ @Override public List<SocialRelation> findByU1_T(long userId1, int type) { return findByU1_T(userId1, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where userId1 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByU1_T(long userId1, int type, int start, int end) { return findByU1_T(userId1, type, start, end, null); } /** * Returns an ordered range of all the social relations where userId1 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU1_T(long userId1, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByU1_T(userId1, type, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where userId1 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId1 the user id1 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU1_T(long userId1, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T; finderArgs = new Object[] { userId1, type }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U1_T; finderArgs = new Object[] { userId1, type, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((userId1 != socialRelation.getUserId1()) || (type != socialRelation.getType())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_T_USERID1_2); query.append(_FINDER_COLUMN_U1_T_TYPE_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(type); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU1_T_First(long userId1, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU1_T_First(userId1, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_T_First(long userId1, int type, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByU1_T(userId1, type, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU1_T_Last(long userId1, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU1_T_Last(userId1, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_T_Last(long userId1, int type, OrderByComparator<SocialRelation> orderByComparator) { int count = countByU1_T(userId1, type); if (count == 0) { return null; } List<SocialRelation> list = findByU1_T(userId1, type, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where userId1 = ? and type = ?. * * @param relationId the primary key of the current social relation * @param userId1 the user id1 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByU1_T_PrevAndNext(long relationId, long userId1, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByU1_T_PrevAndNext(session, socialRelation, userId1, type, orderByComparator, true); array[1] = socialRelation; array[2] = getByU1_T_PrevAndNext(session, socialRelation, userId1, type, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByU1_T_PrevAndNext(Session session, SocialRelation socialRelation, long userId1, int type, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_T_USERID1_2); query.append(_FINDER_COLUMN_U1_T_TYPE_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(type); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where userId1 = ? and type = ? from the database. * * @param userId1 the user id1 * @param type the type */ @Override public void removeByU1_T(long userId1, int type) { for (SocialRelation socialRelation : findByU1_T(userId1, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where userId1 = ? and type = ?. * * @param userId1 the user id1 * @param type the type * @return the number of matching social relations */ @Override public int countByU1_T(long userId1, int type) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U1_T; Object[] finderArgs = new Object[] { userId1, type }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_T_USERID1_2); query.append(_FINDER_COLUMN_U1_T_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(type); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U1_T_USERID1_2 = "socialRelation.userId1 = ? AND "; private static final String _FINDER_COLUMN_U1_T_TYPE_2 = "socialRelation.type = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByU2_T", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByU2_T", new String[] { Long.class.getName(), Integer.class.getName() }, SocialRelationModelImpl.USERID2_COLUMN_BITMASK | SocialRelationModelImpl.TYPE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU2_T", new String[] { Long.class.getName(), Integer.class.getName() }); /** * Returns all the social relations where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @return the matching social relations */ @Override public List<SocialRelation> findByU2_T(long userId2, int type) { return findByU2_T(userId2, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations where userId2 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of matching social relations */ @Override public List<SocialRelation> findByU2_T(long userId2, int type, int start, int end) { return findByU2_T(userId2, type, start, end, null); } /** * Returns an ordered range of all the social relations where userId2 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU2_T(long userId2, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findByU2_T(userId2, type, start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations where userId2 = ? and type = ?. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param userId2 the user id2 * @param type the type * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching social relations */ @Override public List<SocialRelation> findByU2_T(long userId2, int type, int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T; finderArgs = new Object[] { userId2, type }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_U2_T; finderArgs = new Object[] { userId2, type, start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (SocialRelation socialRelation : list) { if ((userId2 != socialRelation.getUserId2()) || (type != socialRelation.getType())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U2_T_USERID2_2); query.append(_FINDER_COLUMN_U2_T_TYPE_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); qPos.add(type); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first social relation in the ordered set where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU2_T_First(long userId2, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU2_T_First(userId2, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId2="); msg.append(userId2); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the first social relation in the ordered set where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU2_T_First(long userId2, int type, OrderByComparator<SocialRelation> orderByComparator) { List<SocialRelation> list = findByU2_T(userId2, type, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last social relation in the ordered set where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU2_T_Last(long userId2, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU2_T_Last(userId2, type, orderByComparator); if (socialRelation != null) { return socialRelation; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId2="); msg.append(userId2); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchRelationException(msg.toString()); } /** * Returns the last social relation in the ordered set where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU2_T_Last(long userId2, int type, OrderByComparator<SocialRelation> orderByComparator) { int count = countByU2_T(userId2, type); if (count == 0) { return null; } List<SocialRelation> list = findByU2_T(userId2, type, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the social relations before and after the current social relation in the ordered set where userId2 = ? and type = ?. * * @param relationId the primary key of the current social relation * @param userId2 the user id2 * @param type the type * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation[] findByU2_T_PrevAndNext(long relationId, long userId2, int type, OrderByComparator<SocialRelation> orderByComparator) throws NoSuchRelationException { SocialRelation socialRelation = findByPrimaryKey(relationId); Session session = null; try { session = openSession(); SocialRelation[] array = new SocialRelationImpl[3]; array[0] = getByU2_T_PrevAndNext(session, socialRelation, userId2, type, orderByComparator, true); array[1] = socialRelation; array[2] = getByU2_T_PrevAndNext(session, socialRelation, userId2, type, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected SocialRelation getByU2_T_PrevAndNext(Session session, SocialRelation socialRelation, long userId2, int type, OrderByComparator<SocialRelation> orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U2_T_USERID2_2); query.append(_FINDER_COLUMN_U2_T_TYPE_2); if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByConditionFields[i]); if ((i + 1) < orderByConditionFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN_HAS_NEXT); } else { query.append(WHERE_LESSER_THAN_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(WHERE_GREATER_THAN); } else { query.append(WHERE_LESSER_THAN); } } } query.append(ORDER_BY_CLAUSE); String[] orderByFields = orderByComparator.getOrderByFields(); for (int i = 0; i < orderByFields.length; i++) { query.append(_ORDER_BY_ENTITY_ALIAS); query.append(orderByFields[i]); if ((i + 1) < orderByFields.length) { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC_HAS_NEXT); } else { query.append(ORDER_BY_DESC_HAS_NEXT); } } else { if (orderByComparator.isAscending() ^ previous) { query.append(ORDER_BY_ASC); } else { query.append(ORDER_BY_DESC); } } } } else { query.append(SocialRelationModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); qPos.add(type); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(socialRelation); for (Object value : values) { qPos.add(value); } } List<SocialRelation> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the social relations where userId2 = ? and type = ? from the database. * * @param userId2 the user id2 * @param type the type */ @Override public void removeByU2_T(long userId2, int type) { for (SocialRelation socialRelation : findByU2_T(userId2, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(socialRelation); } } /** * Returns the number of social relations where userId2 = ? and type = ?. * * @param userId2 the user id2 * @param type the type * @return the number of matching social relations */ @Override public int countByU2_T(long userId2, int type) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U2_T; Object[] finderArgs = new Object[] { userId2, type }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U2_T_USERID2_2); query.append(_FINDER_COLUMN_U2_T_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId2); qPos.add(type); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U2_T_USERID2_2 = "socialRelation.userId2 = ? AND "; private static final String _FINDER_COLUMN_U2_T_TYPE_2 = "socialRelation.type = ?"; public static final FinderPath FINDER_PATH_FETCH_BY_U1_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, SocialRelationImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByU1_U2_T", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }, SocialRelationModelImpl.USERID1_COLUMN_BITMASK | SocialRelationModelImpl.USERID2_COLUMN_BITMASK | SocialRelationModelImpl.TYPE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_U1_U2_T = new FinderPath(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByU1_U2_T", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName() }); /** * Returns the social relation where userId1 = ? and userId2 = ? and type = ? or throws a {@link NoSuchRelationException} if it could not be found. * * @param userId1 the user id1 * @param userId2 the user id2 * @param type the type * @return the matching social relation * @throws NoSuchRelationException if a matching social relation could not be found */ @Override public SocialRelation findByU1_U2_T(long userId1, long userId2, int type) throws NoSuchRelationException { SocialRelation socialRelation = fetchByU1_U2_T(userId1, userId2, type); if (socialRelation == null) { StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("userId1="); msg.append(userId1); msg.append(", userId2="); msg.append(userId2); msg.append(", type="); msg.append(type); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchRelationException(msg.toString()); } return socialRelation; } /** * Returns the social relation where userId1 = ? and userId2 = ? and type = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param userId1 the user id1 * @param userId2 the user id2 * @param type the type * @return the matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_U2_T(long userId1, long userId2, int type) { return fetchByU1_U2_T(userId1, userId2, type, true); } /** * Returns the social relation where userId1 = ? and userId2 = ? and type = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param userId1 the user id1 * @param userId2 the user id2 * @param type the type * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching social relation, or <code>null</code> if a matching social relation could not be found */ @Override public SocialRelation fetchByU1_U2_T(long userId1, long userId2, int type, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { userId1, userId2, type }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_U1_U2_T, finderArgs, this); } if (result instanceof SocialRelation) { SocialRelation socialRelation = (SocialRelation)result; if ((userId1 != socialRelation.getUserId1()) || (userId2 != socialRelation.getUserId2()) || (type != socialRelation.getType())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(5); query.append(_SQL_SELECT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_U2_T_USERID1_2); query.append(_FINDER_COLUMN_U1_U2_T_USERID2_2); query.append(_FINDER_COLUMN_U1_U2_T_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(userId2); qPos.add(type); List<SocialRelation> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_U1_U2_T, finderArgs, list); } else { SocialRelation socialRelation = list.get(0); result = socialRelation; cacheResult(socialRelation); if ((socialRelation.getUserId1() != userId1) || (socialRelation.getUserId2() != userId2) || (socialRelation.getType() != type)) { finderCache.putResult(FINDER_PATH_FETCH_BY_U1_U2_T, finderArgs, socialRelation); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (SocialRelation)result; } } /** * Removes the social relation where userId1 = ? and userId2 = ? and type = ? from the database. * * @param userId1 the user id1 * @param userId2 the user id2 * @param type the type * @return the social relation that was removed */ @Override public SocialRelation removeByU1_U2_T(long userId1, long userId2, int type) throws NoSuchRelationException { SocialRelation socialRelation = findByU1_U2_T(userId1, userId2, type); return remove(socialRelation); } /** * Returns the number of social relations where userId1 = ? and userId2 = ? and type = ?. * * @param userId1 the user id1 * @param userId2 the user id2 * @param type the type * @return the number of matching social relations */ @Override public int countByU1_U2_T(long userId1, long userId2, int type) { FinderPath finderPath = FINDER_PATH_COUNT_BY_U1_U2_T; Object[] finderArgs = new Object[] { userId1, userId2, type }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_SOCIALRELATION_WHERE); query.append(_FINDER_COLUMN_U1_U2_T_USERID1_2); query.append(_FINDER_COLUMN_U1_U2_T_USERID2_2); query.append(_FINDER_COLUMN_U1_U2_T_TYPE_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId1); qPos.add(userId2); qPos.add(type); count = (Long)q.uniqueResult(); finderCache.putResult(finderPath, finderArgs, count); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_U1_U2_T_USERID1_2 = "socialRelation.userId1 = ? AND "; private static final String _FINDER_COLUMN_U1_U2_T_USERID2_2 = "socialRelation.userId2 = ? AND "; private static final String _FINDER_COLUMN_U1_U2_T_TYPE_2 = "socialRelation.type = ?"; public SocialRelationPersistenceImpl() { setModelClass(SocialRelation.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("uuid", "uuid_"); dbColumnNames.put("type", "type_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the social relation in the entity cache if it is enabled. * * @param socialRelation the social relation */ @Override public void cacheResult(SocialRelation socialRelation) { entityCache.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, socialRelation.getPrimaryKey(), socialRelation); finderCache.putResult(FINDER_PATH_FETCH_BY_U1_U2_T, new Object[] { socialRelation.getUserId1(), socialRelation.getUserId2(), socialRelation.getType() }, socialRelation); socialRelation.resetOriginalValues(); } /** * Caches the social relations in the entity cache if it is enabled. * * @param socialRelations the social relations */ @Override public void cacheResult(List<SocialRelation> socialRelations) { for (SocialRelation socialRelation : socialRelations) { if (entityCache.getResult( SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, socialRelation.getPrimaryKey()) == null) { cacheResult(socialRelation); } else { socialRelation.resetOriginalValues(); } } } /** * Clears the cache for all social relations. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(SocialRelationImpl.class); finderCache.clearCache(FINDER_CLASS_NAME_ENTITY); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the social relation. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(SocialRelation socialRelation) { entityCache.removeResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, socialRelation.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((SocialRelationModelImpl)socialRelation, true); } @Override public void clearCache(List<SocialRelation> socialRelations) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (SocialRelation socialRelation : socialRelations) { entityCache.removeResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, socialRelation.getPrimaryKey()); clearUniqueFindersCache((SocialRelationModelImpl)socialRelation, true); } } protected void cacheUniqueFindersCache( SocialRelationModelImpl socialRelationModelImpl) { Object[] args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getUserId2(), socialRelationModelImpl.getType() }; finderCache.putResult(FINDER_PATH_COUNT_BY_U1_U2_T, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_U1_U2_T, args, socialRelationModelImpl, false); } protected void clearUniqueFindersCache( SocialRelationModelImpl socialRelationModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getUserId2(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_U2_T, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_U1_U2_T.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId1(), socialRelationModelImpl.getOriginalUserId2(), socialRelationModelImpl.getOriginalType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_U2_T, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_U1_U2_T, args); } } /** * Creates a new social relation with the primary key. Does not add the social relation to the database. * * @param relationId the primary key for the new social relation * @return the new social relation */ @Override public SocialRelation create(long relationId) { SocialRelation socialRelation = new SocialRelationImpl(); socialRelation.setNew(true); socialRelation.setPrimaryKey(relationId); String uuid = PortalUUIDUtil.generate(); socialRelation.setUuid(uuid); socialRelation.setCompanyId(companyProvider.getCompanyId()); return socialRelation; } /** * Removes the social relation with the primary key from the database. Also notifies the appropriate model listeners. * * @param relationId the primary key of the social relation * @return the social relation that was removed * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation remove(long relationId) throws NoSuchRelationException { return remove((Serializable)relationId); } /** * Removes the social relation with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the social relation * @return the social relation that was removed * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation remove(Serializable primaryKey) throws NoSuchRelationException { Session session = null; try { session = openSession(); SocialRelation socialRelation = (SocialRelation)session.get(SocialRelationImpl.class, primaryKey); if (socialRelation == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchRelationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(socialRelation); } catch (NoSuchRelationException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected SocialRelation removeImpl(SocialRelation socialRelation) { socialRelation = toUnwrappedModel(socialRelation); Session session = null; try { session = openSession(); if (!session.contains(socialRelation)) { socialRelation = (SocialRelation)session.get(SocialRelationImpl.class, socialRelation.getPrimaryKeyObj()); } if (socialRelation != null) { session.delete(socialRelation); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (socialRelation != null) { clearCache(socialRelation); } return socialRelation; } @Override public SocialRelation updateImpl(SocialRelation socialRelation) { socialRelation = toUnwrappedModel(socialRelation); boolean isNew = socialRelation.isNew(); SocialRelationModelImpl socialRelationModelImpl = (SocialRelationModelImpl)socialRelation; if (Validator.isNull(socialRelation.getUuid())) { String uuid = PortalUUIDUtil.generate(); socialRelation.setUuid(uuid); } Session session = null; try { session = openSession(); if (socialRelation.isNew()) { session.save(socialRelation); socialRelation.setNew(false); } else { socialRelation = (SocialRelation)session.merge(socialRelation); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!SocialRelationModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { socialRelationModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { socialRelationModelImpl.getUuid(), socialRelationModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { socialRelationModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { socialRelationModelImpl.getUserId1() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID1, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1, args); args = new Object[] { socialRelationModelImpl.getUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2, args); args = new Object[] { socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE, args); args = new Object[] { socialRelationModelImpl.getCompanyId(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T, args); args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_U2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2, args); args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T, args); args = new Object[] { socialRelationModelImpl.getUserId2(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U2_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); args = new Object[] { socialRelationModelImpl.getUuid() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUuid(), socialRelationModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); args = new Object[] { socialRelationModelImpl.getUuid(), socialRelationModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { socialRelationModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId1() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID1, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1, args); args = new Object[] { socialRelationModelImpl.getUserId1() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID1, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID1, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2, args); args = new Object[] { socialRelationModelImpl.getUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_USERID2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID2, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE, args); args = new Object[] { socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_TYPE, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYPE, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalCompanyId(), socialRelationModelImpl.getOriginalType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T, args); args = new Object[] { socialRelationModelImpl.getCompanyId(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_T, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId1(), socialRelationModelImpl.getOriginalUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_U2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2, args); args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getUserId2() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_U2, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_U2, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId1(), socialRelationModelImpl.getOriginalType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T, args); args = new Object[] { socialRelationModelImpl.getUserId1(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U1_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U1_T, args); } if ((socialRelationModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T.getColumnBitmask()) != 0) { Object[] args = new Object[] { socialRelationModelImpl.getOriginalUserId2(), socialRelationModelImpl.getOriginalType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U2_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T, args); args = new Object[] { socialRelationModelImpl.getUserId2(), socialRelationModelImpl.getType() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_U2_T, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_U2_T, args); } } entityCache.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, socialRelation.getPrimaryKey(), socialRelation, false); clearUniqueFindersCache(socialRelationModelImpl, false); cacheUniqueFindersCache(socialRelationModelImpl); socialRelation.resetOriginalValues(); return socialRelation; } protected SocialRelation toUnwrappedModel(SocialRelation socialRelation) { if (socialRelation instanceof SocialRelationImpl) { return socialRelation; } SocialRelationImpl socialRelationImpl = new SocialRelationImpl(); socialRelationImpl.setNew(socialRelation.isNew()); socialRelationImpl.setPrimaryKey(socialRelation.getPrimaryKey()); socialRelationImpl.setUuid(socialRelation.getUuid()); socialRelationImpl.setRelationId(socialRelation.getRelationId()); socialRelationImpl.setCompanyId(socialRelation.getCompanyId()); socialRelationImpl.setCreateDate(socialRelation.getCreateDate()); socialRelationImpl.setUserId1(socialRelation.getUserId1()); socialRelationImpl.setUserId2(socialRelation.getUserId2()); socialRelationImpl.setType(socialRelation.getType()); return socialRelationImpl; } /** * Returns the social relation with the primary key or throws a {@link com.liferay.portal.kernel.exception.NoSuchModelException} if it could not be found. * * @param primaryKey the primary key of the social relation * @return the social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation findByPrimaryKey(Serializable primaryKey) throws NoSuchRelationException { SocialRelation socialRelation = fetchByPrimaryKey(primaryKey); if (socialRelation == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchRelationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return socialRelation; } /** * Returns the social relation with the primary key or throws a {@link NoSuchRelationException} if it could not be found. * * @param relationId the primary key of the social relation * @return the social relation * @throws NoSuchRelationException if a social relation with the primary key could not be found */ @Override public SocialRelation findByPrimaryKey(long relationId) throws NoSuchRelationException { return findByPrimaryKey((Serializable)relationId); } /** * Returns the social relation with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the social relation * @return the social relation, or <code>null</code> if a social relation with the primary key could not be found */ @Override public SocialRelation fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, primaryKey); if (serializable == nullModel) { return null; } SocialRelation socialRelation = (SocialRelation)serializable; if (socialRelation == null) { Session session = null; try { session = openSession(); socialRelation = (SocialRelation)session.get(SocialRelationImpl.class, primaryKey); if (socialRelation != null) { cacheResult(socialRelation); } else { entityCache.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return socialRelation; } /** * Returns the social relation with the primary key or returns <code>null</code> if it could not be found. * * @param relationId the primary key of the social relation * @return the social relation, or <code>null</code> if a social relation with the primary key could not be found */ @Override public SocialRelation fetchByPrimaryKey(long relationId) { return fetchByPrimaryKey((Serializable)relationId); } @Override public Map<Serializable, SocialRelation> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, SocialRelation> map = new HashMap<Serializable, SocialRelation>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); SocialRelation socialRelation = fetchByPrimaryKey(primaryKey); if (socialRelation != null) { map.put(primaryKey, socialRelation); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (SocialRelation)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_SOCIALRELATION_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (SocialRelation socialRelation : (List<SocialRelation>)q.list()) { map.put(socialRelation.getPrimaryKeyObj(), socialRelation); cacheResult(socialRelation); uncachedPrimaryKeys.remove(socialRelation.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(SocialRelationModelImpl.ENTITY_CACHE_ENABLED, SocialRelationImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the social relations. * * @return the social relations */ @Override public List<SocialRelation> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the social relations. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @return the range of social relations */ @Override public List<SocialRelation> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the social relations. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of social relations */ @Override public List<SocialRelation> findAll(int start, int end, OrderByComparator<SocialRelation> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the social relations. * * <p> * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link SocialRelationModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. * </p> * * @param start the lower bound of the range of social relations * @param end the upper bound of the range of social relations (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of social relations */ @Override public List<SocialRelation> findAll(int start, int end, OrderByComparator<SocialRelation> orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL; finderArgs = new Object[] { start, end, orderByComparator }; } List<SocialRelation> list = null; if (retrieveFromCache) { list = (List<SocialRelation>)finderCache.getResult(finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_SOCIALRELATION); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_SOCIALRELATION; if (pagination) { sql = sql.concat(SocialRelationModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<SocialRelation>)QueryUtil.list(q, getDialect(), start, end); } cacheResult(list); finderCache.putResult(finderPath, finderArgs, list); } catch (Exception e) { finderCache.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the social relations from the database. * */ @Override public void removeAll() { for (SocialRelation socialRelation : findAll()) { remove(socialRelation); } } /** * Returns the number of social relations. * * @return the number of social relations */ @Override public int countAll() { Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_SOCIALRELATION); count = (Long)q.uniqueResult(); finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count); } catch (Exception e) { finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override public Set<String> getBadColumnNames() { return _badColumnNames; } @Override protected Map<String, Integer> getTableColumnsMap() { return SocialRelationModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the social relation persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(SocialRelationImpl.class.getName()); finderCache.removeCache(FINDER_CLASS_NAME_ENTITY); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; protected EntityCache entityCache = EntityCacheUtil.getEntityCache(); protected FinderCache finderCache = FinderCacheUtil.getFinderCache(); private static final String _SQL_SELECT_SOCIALRELATION = "SELECT socialRelation FROM SocialRelation socialRelation"; private static final String _SQL_SELECT_SOCIALRELATION_WHERE_PKS_IN = "SELECT socialRelation FROM SocialRelation socialRelation WHERE relationId IN ("; private static final String _SQL_SELECT_SOCIALRELATION_WHERE = "SELECT socialRelation FROM SocialRelation socialRelation WHERE "; private static final String _SQL_COUNT_SOCIALRELATION = "SELECT COUNT(socialRelation) FROM SocialRelation socialRelation"; private static final String _SQL_COUNT_SOCIALRELATION_WHERE = "SELECT COUNT(socialRelation) FROM SocialRelation socialRelation WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "socialRelation."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialRelation exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialRelation exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(SocialRelationPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "uuid", "type" }); }