/** * 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.asset.service.persistence.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.asset.kernel.exception.NoSuchCategoryPropertyException; import com.liferay.asset.kernel.model.AssetCategoryProperty; import com.liferay.asset.kernel.service.persistence.AssetCategoryPropertyPersistence; 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.ServiceContext; import com.liferay.portal.kernel.service.ServiceContextThreadLocal; 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.portlet.asset.model.impl.AssetCategoryPropertyImpl; import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl; import java.io.Serializable; import java.lang.reflect.Field; import java.util.Collections; import java.util.Date; 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 asset category property service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Brian Wing Shun Chan * @see AssetCategoryPropertyPersistence * @see com.liferay.asset.kernel.service.persistence.AssetCategoryPropertyUtil * @generated */ @ProviderType public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty> implements AssetCategoryPropertyPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link AssetCategoryPropertyUtil} to access the asset category property persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.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(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.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_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.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(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId", new String[] { Long.class.getName() }, AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK | AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId", new String[] { Long.class.getName() }); /** * Returns all the asset category properties where companyId = ?. * * @param companyId the company ID * @return the matching asset category properties */ @Override public List<AssetCategoryProperty> findByCompanyId(long companyId) { return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset category properties 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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @return the range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByCompanyId(long companyId, int start, int end) { return findByCompanyId(companyId, start, end, null); } /** * Returns an ordered range of all the asset category properties 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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByCompanyId(long companyId, int start, int end, OrderByComparator<AssetCategoryProperty> orderByComparator) { return findByCompanyId(companyId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset category properties 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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (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 asset category properties */ @Override public List<AssetCategoryProperty> findByCompanyId(long companyId, int start, int end, OrderByComparator<AssetCategoryProperty> 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<AssetCategoryProperty> list = null; if (retrieveFromCache) { list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategoryProperty assetCategoryProperty : list) { if ((companyId != assetCategoryProperty.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_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryPropertyModelImpl.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<AssetCategoryProperty>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategoryProperty>)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 asset category property 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 asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByCompanyId_First(long companyId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_First(companyId, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } 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 NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the first asset category property 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 asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCompanyId_First(long companyId, OrderByComparator<AssetCategoryProperty> orderByComparator) { List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category property 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 asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByCompanyId_Last(long companyId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_Last(companyId, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } 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 NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the last asset category property 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 asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCompanyId_Last(long companyId, OrderByComparator<AssetCategoryProperty> orderByComparator) { int count = countByCompanyId(companyId); if (count == 0) { return null; } List<AssetCategoryProperty> list = findByCompanyId(companyId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset category properties before and after the current asset category property in the ordered set where companyId = ?. * * @param categoryPropertyId the primary key of the current asset category property * @param companyId the company ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category property * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty[] findByCompanyId_PrevAndNext( long categoryPropertyId, long companyId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId); Session session = null; try { session = openSession(); AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3]; array[0] = getByCompanyId_PrevAndNext(session, assetCategoryProperty, companyId, orderByComparator, true); array[1] = assetCategoryProperty; array[2] = getByCompanyId_PrevAndNext(session, assetCategoryProperty, companyId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategoryProperty getByCompanyId_PrevAndNext( Session session, AssetCategoryProperty assetCategoryProperty, long companyId, OrderByComparator<AssetCategoryProperty> 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_ASSETCATEGORYPROPERTY_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(AssetCategoryPropertyModelImpl.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(assetCategoryProperty); for (Object value : values) { qPos.add(value); } } List<AssetCategoryProperty> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset category properties where companyId = ? from the database. * * @param companyId the company ID */ @Override public void removeByCompanyId(long companyId) { for (AssetCategoryProperty assetCategoryProperty : findByCompanyId( companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategoryProperty); } } /** * Returns the number of asset category properties where companyId = ?. * * @param companyId the company ID * @return the number of matching asset category properties */ @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_ASSETCATEGORYPROPERTY_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 = "assetCategoryProperty.companyId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCategoryId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCategoryId", new String[] { Long.class.getName() }, AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK | AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCategoryId", new String[] { Long.class.getName() }); /** * Returns all the asset category properties where categoryId = ?. * * @param categoryId the category ID * @return the matching asset category properties */ @Override public List<AssetCategoryProperty> findByCategoryId(long categoryId) { return findByCategoryId(categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset category properties where categoryId = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @return the range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByCategoryId(long categoryId, int start, int end) { return findByCategoryId(categoryId, start, end, null); } /** * Returns an ordered range of all the asset category properties where categoryId = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByCategoryId(long categoryId, int start, int end, OrderByComparator<AssetCategoryProperty> orderByComparator) { return findByCategoryId(categoryId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset category properties where categoryId = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 categoryId the category ID * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (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 asset category properties */ @Override public List<AssetCategoryProperty> findByCategoryId(long categoryId, int start, int end, OrderByComparator<AssetCategoryProperty> 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_CATEGORYID; finderArgs = new Object[] { categoryId }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID; finderArgs = new Object[] { categoryId, start, end, orderByComparator }; } List<AssetCategoryProperty> list = null; if (retrieveFromCache) { list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategoryProperty assetCategoryProperty : list) { if ((categoryId != assetCategoryProperty.getCategoryId())) { 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_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2); if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryPropertyModelImpl.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(categoryId); if (!pagination) { list = (List<AssetCategoryProperty>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategoryProperty>)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 asset category property in the ordered set where categoryId = ?. * * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByCategoryId_First(long categoryId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_First(categoryId, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the first asset category property in the ordered set where categoryId = ?. * * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCategoryId_First(long categoryId, OrderByComparator<AssetCategoryProperty> orderByComparator) { List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category property in the ordered set where categoryId = ?. * * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByCategoryId_Last(long categoryId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_Last(categoryId, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the last asset category property in the ordered set where categoryId = ?. * * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCategoryId_Last(long categoryId, OrderByComparator<AssetCategoryProperty> orderByComparator) { int count = countByCategoryId(categoryId); if (count == 0) { return null; } List<AssetCategoryProperty> list = findByCategoryId(categoryId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset category properties before and after the current asset category property in the ordered set where categoryId = ?. * * @param categoryPropertyId the primary key of the current asset category property * @param categoryId the category ID * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category property * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty[] findByCategoryId_PrevAndNext( long categoryPropertyId, long categoryId, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId); Session session = null; try { session = openSession(); AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3]; array[0] = getByCategoryId_PrevAndNext(session, assetCategoryProperty, categoryId, orderByComparator, true); array[1] = assetCategoryProperty; array[2] = getByCategoryId_PrevAndNext(session, assetCategoryProperty, categoryId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategoryProperty getByCategoryId_PrevAndNext( Session session, AssetCategoryProperty assetCategoryProperty, long categoryId, OrderByComparator<AssetCategoryProperty> 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_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_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(AssetCategoryPropertyModelImpl.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(categoryId); if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty); for (Object value : values) { qPos.add(value); } } List<AssetCategoryProperty> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset category properties where categoryId = ? from the database. * * @param categoryId the category ID */ @Override public void removeByCategoryId(long categoryId) { for (AssetCategoryProperty assetCategoryProperty : findByCategoryId( categoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategoryProperty); } } /** * Returns the number of asset category properties where categoryId = ?. * * @param categoryId the category ID * @return the number of matching asset category properties */ @Override public int countByCategoryId(long categoryId) { FinderPath finderPath = FINDER_PATH_COUNT_BY_CATEGORYID; Object[] finderArgs = new Object[] { categoryId }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); 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_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?"; public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_K", new String[] { Long.class.getName(), String.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_K", new String[] { Long.class.getName(), String.class.getName() }, AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK | AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K", new String[] { Long.class.getName(), String.class.getName() }); /** * Returns all the asset category properties where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @return the matching asset category properties */ @Override public List<AssetCategoryProperty> findByC_K(long companyId, String key) { return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset category properties where companyId = ? and key = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 key the key * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @return the range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByC_K(long companyId, String key, int start, int end) { return findByC_K(companyId, key, start, end, null); } /** * Returns an ordered range of all the asset category properties where companyId = ? and key = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 key the key * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching asset category properties */ @Override public List<AssetCategoryProperty> findByC_K(long companyId, String key, int start, int end, OrderByComparator<AssetCategoryProperty> orderByComparator) { return findByC_K(companyId, key, start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset category properties where companyId = ? and key = ?. * * <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 AssetCategoryPropertyModelImpl}. 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 key the key * @param start the lower bound of the range of asset category properties * @param end the upper bound of the range of asset category properties (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 asset category properties */ @Override public List<AssetCategoryProperty> findByC_K(long companyId, String key, int start, int end, OrderByComparator<AssetCategoryProperty> 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_K; finderArgs = new Object[] { companyId, key }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K; finderArgs = new Object[] { companyId, key, start, end, orderByComparator }; } List<AssetCategoryProperty> list = null; if (retrieveFromCache) { list = (List<AssetCategoryProperty>)finderCache.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (AssetCategoryProperty assetCategoryProperty : list) { if ((companyId != assetCategoryProperty.getCompanyId()) || !Objects.equals(key, assetCategoryProperty.getKey())) { 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_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_C_K_COMPANYID_2); boolean bindKey = false; if (key == null) { query.append(_FINDER_COLUMN_C_K_KEY_1); } else if (key.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_K_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_C_K_KEY_2); } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(AssetCategoryPropertyModelImpl.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 (bindKey) { qPos.add(key); } if (!pagination) { list = (List<AssetCategoryProperty>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategoryProperty>)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 asset category property in the ordered set where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByC_K_First(long companyId, String key, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByC_K_First(companyId, key, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", key="); msg.append(key); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the first asset category property in the ordered set where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByC_K_First(long companyId, String key, OrderByComparator<AssetCategoryProperty> orderByComparator) { List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last asset category property in the ordered set where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByC_K_Last(long companyId, String key, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByC_K_Last(companyId, key, orderByComparator); if (assetCategoryProperty != null) { return assetCategoryProperty; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("companyId="); msg.append(companyId); msg.append(", key="); msg.append(key); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchCategoryPropertyException(msg.toString()); } /** * Returns the last asset category property in the ordered set where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByC_K_Last(long companyId, String key, OrderByComparator<AssetCategoryProperty> orderByComparator) { int count = countByC_K(companyId, key); if (count == 0) { return null; } List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the asset category properties before and after the current asset category property in the ordered set where companyId = ? and key = ?. * * @param categoryPropertyId the primary key of the current asset category property * @param companyId the company ID * @param key the key * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next asset category property * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty[] findByC_K_PrevAndNext( long categoryPropertyId, long companyId, String key, OrderByComparator<AssetCategoryProperty> orderByComparator) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId); Session session = null; try { session = openSession(); AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3]; array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty, companyId, key, orderByComparator, true); array[1] = assetCategoryProperty; array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty, companyId, key, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected AssetCategoryProperty getByC_K_PrevAndNext(Session session, AssetCategoryProperty assetCategoryProperty, long companyId, String key, OrderByComparator<AssetCategoryProperty> 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_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_C_K_COMPANYID_2); boolean bindKey = false; if (key == null) { query.append(_FINDER_COLUMN_C_K_KEY_1); } else if (key.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_K_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_C_K_KEY_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(AssetCategoryPropertyModelImpl.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 (bindKey) { qPos.add(key); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty); for (Object value : values) { qPos.add(value); } } List<AssetCategoryProperty> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the asset category properties where companyId = ? and key = ? from the database. * * @param companyId the company ID * @param key the key */ @Override public void removeByC_K(long companyId, String key) { for (AssetCategoryProperty assetCategoryProperty : findByC_K( companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(assetCategoryProperty); } } /** * Returns the number of asset category properties where companyId = ? and key = ?. * * @param companyId the company ID * @param key the key * @return the number of matching asset category properties */ @Override public int countByC_K(long companyId, String key) { FinderPath finderPath = FINDER_PATH_COUNT_BY_C_K; Object[] finderArgs = new Object[] { companyId, key }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_C_K_COMPANYID_2); boolean bindKey = false; if (key == null) { query.append(_FINDER_COLUMN_C_K_KEY_1); } else if (key.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_C_K_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_C_K_KEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (bindKey) { qPos.add(key); } 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_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND "; private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL"; private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?"; private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')"; public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByCA_K", new String[] { Long.class.getName(), String.class.getName() }, AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK | AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCA_K", new String[] { Long.class.getName(), String.class.getName() }); /** * Returns the asset category property where categoryId = ? and key = ? or throws a {@link NoSuchCategoryPropertyException} if it could not be found. * * @param categoryId the category ID * @param key the key * @return the matching asset category property * @throws NoSuchCategoryPropertyException if a matching asset category property could not be found */ @Override public AssetCategoryProperty findByCA_K(long categoryId, String key) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId, key); if (assetCategoryProperty == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("categoryId="); msg.append(categoryId); msg.append(", key="); msg.append(key); msg.append(StringPool.CLOSE_CURLY_BRACE); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchCategoryPropertyException(msg.toString()); } return assetCategoryProperty; } /** * Returns the asset category property where categoryId = ? and key = ? or returns <code>null</code> if it could not be found. Uses the finder cache. * * @param categoryId the category ID * @param key the key * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCA_K(long categoryId, String key) { return fetchByCA_K(categoryId, key, true); } /** * Returns the asset category property where categoryId = ? and key = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. * * @param categoryId the category ID * @param key the key * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found */ @Override public AssetCategoryProperty fetchByCA_K(long categoryId, String key, boolean retrieveFromCache) { Object[] finderArgs = new Object[] { categoryId, key }; Object result = null; if (retrieveFromCache) { result = finderCache.getResult(FINDER_PATH_FETCH_BY_CA_K, finderArgs, this); } if (result instanceof AssetCategoryProperty) { AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)result; if ((categoryId != assetCategoryProperty.getCategoryId()) || !Objects.equals(key, assetCategoryProperty.getKey())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2); boolean bindKey = false; if (key == null) { query.append(_FINDER_COLUMN_CA_K_KEY_1); } else if (key.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CA_K_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_CA_K_KEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); if (bindKey) { qPos.add(key); } List<AssetCategoryProperty> list = q.list(); if (list.isEmpty()) { finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, finderArgs, list); } else { AssetCategoryProperty assetCategoryProperty = list.get(0); result = assetCategoryProperty; cacheResult(assetCategoryProperty); if ((assetCategoryProperty.getCategoryId() != categoryId) || (assetCategoryProperty.getKey() == null) || !assetCategoryProperty.getKey().equals(key)) { finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, finderArgs, assetCategoryProperty); } } } catch (Exception e) { finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List<?>) { return null; } else { return (AssetCategoryProperty)result; } } /** * Removes the asset category property where categoryId = ? and key = ? from the database. * * @param categoryId the category ID * @param key the key * @return the asset category property that was removed */ @Override public AssetCategoryProperty removeByCA_K(long categoryId, String key) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key); return remove(assetCategoryProperty); } /** * Returns the number of asset category properties where categoryId = ? and key = ?. * * @param categoryId the category ID * @param key the key * @return the number of matching asset category properties */ @Override public int countByCA_K(long categoryId, String key) { FinderPath finderPath = FINDER_PATH_COUNT_BY_CA_K; Object[] finderArgs = new Object[] { categoryId, key }; Long count = (Long)finderCache.getResult(finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE); query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2); boolean bindKey = false; if (key == null) { query.append(_FINDER_COLUMN_CA_K_KEY_1); } else if (key.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_CA_K_KEY_3); } else { bindKey = true; query.append(_FINDER_COLUMN_CA_K_KEY_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(categoryId); if (bindKey) { qPos.add(key); } 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_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND "; private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL"; private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?"; private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = '')"; public AssetCategoryPropertyPersistenceImpl() { setModelClass(AssetCategoryProperty.class); try { Field field = ReflectionUtil.getDeclaredField(BasePersistenceImpl.class, "_dbColumnNames"); Map<String, String> dbColumnNames = new HashMap<String, String>(); dbColumnNames.put("key", "key_"); field.set(this, dbColumnNames); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } /** * Caches the asset category property in the entity cache if it is enabled. * * @param assetCategoryProperty the asset category property */ @Override public void cacheResult(AssetCategoryProperty assetCategoryProperty) { entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKey(), assetCategoryProperty); finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, new Object[] { assetCategoryProperty.getCategoryId(), assetCategoryProperty.getKey() }, assetCategoryProperty); assetCategoryProperty.resetOriginalValues(); } /** * Caches the asset category properties in the entity cache if it is enabled. * * @param assetCategoryProperties the asset category properties */ @Override public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) { for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) { if (entityCache.getResult( AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKey()) == null) { cacheResult(assetCategoryProperty); } else { assetCategoryProperty.resetOriginalValues(); } } } /** * Clears the cache for all asset category properties. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache() { entityCache.clearCache(AssetCategoryPropertyImpl.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 asset category property. * * <p> * The {@link EntityCache} and {@link FinderCache} are both cleared by this method. * </p> */ @Override public void clearCache(AssetCategoryProperty assetCategoryProperty) { entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKey()); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((AssetCategoryPropertyModelImpl)assetCategoryProperty, true); } @Override public void clearCache(List<AssetCategoryProperty> assetCategoryProperties) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) { entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKey()); clearUniqueFindersCache((AssetCategoryPropertyModelImpl)assetCategoryProperty, true); } } protected void cacheUniqueFindersCache( AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getCategoryId(), assetCategoryPropertyModelImpl.getKey() }; finderCache.putResult(FINDER_PATH_COUNT_BY_CA_K, args, Long.valueOf(1), false); finderCache.putResult(FINDER_PATH_FETCH_BY_CA_K, args, assetCategoryPropertyModelImpl, false); } protected void clearUniqueFindersCache( AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getCategoryId(), assetCategoryPropertyModelImpl.getKey() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CA_K, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, args); } if ((assetCategoryPropertyModelImpl.getColumnBitmask() & FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getOriginalCategoryId(), assetCategoryPropertyModelImpl.getOriginalKey() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CA_K, args); finderCache.removeResult(FINDER_PATH_FETCH_BY_CA_K, args); } } /** * Creates a new asset category property with the primary key. Does not add the asset category property to the database. * * @param categoryPropertyId the primary key for the new asset category property * @return the new asset category property */ @Override public AssetCategoryProperty create(long categoryPropertyId) { AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl(); assetCategoryProperty.setNew(true); assetCategoryProperty.setPrimaryKey(categoryPropertyId); assetCategoryProperty.setCompanyId(companyProvider.getCompanyId()); return assetCategoryProperty; } /** * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners. * * @param categoryPropertyId the primary key of the asset category property * @return the asset category property that was removed * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty remove(long categoryPropertyId) throws NoSuchCategoryPropertyException { return remove((Serializable)categoryPropertyId); } /** * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the asset category property * @return the asset category property that was removed * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty remove(Serializable primaryKey) throws NoSuchCategoryPropertyException { Session session = null; try { session = openSession(); AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class, primaryKey); if (assetCategoryProperty == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(assetCategoryProperty); } catch (NoSuchCategoryPropertyException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected AssetCategoryProperty removeImpl( AssetCategoryProperty assetCategoryProperty) { assetCategoryProperty = toUnwrappedModel(assetCategoryProperty); Session session = null; try { session = openSession(); if (!session.contains(assetCategoryProperty)) { assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKeyObj()); } if (assetCategoryProperty != null) { session.delete(assetCategoryProperty); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (assetCategoryProperty != null) { clearCache(assetCategoryProperty); } return assetCategoryProperty; } @Override public AssetCategoryProperty updateImpl( AssetCategoryProperty assetCategoryProperty) { assetCategoryProperty = toUnwrappedModel(assetCategoryProperty); boolean isNew = assetCategoryProperty.isNew(); AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (assetCategoryProperty.getCreateDate() == null)) { if (serviceContext == null) { assetCategoryProperty.setCreateDate(now); } else { assetCategoryProperty.setCreateDate(serviceContext.getCreateDate( now)); } } if (!assetCategoryPropertyModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { assetCategoryProperty.setModifiedDate(now); } else { assetCategoryProperty.setModifiedDate(serviceContext.getModifiedDate( now)); } } Session session = null; try { session = openSession(); if (assetCategoryProperty.isNew()) { session.save(assetCategoryProperty); assetCategoryProperty.setNew(false); } else { assetCategoryProperty = (AssetCategoryProperty)session.merge(assetCategoryProperty); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!AssetCategoryPropertyModelImpl.COLUMN_BITMASK_ENABLED) { finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { assetCategoryPropertyModelImpl.getCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID, args); args = new Object[] { assetCategoryPropertyModelImpl.getCompanyId(), assetCategoryPropertyModelImpl.getKey() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_K, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K, args); finderCache.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL, FINDER_ARGS_EMPTY); } else { if ((assetCategoryPropertyModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getOriginalCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); args = new Object[] { assetCategoryPropertyModelImpl.getCompanyId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID, args); } if ((assetCategoryPropertyModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getOriginalCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID, args); args = new Object[] { assetCategoryPropertyModelImpl.getCategoryId() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID, args); } if ((assetCategoryPropertyModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K.getColumnBitmask()) != 0) { Object[] args = new Object[] { assetCategoryPropertyModelImpl.getOriginalCompanyId(), assetCategoryPropertyModelImpl.getOriginalKey() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_K, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K, args); args = new Object[] { assetCategoryPropertyModelImpl.getCompanyId(), assetCategoryPropertyModelImpl.getKey() }; finderCache.removeResult(FINDER_PATH_COUNT_BY_C_K, args); finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K, args); } } entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, assetCategoryProperty.getPrimaryKey(), assetCategoryProperty, false); clearUniqueFindersCache(assetCategoryPropertyModelImpl, false); cacheUniqueFindersCache(assetCategoryPropertyModelImpl); assetCategoryProperty.resetOriginalValues(); return assetCategoryProperty; } protected AssetCategoryProperty toUnwrappedModel( AssetCategoryProperty assetCategoryProperty) { if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) { return assetCategoryProperty; } AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl(); assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew()); assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey()); assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId()); assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId()); assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId()); assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName()); assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate()); assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate()); assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId()); assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey()); assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue()); return assetCategoryPropertyImpl; } /** * Returns the asset category property 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 asset category property * @return the asset category property * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey) throws NoSuchCategoryPropertyException { AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey); if (assetCategoryProperty == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return assetCategoryProperty; } /** * Returns the asset category property with the primary key or throws a {@link NoSuchCategoryPropertyException} if it could not be found. * * @param categoryPropertyId the primary key of the asset category property * @return the asset category property * @throws NoSuchCategoryPropertyException if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId) throws NoSuchCategoryPropertyException { return findByPrimaryKey((Serializable)categoryPropertyId); } /** * Returns the asset category property with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the asset category property * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = entityCache.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, primaryKey); if (serializable == nullModel) { return null; } AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)serializable; if (assetCategoryProperty == null) { Session session = null; try { session = openSession(); assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class, primaryKey); if (assetCategoryProperty != null) { cacheResult(assetCategoryProperty); } else { entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, primaryKey, nullModel); } } catch (Exception e) { entityCache.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return assetCategoryProperty; } /** * Returns the asset category property with the primary key or returns <code>null</code> if it could not be found. * * @param categoryPropertyId the primary key of the asset category property * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found */ @Override public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId) { return fetchByPrimaryKey((Serializable)categoryPropertyId); } @Override public Map<Serializable, AssetCategoryProperty> fetchByPrimaryKeys( Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map<Serializable, AssetCategoryProperty> map = new HashMap<Serializable, AssetCategoryProperty>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(primaryKey); if (assetCategoryProperty != null) { map.put(primaryKey, assetCategoryProperty); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (AssetCategoryProperty)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_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 (AssetCategoryProperty assetCategoryProperty : (List<AssetCategoryProperty>)q.list()) { map.put(assetCategoryProperty.getPrimaryKeyObj(), assetCategoryProperty); cacheResult(assetCategoryProperty); uncachedPrimaryKeys.remove(assetCategoryProperty.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED, AssetCategoryPropertyImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the asset category properties. * * @return the asset category properties */ @Override public List<AssetCategoryProperty> findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the asset category properties. * * <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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @return the range of asset category properties */ @Override public List<AssetCategoryProperty> findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the asset category properties. * * <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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of asset category properties */ @Override public List<AssetCategoryProperty> findAll(int start, int end, OrderByComparator<AssetCategoryProperty> orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the asset category properties. * * <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 AssetCategoryPropertyModelImpl}. 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 asset category properties * @param end the upper bound of the range of asset category properties (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 asset category properties */ @Override public List<AssetCategoryProperty> findAll(int start, int end, OrderByComparator<AssetCategoryProperty> 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<AssetCategoryProperty> list = null; if (retrieveFromCache) { list = (List<AssetCategoryProperty>)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_ASSETCATEGORYPROPERTY); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_ASSETCATEGORYPROPERTY; if (pagination) { sql = sql.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List<AssetCategoryProperty>)QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List<AssetCategoryProperty>)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 asset category properties from the database. * */ @Override public void removeAll() { for (AssetCategoryProperty assetCategoryProperty : findAll()) { remove(assetCategoryProperty); } } /** * Returns the number of asset category properties. * * @return the number of asset category properties */ @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_ASSETCATEGORYPROPERTY); 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 AssetCategoryPropertyModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the asset category property persistence. */ public void afterPropertiesSet() { } public void destroy() { entityCache.removeCache(AssetCategoryPropertyImpl.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_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty"; private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE_PKS_IN = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE categoryPropertyId IN ("; private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE "; private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty"; private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {"; private static final Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class); private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] { "key" }); }