001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.BatchSessionUtil;
039    import com.liferay.portal.service.persistence.ResourcePersistence;
040    import com.liferay.portal.service.persistence.UserPersistence;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
044    import com.liferay.portlet.asset.model.AssetCategoryProperty;
045    import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
046    import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
047    
048    import java.io.Serializable;
049    
050    import java.util.ArrayList;
051    import java.util.Collections;
052    import java.util.List;
053    
054    /**
055     * The persistence implementation for the asset category property service.
056     *
057     * <p>
058     * 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.
059     * </p>
060     *
061     * <p>
062     * Caching information and settings can be found in <code>portal.properties</code>
063     * </p>
064     *
065     * @author Brian Wing Shun Chan
066     * @see AssetCategoryPropertyPersistence
067     * @see AssetCategoryPropertyUtil
068     * @generated
069     */
070    public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
071            implements AssetCategoryPropertyPersistence {
072            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
074                    ".List";
075            public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
076                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
077                            FINDER_CLASS_NAME_LIST, "findByCompanyId",
078                            new String[] {
079                                    Long.class.getName(),
080                                    
081                            "java.lang.Integer", "java.lang.Integer",
082                                    "com.liferay.portal.kernel.util.OrderByComparator"
083                            });
084            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
085                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
086                            FINDER_CLASS_NAME_LIST, "countByCompanyId",
087                            new String[] { Long.class.getName() });
088            public static final FinderPath FINDER_PATH_FIND_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
089                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
090                            FINDER_CLASS_NAME_LIST, "findByCategoryId",
091                            new String[] {
092                                    Long.class.getName(),
093                                    
094                            "java.lang.Integer", "java.lang.Integer",
095                                    "com.liferay.portal.kernel.util.OrderByComparator"
096                            });
097            public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
098                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
099                            FINDER_CLASS_NAME_LIST, "countByCategoryId",
100                            new String[] { Long.class.getName() });
101            public static final FinderPath FINDER_PATH_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
102                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
103                            FINDER_CLASS_NAME_LIST, "findByC_K",
104                            new String[] {
105                                    Long.class.getName(), String.class.getName(),
106                                    
107                            "java.lang.Integer", "java.lang.Integer",
108                                    "com.liferay.portal.kernel.util.OrderByComparator"
109                            });
110            public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
111                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
112                            FINDER_CLASS_NAME_LIST, "countByC_K",
113                            new String[] { Long.class.getName(), String.class.getName() });
114            public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
115                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
116                            FINDER_CLASS_NAME_ENTITY, "fetchByCA_K",
117                            new String[] { Long.class.getName(), String.class.getName() });
118            public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
119                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
120                            FINDER_CLASS_NAME_LIST, "countByCA_K",
121                            new String[] { Long.class.getName(), String.class.getName() });
122            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
123                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
124                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
125            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
126                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
127                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
128    
129            /**
130             * Caches the asset category property in the entity cache if it is enabled.
131             *
132             * @param assetCategoryProperty the asset category property to cache
133             */
134            public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
135                    EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
136                            AssetCategoryPropertyImpl.class,
137                            assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
138    
139                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
140                            new Object[] {
141                                    new Long(assetCategoryProperty.getCategoryId()),
142                                    
143                            assetCategoryProperty.getKey()
144                            }, assetCategoryProperty);
145            }
146    
147            /**
148             * Caches the asset category properties in the entity cache if it is enabled.
149             *
150             * @param assetCategoryProperties the asset category properties to cache
151             */
152            public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
153                    for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
154                            if (EntityCacheUtil.getResult(
155                                                    AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
156                                                    AssetCategoryPropertyImpl.class,
157                                                    assetCategoryProperty.getPrimaryKey(), this) == null) {
158                                    cacheResult(assetCategoryProperty);
159                            }
160                    }
161            }
162    
163            /**
164             * Clears the cache for all asset category properties.
165             *
166             * <p>
167             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
168             * </p>
169             */
170            public void clearCache() {
171                    CacheRegistryUtil.clear(AssetCategoryPropertyImpl.class.getName());
172                    EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
173                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
174                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
175            }
176    
177            /**
178             * Clears the cache for the asset category property.
179             *
180             * <p>
181             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
182             * </p>
183             */
184            public void clearCache(AssetCategoryProperty assetCategoryProperty) {
185                    EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
186                            AssetCategoryPropertyImpl.class,
187                            assetCategoryProperty.getPrimaryKey());
188    
189                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
190                            new Object[] {
191                                    new Long(assetCategoryProperty.getCategoryId()),
192                                    
193                            assetCategoryProperty.getKey()
194                            });
195            }
196    
197            /**
198             * Creates a new asset category property with the primary key. Does not add the asset category property to the database.
199             *
200             * @param categoryPropertyId the primary key for the new asset category property
201             * @return the new asset category property
202             */
203            public AssetCategoryProperty create(long categoryPropertyId) {
204                    AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
205    
206                    assetCategoryProperty.setNew(true);
207                    assetCategoryProperty.setPrimaryKey(categoryPropertyId);
208    
209                    return assetCategoryProperty;
210            }
211    
212            /**
213             * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners.
214             *
215             * @param primaryKey the primary key of the asset category property to remove
216             * @return the asset category property that was removed
217             * @throws com.liferay.portal.NoSuchModelException if a asset category property with the primary key could not be found
218             * @throws SystemException if a system exception occurred
219             */
220            public AssetCategoryProperty remove(Serializable primaryKey)
221                    throws NoSuchModelException, SystemException {
222                    return remove(((Long)primaryKey).longValue());
223            }
224    
225            /**
226             * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners.
227             *
228             * @param categoryPropertyId the primary key of the asset category property to remove
229             * @return the asset category property that was removed
230             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
231             * @throws SystemException if a system exception occurred
232             */
233            public AssetCategoryProperty remove(long categoryPropertyId)
234                    throws NoSuchCategoryPropertyException, SystemException {
235                    Session session = null;
236    
237                    try {
238                            session = openSession();
239    
240                            AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
241                                            new Long(categoryPropertyId));
242    
243                            if (assetCategoryProperty == null) {
244                                    if (_log.isWarnEnabled()) {
245                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
246                                                    categoryPropertyId);
247                                    }
248    
249                                    throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
250                                            categoryPropertyId);
251                            }
252    
253                            return remove(assetCategoryProperty);
254                    }
255                    catch (NoSuchCategoryPropertyException nsee) {
256                            throw nsee;
257                    }
258                    catch (Exception e) {
259                            throw processException(e);
260                    }
261                    finally {
262                            closeSession(session);
263                    }
264            }
265    
266            protected AssetCategoryProperty removeImpl(
267                    AssetCategoryProperty assetCategoryProperty) throws SystemException {
268                    assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
269    
270                    Session session = null;
271    
272                    try {
273                            session = openSession();
274    
275                            BatchSessionUtil.delete(session, assetCategoryProperty);
276                    }
277                    catch (Exception e) {
278                            throw processException(e);
279                    }
280                    finally {
281                            closeSession(session);
282                    }
283    
284                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285    
286                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
287    
288                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
289                            new Object[] {
290                                    new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
291                                    
292                            assetCategoryPropertyModelImpl.getOriginalKey()
293                            });
294    
295                    EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
296                            AssetCategoryPropertyImpl.class,
297                            assetCategoryProperty.getPrimaryKey());
298    
299                    return assetCategoryProperty;
300            }
301    
302            public AssetCategoryProperty updateImpl(
303                    com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty,
304                    boolean merge) throws SystemException {
305                    assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
306    
307                    boolean isNew = assetCategoryProperty.isNew();
308    
309                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
310    
311                    Session session = null;
312    
313                    try {
314                            session = openSession();
315    
316                            BatchSessionUtil.update(session, assetCategoryProperty, merge);
317    
318                            assetCategoryProperty.setNew(false);
319                    }
320                    catch (Exception e) {
321                            throw processException(e);
322                    }
323                    finally {
324                            closeSession(session);
325                    }
326    
327                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
328    
329                    EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
330                            AssetCategoryPropertyImpl.class,
331                            assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
332    
333                    if (!isNew &&
334                                    ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
335                                    !Validator.equals(assetCategoryProperty.getKey(),
336                                            assetCategoryPropertyModelImpl.getOriginalKey()))) {
337                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
338                                    new Object[] {
339                                            new Long(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
340                                            
341                                    assetCategoryPropertyModelImpl.getOriginalKey()
342                                    });
343                    }
344    
345                    if (isNew ||
346                                    ((assetCategoryProperty.getCategoryId() != assetCategoryPropertyModelImpl.getOriginalCategoryId()) ||
347                                    !Validator.equals(assetCategoryProperty.getKey(),
348                                            assetCategoryPropertyModelImpl.getOriginalKey()))) {
349                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
350                                    new Object[] {
351                                            new Long(assetCategoryProperty.getCategoryId()),
352                                            
353                                    assetCategoryProperty.getKey()
354                                    }, assetCategoryProperty);
355                    }
356    
357                    return assetCategoryProperty;
358            }
359    
360            protected AssetCategoryProperty toUnwrappedModel(
361                    AssetCategoryProperty assetCategoryProperty) {
362                    if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
363                            return assetCategoryProperty;
364                    }
365    
366                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
367    
368                    assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
369                    assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
370    
371                    assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
372                    assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
373                    assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
374                    assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
375                    assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
376                    assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
377                    assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
378                    assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
379                    assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
380    
381                    return assetCategoryPropertyImpl;
382            }
383    
384            /**
385             * Finds the asset category property with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
386             *
387             * @param primaryKey the primary key of the asset category property to find
388             * @return the asset category property
389             * @throws com.liferay.portal.NoSuchModelException if a asset category property with the primary key could not be found
390             * @throws SystemException if a system exception occurred
391             */
392            public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
393                    throws NoSuchModelException, SystemException {
394                    return findByPrimaryKey(((Long)primaryKey).longValue());
395            }
396    
397            /**
398             * Finds the asset category property with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchCategoryPropertyException} if it could not be found.
399             *
400             * @param categoryPropertyId the primary key of the asset category property to find
401             * @return the asset category property
402             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
403             * @throws SystemException if a system exception occurred
404             */
405            public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
406                    throws NoSuchCategoryPropertyException, SystemException {
407                    AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(categoryPropertyId);
408    
409                    if (assetCategoryProperty == null) {
410                            if (_log.isWarnEnabled()) {
411                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
412                                            categoryPropertyId);
413                            }
414    
415                            throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
416                                    categoryPropertyId);
417                    }
418    
419                    return assetCategoryProperty;
420            }
421    
422            /**
423             * Finds the asset category property with the primary key or returns <code>null</code> if it could not be found.
424             *
425             * @param primaryKey the primary key of the asset category property to find
426             * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found
427             * @throws SystemException if a system exception occurred
428             */
429            public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
430                    throws SystemException {
431                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
432            }
433    
434            /**
435             * Finds the asset category property with the primary key or returns <code>null</code> if it could not be found.
436             *
437             * @param categoryPropertyId the primary key of the asset category property to find
438             * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found
439             * @throws SystemException if a system exception occurred
440             */
441            public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
442                    throws SystemException {
443                    AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
444                                    AssetCategoryPropertyImpl.class, categoryPropertyId, this);
445    
446                    if (assetCategoryProperty == null) {
447                            Session session = null;
448    
449                            try {
450                                    session = openSession();
451    
452                                    assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
453                                                    new Long(categoryPropertyId));
454                            }
455                            catch (Exception e) {
456                                    throw processException(e);
457                            }
458                            finally {
459                                    if (assetCategoryProperty != null) {
460                                            cacheResult(assetCategoryProperty);
461                                    }
462    
463                                    closeSession(session);
464                            }
465                    }
466    
467                    return assetCategoryProperty;
468            }
469    
470            /**
471             * Finds all the asset category properties where companyId = &#63;.
472             *
473             * @param companyId the company id to search with
474             * @return the matching asset category properties
475             * @throws SystemException if a system exception occurred
476             */
477            public List<AssetCategoryProperty> findByCompanyId(long companyId)
478                    throws SystemException {
479                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
480                            null);
481            }
482    
483            /**
484             * Finds a range of all the asset category properties where companyId = &#63;.
485             *
486             * <p>
487             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
488             * </p>
489             *
490             * @param companyId the company id to search with
491             * @param start the lower bound of the range of asset category properties to return
492             * @param end the upper bound of the range of asset category properties to return (not inclusive)
493             * @return the range of matching asset category properties
494             * @throws SystemException if a system exception occurred
495             */
496            public List<AssetCategoryProperty> findByCompanyId(long companyId,
497                    int start, int end) throws SystemException {
498                    return findByCompanyId(companyId, start, end, null);
499            }
500    
501            /**
502             * Finds an ordered range of all the asset category properties where companyId = &#63;.
503             *
504             * <p>
505             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
506             * </p>
507             *
508             * @param companyId the company id to search with
509             * @param start the lower bound of the range of asset category properties to return
510             * @param end the upper bound of the range of asset category properties to return (not inclusive)
511             * @param orderByComparator the comparator to order the results by
512             * @return the ordered range of matching asset category properties
513             * @throws SystemException if a system exception occurred
514             */
515            public List<AssetCategoryProperty> findByCompanyId(long companyId,
516                    int start, int end, OrderByComparator orderByComparator)
517                    throws SystemException {
518                    Object[] finderArgs = new Object[] {
519                                    companyId,
520                                    
521                                    String.valueOf(start), String.valueOf(end),
522                                    String.valueOf(orderByComparator)
523                            };
524    
525                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
526                                    finderArgs, this);
527    
528                    if (list == null) {
529                            Session session = null;
530    
531                            try {
532                                    session = openSession();
533    
534                                    StringBundler query = null;
535    
536                                    if (orderByComparator != null) {
537                                            query = new StringBundler(3 +
538                                                            (orderByComparator.getOrderByFields().length * 3));
539                                    }
540                                    else {
541                                            query = new StringBundler(3);
542                                    }
543    
544                                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
545    
546                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
547    
548                                    if (orderByComparator != null) {
549                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
550                                                    orderByComparator);
551                                    }
552    
553                                    else {
554                                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
555                                    }
556    
557                                    String sql = query.toString();
558    
559                                    Query q = session.createQuery(sql);
560    
561                                    QueryPos qPos = QueryPos.getInstance(q);
562    
563                                    qPos.add(companyId);
564    
565                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
566                                                    getDialect(), start, end);
567                            }
568                            catch (Exception e) {
569                                    throw processException(e);
570                            }
571                            finally {
572                                    if (list == null) {
573                                            list = new ArrayList<AssetCategoryProperty>();
574                                    }
575    
576                                    cacheResult(list);
577    
578                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
579                                            finderArgs, list);
580    
581                                    closeSession(session);
582                            }
583                    }
584    
585                    return list;
586            }
587    
588            /**
589             * Finds the first asset category property in the ordered set where companyId = &#63;.
590             *
591             * <p>
592             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
593             * </p>
594             *
595             * @param companyId the company id to search with
596             * @param orderByComparator the comparator to order the set by
597             * @return the first matching asset category property
598             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
599             * @throws SystemException if a system exception occurred
600             */
601            public AssetCategoryProperty findByCompanyId_First(long companyId,
602                    OrderByComparator orderByComparator)
603                    throws NoSuchCategoryPropertyException, SystemException {
604                    List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
605                                    orderByComparator);
606    
607                    if (list.isEmpty()) {
608                            StringBundler msg = new StringBundler(4);
609    
610                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
611    
612                            msg.append("companyId=");
613                            msg.append(companyId);
614    
615                            msg.append(StringPool.CLOSE_CURLY_BRACE);
616    
617                            throw new NoSuchCategoryPropertyException(msg.toString());
618                    }
619                    else {
620                            return list.get(0);
621                    }
622            }
623    
624            /**
625             * Finds the last asset category property in the ordered set where companyId = &#63;.
626             *
627             * <p>
628             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
629             * </p>
630             *
631             * @param companyId the company id to search with
632             * @param orderByComparator the comparator to order the set by
633             * @return the last matching asset category property
634             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
635             * @throws SystemException if a system exception occurred
636             */
637            public AssetCategoryProperty findByCompanyId_Last(long companyId,
638                    OrderByComparator orderByComparator)
639                    throws NoSuchCategoryPropertyException, SystemException {
640                    int count = countByCompanyId(companyId);
641    
642                    List<AssetCategoryProperty> list = findByCompanyId(companyId,
643                                    count - 1, count, orderByComparator);
644    
645                    if (list.isEmpty()) {
646                            StringBundler msg = new StringBundler(4);
647    
648                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
649    
650                            msg.append("companyId=");
651                            msg.append(companyId);
652    
653                            msg.append(StringPool.CLOSE_CURLY_BRACE);
654    
655                            throw new NoSuchCategoryPropertyException(msg.toString());
656                    }
657                    else {
658                            return list.get(0);
659                    }
660            }
661    
662            /**
663             * Finds the asset category properties before and after the current asset category property in the ordered set where companyId = &#63;.
664             *
665             * <p>
666             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
667             * </p>
668             *
669             * @param categoryPropertyId the primary key of the current asset category property
670             * @param companyId the company id to search with
671             * @param orderByComparator the comparator to order the set by
672             * @return the previous, current, and next asset category property
673             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
674             * @throws SystemException if a system exception occurred
675             */
676            public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
677                    long categoryPropertyId, long companyId,
678                    OrderByComparator orderByComparator)
679                    throws NoSuchCategoryPropertyException, SystemException {
680                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
681    
682                    Session session = null;
683    
684                    try {
685                            session = openSession();
686    
687                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
688    
689                            array[0] = getByCompanyId_PrevAndNext(session,
690                                            assetCategoryProperty, companyId, orderByComparator, true);
691    
692                            array[1] = assetCategoryProperty;
693    
694                            array[2] = getByCompanyId_PrevAndNext(session,
695                                            assetCategoryProperty, companyId, orderByComparator, false);
696    
697                            return array;
698                    }
699                    catch (Exception e) {
700                            throw processException(e);
701                    }
702                    finally {
703                            closeSession(session);
704                    }
705            }
706    
707            protected AssetCategoryProperty getByCompanyId_PrevAndNext(
708                    Session session, AssetCategoryProperty assetCategoryProperty,
709                    long companyId, OrderByComparator orderByComparator, boolean previous) {
710                    StringBundler query = null;
711    
712                    if (orderByComparator != null) {
713                            query = new StringBundler(6 +
714                                            (orderByComparator.getOrderByFields().length * 6));
715                    }
716                    else {
717                            query = new StringBundler(3);
718                    }
719    
720                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
721    
722                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
723    
724                    if (orderByComparator != null) {
725                            String[] orderByFields = orderByComparator.getOrderByFields();
726    
727                            if (orderByFields.length > 0) {
728                                    query.append(WHERE_AND);
729                            }
730    
731                            for (int i = 0; i < orderByFields.length; i++) {
732                                    query.append(_ORDER_BY_ENTITY_ALIAS);
733                                    query.append(orderByFields[i]);
734    
735                                    if ((i + 1) < orderByFields.length) {
736                                            if (orderByComparator.isAscending() ^ previous) {
737                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
738                                            }
739                                            else {
740                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
741                                            }
742                                    }
743                                    else {
744                                            if (orderByComparator.isAscending() ^ previous) {
745                                                    query.append(WHERE_GREATER_THAN);
746                                            }
747                                            else {
748                                                    query.append(WHERE_LESSER_THAN);
749                                            }
750                                    }
751                            }
752    
753                            query.append(ORDER_BY_CLAUSE);
754    
755                            for (int i = 0; i < orderByFields.length; i++) {
756                                    query.append(_ORDER_BY_ENTITY_ALIAS);
757                                    query.append(orderByFields[i]);
758    
759                                    if ((i + 1) < orderByFields.length) {
760                                            if (orderByComparator.isAscending() ^ previous) {
761                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
762                                            }
763                                            else {
764                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
765                                            }
766                                    }
767                                    else {
768                                            if (orderByComparator.isAscending() ^ previous) {
769                                                    query.append(ORDER_BY_ASC);
770                                            }
771                                            else {
772                                                    query.append(ORDER_BY_DESC);
773                                            }
774                                    }
775                            }
776                    }
777    
778                    else {
779                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
780                    }
781    
782                    String sql = query.toString();
783    
784                    Query q = session.createQuery(sql);
785    
786                    q.setFirstResult(0);
787                    q.setMaxResults(2);
788    
789                    QueryPos qPos = QueryPos.getInstance(q);
790    
791                    qPos.add(companyId);
792    
793                    if (orderByComparator != null) {
794                            Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
795    
796                            for (Object value : values) {
797                                    qPos.add(value);
798                            }
799                    }
800    
801                    List<AssetCategoryProperty> list = q.list();
802    
803                    if (list.size() == 2) {
804                            return list.get(1);
805                    }
806                    else {
807                            return null;
808                    }
809            }
810    
811            /**
812             * Finds all the asset category properties where categoryId = &#63;.
813             *
814             * @param categoryId the category id to search with
815             * @return the matching asset category properties
816             * @throws SystemException if a system exception occurred
817             */
818            public List<AssetCategoryProperty> findByCategoryId(long categoryId)
819                    throws SystemException {
820                    return findByCategoryId(categoryId, QueryUtil.ALL_POS,
821                            QueryUtil.ALL_POS, null);
822            }
823    
824            /**
825             * Finds a range of all the asset category properties where categoryId = &#63;.
826             *
827             * <p>
828             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
829             * </p>
830             *
831             * @param categoryId the category id to search with
832             * @param start the lower bound of the range of asset category properties to return
833             * @param end the upper bound of the range of asset category properties to return (not inclusive)
834             * @return the range of matching asset category properties
835             * @throws SystemException if a system exception occurred
836             */
837            public List<AssetCategoryProperty> findByCategoryId(long categoryId,
838                    int start, int end) throws SystemException {
839                    return findByCategoryId(categoryId, start, end, null);
840            }
841    
842            /**
843             * Finds an ordered range of all the asset category properties where categoryId = &#63;.
844             *
845             * <p>
846             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
847             * </p>
848             *
849             * @param categoryId the category id to search with
850             * @param start the lower bound of the range of asset category properties to return
851             * @param end the upper bound of the range of asset category properties to return (not inclusive)
852             * @param orderByComparator the comparator to order the results by
853             * @return the ordered range of matching asset category properties
854             * @throws SystemException if a system exception occurred
855             */
856            public List<AssetCategoryProperty> findByCategoryId(long categoryId,
857                    int start, int end, OrderByComparator orderByComparator)
858                    throws SystemException {
859                    Object[] finderArgs = new Object[] {
860                                    categoryId,
861                                    
862                                    String.valueOf(start), String.valueOf(end),
863                                    String.valueOf(orderByComparator)
864                            };
865    
866                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_CATEGORYID,
867                                    finderArgs, this);
868    
869                    if (list == null) {
870                            Session session = null;
871    
872                            try {
873                                    session = openSession();
874    
875                                    StringBundler query = null;
876    
877                                    if (orderByComparator != null) {
878                                            query = new StringBundler(3 +
879                                                            (orderByComparator.getOrderByFields().length * 3));
880                                    }
881                                    else {
882                                            query = new StringBundler(3);
883                                    }
884    
885                                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
886    
887                                    query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
888    
889                                    if (orderByComparator != null) {
890                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
891                                                    orderByComparator);
892                                    }
893    
894                                    else {
895                                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
896                                    }
897    
898                                    String sql = query.toString();
899    
900                                    Query q = session.createQuery(sql);
901    
902                                    QueryPos qPos = QueryPos.getInstance(q);
903    
904                                    qPos.add(categoryId);
905    
906                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
907                                                    getDialect(), start, end);
908                            }
909                            catch (Exception e) {
910                                    throw processException(e);
911                            }
912                            finally {
913                                    if (list == null) {
914                                            list = new ArrayList<AssetCategoryProperty>();
915                                    }
916    
917                                    cacheResult(list);
918    
919                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_CATEGORYID,
920                                            finderArgs, list);
921    
922                                    closeSession(session);
923                            }
924                    }
925    
926                    return list;
927            }
928    
929            /**
930             * Finds the first asset category property in the ordered set where categoryId = &#63;.
931             *
932             * <p>
933             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
934             * </p>
935             *
936             * @param categoryId the category id to search with
937             * @param orderByComparator the comparator to order the set by
938             * @return the first matching asset category property
939             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
940             * @throws SystemException if a system exception occurred
941             */
942            public AssetCategoryProperty findByCategoryId_First(long categoryId,
943                    OrderByComparator orderByComparator)
944                    throws NoSuchCategoryPropertyException, SystemException {
945                    List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
946                                    orderByComparator);
947    
948                    if (list.isEmpty()) {
949                            StringBundler msg = new StringBundler(4);
950    
951                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
952    
953                            msg.append("categoryId=");
954                            msg.append(categoryId);
955    
956                            msg.append(StringPool.CLOSE_CURLY_BRACE);
957    
958                            throw new NoSuchCategoryPropertyException(msg.toString());
959                    }
960                    else {
961                            return list.get(0);
962                    }
963            }
964    
965            /**
966             * Finds the last asset category property in the ordered set where categoryId = &#63;.
967             *
968             * <p>
969             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
970             * </p>
971             *
972             * @param categoryId the category id to search with
973             * @param orderByComparator the comparator to order the set by
974             * @return the last matching asset category property
975             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
976             * @throws SystemException if a system exception occurred
977             */
978            public AssetCategoryProperty findByCategoryId_Last(long categoryId,
979                    OrderByComparator orderByComparator)
980                    throws NoSuchCategoryPropertyException, SystemException {
981                    int count = countByCategoryId(categoryId);
982    
983                    List<AssetCategoryProperty> list = findByCategoryId(categoryId,
984                                    count - 1, count, orderByComparator);
985    
986                    if (list.isEmpty()) {
987                            StringBundler msg = new StringBundler(4);
988    
989                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
990    
991                            msg.append("categoryId=");
992                            msg.append(categoryId);
993    
994                            msg.append(StringPool.CLOSE_CURLY_BRACE);
995    
996                            throw new NoSuchCategoryPropertyException(msg.toString());
997                    }
998                    else {
999                            return list.get(0);
1000                    }
1001            }
1002    
1003            /**
1004             * Finds the asset category properties before and after the current asset category property in the ordered set where categoryId = &#63;.
1005             *
1006             * <p>
1007             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1008             * </p>
1009             *
1010             * @param categoryPropertyId the primary key of the current asset category property
1011             * @param categoryId the category id to search with
1012             * @param orderByComparator the comparator to order the set by
1013             * @return the previous, current, and next asset category property
1014             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
1015             * @throws SystemException if a system exception occurred
1016             */
1017            public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
1018                    long categoryPropertyId, long categoryId,
1019                    OrderByComparator orderByComparator)
1020                    throws NoSuchCategoryPropertyException, SystemException {
1021                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1022    
1023                    Session session = null;
1024    
1025                    try {
1026                            session = openSession();
1027    
1028                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1029    
1030                            array[0] = getByCategoryId_PrevAndNext(session,
1031                                            assetCategoryProperty, categoryId, orderByComparator, true);
1032    
1033                            array[1] = assetCategoryProperty;
1034    
1035                            array[2] = getByCategoryId_PrevAndNext(session,
1036                                            assetCategoryProperty, categoryId, orderByComparator, false);
1037    
1038                            return array;
1039                    }
1040                    catch (Exception e) {
1041                            throw processException(e);
1042                    }
1043                    finally {
1044                            closeSession(session);
1045                    }
1046            }
1047    
1048            protected AssetCategoryProperty getByCategoryId_PrevAndNext(
1049                    Session session, AssetCategoryProperty assetCategoryProperty,
1050                    long categoryId, OrderByComparator orderByComparator, boolean previous) {
1051                    StringBundler query = null;
1052    
1053                    if (orderByComparator != null) {
1054                            query = new StringBundler(6 +
1055                                            (orderByComparator.getOrderByFields().length * 6));
1056                    }
1057                    else {
1058                            query = new StringBundler(3);
1059                    }
1060    
1061                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1062    
1063                    query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1064    
1065                    if (orderByComparator != null) {
1066                            String[] orderByFields = orderByComparator.getOrderByFields();
1067    
1068                            if (orderByFields.length > 0) {
1069                                    query.append(WHERE_AND);
1070                            }
1071    
1072                            for (int i = 0; i < orderByFields.length; i++) {
1073                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1074                                    query.append(orderByFields[i]);
1075    
1076                                    if ((i + 1) < orderByFields.length) {
1077                                            if (orderByComparator.isAscending() ^ previous) {
1078                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1079                                            }
1080                                            else {
1081                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1082                                            }
1083                                    }
1084                                    else {
1085                                            if (orderByComparator.isAscending() ^ previous) {
1086                                                    query.append(WHERE_GREATER_THAN);
1087                                            }
1088                                            else {
1089                                                    query.append(WHERE_LESSER_THAN);
1090                                            }
1091                                    }
1092                            }
1093    
1094                            query.append(ORDER_BY_CLAUSE);
1095    
1096                            for (int i = 0; i < orderByFields.length; i++) {
1097                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1098                                    query.append(orderByFields[i]);
1099    
1100                                    if ((i + 1) < orderByFields.length) {
1101                                            if (orderByComparator.isAscending() ^ previous) {
1102                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1103                                            }
1104                                            else {
1105                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1106                                            }
1107                                    }
1108                                    else {
1109                                            if (orderByComparator.isAscending() ^ previous) {
1110                                                    query.append(ORDER_BY_ASC);
1111                                            }
1112                                            else {
1113                                                    query.append(ORDER_BY_DESC);
1114                                            }
1115                                    }
1116                            }
1117                    }
1118    
1119                    else {
1120                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1121                    }
1122    
1123                    String sql = query.toString();
1124    
1125                    Query q = session.createQuery(sql);
1126    
1127                    q.setFirstResult(0);
1128                    q.setMaxResults(2);
1129    
1130                    QueryPos qPos = QueryPos.getInstance(q);
1131    
1132                    qPos.add(categoryId);
1133    
1134                    if (orderByComparator != null) {
1135                            Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1136    
1137                            for (Object value : values) {
1138                                    qPos.add(value);
1139                            }
1140                    }
1141    
1142                    List<AssetCategoryProperty> list = q.list();
1143    
1144                    if (list.size() == 2) {
1145                            return list.get(1);
1146                    }
1147                    else {
1148                            return null;
1149                    }
1150            }
1151    
1152            /**
1153             * Finds all the asset category properties where companyId = &#63; and key = &#63;.
1154             *
1155             * @param companyId the company id to search with
1156             * @param key the key to search with
1157             * @return the matching asset category properties
1158             * @throws SystemException if a system exception occurred
1159             */
1160            public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1161                    throws SystemException {
1162                    return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1163                            null);
1164            }
1165    
1166            /**
1167             * Finds a range of all the asset category properties where companyId = &#63; and key = &#63;.
1168             *
1169             * <p>
1170             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1171             * </p>
1172             *
1173             * @param companyId the company id to search with
1174             * @param key the key to search with
1175             * @param start the lower bound of the range of asset category properties to return
1176             * @param end the upper bound of the range of asset category properties to return (not inclusive)
1177             * @return the range of matching asset category properties
1178             * @throws SystemException if a system exception occurred
1179             */
1180            public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1181                    int start, int end) throws SystemException {
1182                    return findByC_K(companyId, key, start, end, null);
1183            }
1184    
1185            /**
1186             * Finds an ordered range of all the asset category properties where companyId = &#63; and key = &#63;.
1187             *
1188             * <p>
1189             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1190             * </p>
1191             *
1192             * @param companyId the company id to search with
1193             * @param key the key to search with
1194             * @param start the lower bound of the range of asset category properties to return
1195             * @param end the upper bound of the range of asset category properties to return (not inclusive)
1196             * @param orderByComparator the comparator to order the results by
1197             * @return the ordered range of matching asset category properties
1198             * @throws SystemException if a system exception occurred
1199             */
1200            public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1201                    int start, int end, OrderByComparator orderByComparator)
1202                    throws SystemException {
1203                    Object[] finderArgs = new Object[] {
1204                                    companyId, key,
1205                                    
1206                                    String.valueOf(start), String.valueOf(end),
1207                                    String.valueOf(orderByComparator)
1208                            };
1209    
1210                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_K,
1211                                    finderArgs, this);
1212    
1213                    if (list == null) {
1214                            Session session = null;
1215    
1216                            try {
1217                                    session = openSession();
1218    
1219                                    StringBundler query = null;
1220    
1221                                    if (orderByComparator != null) {
1222                                            query = new StringBundler(4 +
1223                                                            (orderByComparator.getOrderByFields().length * 3));
1224                                    }
1225                                    else {
1226                                            query = new StringBundler(4);
1227                                    }
1228    
1229                                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1230    
1231                                    query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1232    
1233                                    if (key == null) {
1234                                            query.append(_FINDER_COLUMN_C_K_KEY_1);
1235                                    }
1236                                    else {
1237                                            if (key.equals(StringPool.BLANK)) {
1238                                                    query.append(_FINDER_COLUMN_C_K_KEY_3);
1239                                            }
1240                                            else {
1241                                                    query.append(_FINDER_COLUMN_C_K_KEY_2);
1242                                            }
1243                                    }
1244    
1245                                    if (orderByComparator != null) {
1246                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1247                                                    orderByComparator);
1248                                    }
1249    
1250                                    else {
1251                                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1252                                    }
1253    
1254                                    String sql = query.toString();
1255    
1256                                    Query q = session.createQuery(sql);
1257    
1258                                    QueryPos qPos = QueryPos.getInstance(q);
1259    
1260                                    qPos.add(companyId);
1261    
1262                                    if (key != null) {
1263                                            qPos.add(key);
1264                                    }
1265    
1266                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1267                                                    getDialect(), start, end);
1268                            }
1269                            catch (Exception e) {
1270                                    throw processException(e);
1271                            }
1272                            finally {
1273                                    if (list == null) {
1274                                            list = new ArrayList<AssetCategoryProperty>();
1275                                    }
1276    
1277                                    cacheResult(list);
1278    
1279                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_K, finderArgs,
1280                                            list);
1281    
1282                                    closeSession(session);
1283                            }
1284                    }
1285    
1286                    return list;
1287            }
1288    
1289            /**
1290             * Finds the first asset category property in the ordered set where companyId = &#63; and key = &#63;.
1291             *
1292             * <p>
1293             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1294             * </p>
1295             *
1296             * @param companyId the company id to search with
1297             * @param key the key to search with
1298             * @param orderByComparator the comparator to order the set by
1299             * @return the first matching asset category property
1300             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1301             * @throws SystemException if a system exception occurred
1302             */
1303            public AssetCategoryProperty findByC_K_First(long companyId, String key,
1304                    OrderByComparator orderByComparator)
1305                    throws NoSuchCategoryPropertyException, SystemException {
1306                    List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1307                                    orderByComparator);
1308    
1309                    if (list.isEmpty()) {
1310                            StringBundler msg = new StringBundler(6);
1311    
1312                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1313    
1314                            msg.append("companyId=");
1315                            msg.append(companyId);
1316    
1317                            msg.append(", key=");
1318                            msg.append(key);
1319    
1320                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1321    
1322                            throw new NoSuchCategoryPropertyException(msg.toString());
1323                    }
1324                    else {
1325                            return list.get(0);
1326                    }
1327            }
1328    
1329            /**
1330             * Finds the last asset category property in the ordered set where companyId = &#63; and key = &#63;.
1331             *
1332             * <p>
1333             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1334             * </p>
1335             *
1336             * @param companyId the company id to search with
1337             * @param key the key to search with
1338             * @param orderByComparator the comparator to order the set by
1339             * @return the last matching asset category property
1340             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1341             * @throws SystemException if a system exception occurred
1342             */
1343            public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1344                    OrderByComparator orderByComparator)
1345                    throws NoSuchCategoryPropertyException, SystemException {
1346                    int count = countByC_K(companyId, key);
1347    
1348                    List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1349                                    count, orderByComparator);
1350    
1351                    if (list.isEmpty()) {
1352                            StringBundler msg = new StringBundler(6);
1353    
1354                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1355    
1356                            msg.append("companyId=");
1357                            msg.append(companyId);
1358    
1359                            msg.append(", key=");
1360                            msg.append(key);
1361    
1362                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1363    
1364                            throw new NoSuchCategoryPropertyException(msg.toString());
1365                    }
1366                    else {
1367                            return list.get(0);
1368                    }
1369            }
1370    
1371            /**
1372             * Finds the asset category properties before and after the current asset category property in the ordered set where companyId = &#63; and key = &#63;.
1373             *
1374             * <p>
1375             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1376             * </p>
1377             *
1378             * @param categoryPropertyId the primary key of the current asset category property
1379             * @param companyId the company id to search with
1380             * @param key the key to search with
1381             * @param orderByComparator the comparator to order the set by
1382             * @return the previous, current, and next asset category property
1383             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
1384             * @throws SystemException if a system exception occurred
1385             */
1386            public AssetCategoryProperty[] findByC_K_PrevAndNext(
1387                    long categoryPropertyId, long companyId, String key,
1388                    OrderByComparator orderByComparator)
1389                    throws NoSuchCategoryPropertyException, SystemException {
1390                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1391    
1392                    Session session = null;
1393    
1394                    try {
1395                            session = openSession();
1396    
1397                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1398    
1399                            array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1400                                            companyId, key, orderByComparator, true);
1401    
1402                            array[1] = assetCategoryProperty;
1403    
1404                            array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1405                                            companyId, key, orderByComparator, false);
1406    
1407                            return array;
1408                    }
1409                    catch (Exception e) {
1410                            throw processException(e);
1411                    }
1412                    finally {
1413                            closeSession(session);
1414                    }
1415            }
1416    
1417            protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1418                    AssetCategoryProperty assetCategoryProperty, long companyId,
1419                    String key, OrderByComparator orderByComparator, boolean previous) {
1420                    StringBundler query = null;
1421    
1422                    if (orderByComparator != null) {
1423                            query = new StringBundler(6 +
1424                                            (orderByComparator.getOrderByFields().length * 6));
1425                    }
1426                    else {
1427                            query = new StringBundler(3);
1428                    }
1429    
1430                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1431    
1432                    query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1433    
1434                    if (key == null) {
1435                            query.append(_FINDER_COLUMN_C_K_KEY_1);
1436                    }
1437                    else {
1438                            if (key.equals(StringPool.BLANK)) {
1439                                    query.append(_FINDER_COLUMN_C_K_KEY_3);
1440                            }
1441                            else {
1442                                    query.append(_FINDER_COLUMN_C_K_KEY_2);
1443                            }
1444                    }
1445    
1446                    if (orderByComparator != null) {
1447                            String[] orderByFields = orderByComparator.getOrderByFields();
1448    
1449                            if (orderByFields.length > 0) {
1450                                    query.append(WHERE_AND);
1451                            }
1452    
1453                            for (int i = 0; i < orderByFields.length; i++) {
1454                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1455                                    query.append(orderByFields[i]);
1456    
1457                                    if ((i + 1) < orderByFields.length) {
1458                                            if (orderByComparator.isAscending() ^ previous) {
1459                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1460                                            }
1461                                            else {
1462                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1463                                            }
1464                                    }
1465                                    else {
1466                                            if (orderByComparator.isAscending() ^ previous) {
1467                                                    query.append(WHERE_GREATER_THAN);
1468                                            }
1469                                            else {
1470                                                    query.append(WHERE_LESSER_THAN);
1471                                            }
1472                                    }
1473                            }
1474    
1475                            query.append(ORDER_BY_CLAUSE);
1476    
1477                            for (int i = 0; i < orderByFields.length; i++) {
1478                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1479                                    query.append(orderByFields[i]);
1480    
1481                                    if ((i + 1) < orderByFields.length) {
1482                                            if (orderByComparator.isAscending() ^ previous) {
1483                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1484                                            }
1485                                            else {
1486                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1487                                            }
1488                                    }
1489                                    else {
1490                                            if (orderByComparator.isAscending() ^ previous) {
1491                                                    query.append(ORDER_BY_ASC);
1492                                            }
1493                                            else {
1494                                                    query.append(ORDER_BY_DESC);
1495                                            }
1496                                    }
1497                            }
1498                    }
1499    
1500                    else {
1501                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1502                    }
1503    
1504                    String sql = query.toString();
1505    
1506                    Query q = session.createQuery(sql);
1507    
1508                    q.setFirstResult(0);
1509                    q.setMaxResults(2);
1510    
1511                    QueryPos qPos = QueryPos.getInstance(q);
1512    
1513                    qPos.add(companyId);
1514    
1515                    if (key != null) {
1516                            qPos.add(key);
1517                    }
1518    
1519                    if (orderByComparator != null) {
1520                            Object[] values = orderByComparator.getOrderByValues(assetCategoryProperty);
1521    
1522                            for (Object value : values) {
1523                                    qPos.add(value);
1524                            }
1525                    }
1526    
1527                    List<AssetCategoryProperty> list = q.list();
1528    
1529                    if (list.size() == 2) {
1530                            return list.get(1);
1531                    }
1532                    else {
1533                            return null;
1534                    }
1535            }
1536    
1537            /**
1538             * Finds the asset category property where categoryId = &#63; and key = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryPropertyException} if it could not be found.
1539             *
1540             * @param categoryId the category id to search with
1541             * @param key the key to search with
1542             * @return the matching asset category property
1543             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1544             * @throws SystemException if a system exception occurred
1545             */
1546            public AssetCategoryProperty findByCA_K(long categoryId, String key)
1547                    throws NoSuchCategoryPropertyException, SystemException {
1548                    AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1549                                    key);
1550    
1551                    if (assetCategoryProperty == null) {
1552                            StringBundler msg = new StringBundler(6);
1553    
1554                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1555    
1556                            msg.append("categoryId=");
1557                            msg.append(categoryId);
1558    
1559                            msg.append(", key=");
1560                            msg.append(key);
1561    
1562                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1563    
1564                            if (_log.isWarnEnabled()) {
1565                                    _log.warn(msg.toString());
1566                            }
1567    
1568                            throw new NoSuchCategoryPropertyException(msg.toString());
1569                    }
1570    
1571                    return assetCategoryProperty;
1572            }
1573    
1574            /**
1575             * Finds the asset category property where categoryId = &#63; and key = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1576             *
1577             * @param categoryId the category id to search with
1578             * @param key the key to search with
1579             * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found
1580             * @throws SystemException if a system exception occurred
1581             */
1582            public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1583                    throws SystemException {
1584                    return fetchByCA_K(categoryId, key, true);
1585            }
1586    
1587            /**
1588             * Finds the asset category property where categoryId = &#63; and key = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1589             *
1590             * @param categoryId the category id to search with
1591             * @param key the key to search with
1592             * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found
1593             * @throws SystemException if a system exception occurred
1594             */
1595            public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1596                    boolean retrieveFromCache) throws SystemException {
1597                    Object[] finderArgs = new Object[] { categoryId, key };
1598    
1599                    Object result = null;
1600    
1601                    if (retrieveFromCache) {
1602                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1603                                            finderArgs, this);
1604                    }
1605    
1606                    if (result == null) {
1607                            Session session = null;
1608    
1609                            try {
1610                                    session = openSession();
1611    
1612                                    StringBundler query = new StringBundler(4);
1613    
1614                                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1615    
1616                                    query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1617    
1618                                    if (key == null) {
1619                                            query.append(_FINDER_COLUMN_CA_K_KEY_1);
1620                                    }
1621                                    else {
1622                                            if (key.equals(StringPool.BLANK)) {
1623                                                    query.append(_FINDER_COLUMN_CA_K_KEY_3);
1624                                            }
1625                                            else {
1626                                                    query.append(_FINDER_COLUMN_CA_K_KEY_2);
1627                                            }
1628                                    }
1629    
1630                                    query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1631    
1632                                    String sql = query.toString();
1633    
1634                                    Query q = session.createQuery(sql);
1635    
1636                                    QueryPos qPos = QueryPos.getInstance(q);
1637    
1638                                    qPos.add(categoryId);
1639    
1640                                    if (key != null) {
1641                                            qPos.add(key);
1642                                    }
1643    
1644                                    List<AssetCategoryProperty> list = q.list();
1645    
1646                                    result = list;
1647    
1648                                    AssetCategoryProperty assetCategoryProperty = null;
1649    
1650                                    if (list.isEmpty()) {
1651                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1652                                                    finderArgs, list);
1653                                    }
1654                                    else {
1655                                            assetCategoryProperty = list.get(0);
1656    
1657                                            cacheResult(assetCategoryProperty);
1658    
1659                                            if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1660                                                            (assetCategoryProperty.getKey() == null) ||
1661                                                            !assetCategoryProperty.getKey().equals(key)) {
1662                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1663                                                            finderArgs, assetCategoryProperty);
1664                                            }
1665                                    }
1666    
1667                                    return assetCategoryProperty;
1668                            }
1669                            catch (Exception e) {
1670                                    throw processException(e);
1671                            }
1672                            finally {
1673                                    if (result == null) {
1674                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1675                                                    finderArgs, new ArrayList<AssetCategoryProperty>());
1676                                    }
1677    
1678                                    closeSession(session);
1679                            }
1680                    }
1681                    else {
1682                            if (result instanceof List<?>) {
1683                                    return null;
1684                            }
1685                            else {
1686                                    return (AssetCategoryProperty)result;
1687                            }
1688                    }
1689            }
1690    
1691            /**
1692             * Finds all the asset category properties.
1693             *
1694             * @return the asset category properties
1695             * @throws SystemException if a system exception occurred
1696             */
1697            public List<AssetCategoryProperty> findAll() throws SystemException {
1698                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1699            }
1700    
1701            /**
1702             * Finds a range of all the asset category properties.
1703             *
1704             * <p>
1705             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1706             * </p>
1707             *
1708             * @param start the lower bound of the range of asset category properties to return
1709             * @param end the upper bound of the range of asset category properties to return (not inclusive)
1710             * @return the range of asset category properties
1711             * @throws SystemException if a system exception occurred
1712             */
1713            public List<AssetCategoryProperty> findAll(int start, int end)
1714                    throws SystemException {
1715                    return findAll(start, end, null);
1716            }
1717    
1718            /**
1719             * Finds an ordered range of all the asset category properties.
1720             *
1721             * <p>
1722             * 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 com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1723             * </p>
1724             *
1725             * @param start the lower bound of the range of asset category properties to return
1726             * @param end the upper bound of the range of asset category properties to return (not inclusive)
1727             * @param orderByComparator the comparator to order the results by
1728             * @return the ordered range of asset category properties
1729             * @throws SystemException if a system exception occurred
1730             */
1731            public List<AssetCategoryProperty> findAll(int start, int end,
1732                    OrderByComparator orderByComparator) throws SystemException {
1733                    Object[] finderArgs = new Object[] {
1734                                    String.valueOf(start), String.valueOf(end),
1735                                    String.valueOf(orderByComparator)
1736                            };
1737    
1738                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1739                                    finderArgs, this);
1740    
1741                    if (list == null) {
1742                            Session session = null;
1743    
1744                            try {
1745                                    session = openSession();
1746    
1747                                    StringBundler query = null;
1748                                    String sql = null;
1749    
1750                                    if (orderByComparator != null) {
1751                                            query = new StringBundler(2 +
1752                                                            (orderByComparator.getOrderByFields().length * 3));
1753    
1754                                            query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
1755    
1756                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1757                                                    orderByComparator);
1758    
1759                                            sql = query.toString();
1760                                    }
1761                                    else {
1762                                            sql = _SQL_SELECT_ASSETCATEGORYPROPERTY.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1763                                    }
1764    
1765                                    Query q = session.createQuery(sql);
1766    
1767                                    if (orderByComparator == null) {
1768                                            list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1769                                                            getDialect(), start, end, false);
1770    
1771                                            Collections.sort(list);
1772                                    }
1773                                    else {
1774                                            list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1775                                                            getDialect(), start, end);
1776                                    }
1777                            }
1778                            catch (Exception e) {
1779                                    throw processException(e);
1780                            }
1781                            finally {
1782                                    if (list == null) {
1783                                            list = new ArrayList<AssetCategoryProperty>();
1784                                    }
1785    
1786                                    cacheResult(list);
1787    
1788                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1789    
1790                                    closeSession(session);
1791                            }
1792                    }
1793    
1794                    return list;
1795            }
1796    
1797            /**
1798             * Removes all the asset category properties where companyId = &#63; from the database.
1799             *
1800             * @param companyId the company id to search with
1801             * @throws SystemException if a system exception occurred
1802             */
1803            public void removeByCompanyId(long companyId) throws SystemException {
1804                    for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
1805                                    companyId)) {
1806                            remove(assetCategoryProperty);
1807                    }
1808            }
1809    
1810            /**
1811             * Removes all the asset category properties where categoryId = &#63; from the database.
1812             *
1813             * @param categoryId the category id to search with
1814             * @throws SystemException if a system exception occurred
1815             */
1816            public void removeByCategoryId(long categoryId) throws SystemException {
1817                    for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
1818                                    categoryId)) {
1819                            remove(assetCategoryProperty);
1820                    }
1821            }
1822    
1823            /**
1824             * Removes all the asset category properties where companyId = &#63; and key = &#63; from the database.
1825             *
1826             * @param companyId the company id to search with
1827             * @param key the key to search with
1828             * @throws SystemException if a system exception occurred
1829             */
1830            public void removeByC_K(long companyId, String key)
1831                    throws SystemException {
1832                    for (AssetCategoryProperty assetCategoryProperty : findByC_K(
1833                                    companyId, key)) {
1834                            remove(assetCategoryProperty);
1835                    }
1836            }
1837    
1838            /**
1839             * Removes the asset category property where categoryId = &#63; and key = &#63; from the database.
1840             *
1841             * @param categoryId the category id to search with
1842             * @param key the key to search with
1843             * @throws SystemException if a system exception occurred
1844             */
1845            public void removeByCA_K(long categoryId, String key)
1846                    throws NoSuchCategoryPropertyException, SystemException {
1847                    AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
1848    
1849                    remove(assetCategoryProperty);
1850            }
1851    
1852            /**
1853             * Removes all the asset category properties from the database.
1854             *
1855             * @throws SystemException if a system exception occurred
1856             */
1857            public void removeAll() throws SystemException {
1858                    for (AssetCategoryProperty assetCategoryProperty : findAll()) {
1859                            remove(assetCategoryProperty);
1860                    }
1861            }
1862    
1863            /**
1864             * Counts all the asset category properties where companyId = &#63;.
1865             *
1866             * @param companyId the company id to search with
1867             * @return the number of matching asset category properties
1868             * @throws SystemException if a system exception occurred
1869             */
1870            public int countByCompanyId(long companyId) throws SystemException {
1871                    Object[] finderArgs = new Object[] { companyId };
1872    
1873                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1874                                    finderArgs, this);
1875    
1876                    if (count == null) {
1877                            Session session = null;
1878    
1879                            try {
1880                                    session = openSession();
1881    
1882                                    StringBundler query = new StringBundler(2);
1883    
1884                                    query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1885    
1886                                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1887    
1888                                    String sql = query.toString();
1889    
1890                                    Query q = session.createQuery(sql);
1891    
1892                                    QueryPos qPos = QueryPos.getInstance(q);
1893    
1894                                    qPos.add(companyId);
1895    
1896                                    count = (Long)q.uniqueResult();
1897                            }
1898                            catch (Exception e) {
1899                                    throw processException(e);
1900                            }
1901                            finally {
1902                                    if (count == null) {
1903                                            count = Long.valueOf(0);
1904                                    }
1905    
1906                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1907                                            finderArgs, count);
1908    
1909                                    closeSession(session);
1910                            }
1911                    }
1912    
1913                    return count.intValue();
1914            }
1915    
1916            /**
1917             * Counts all the asset category properties where categoryId = &#63;.
1918             *
1919             * @param categoryId the category id to search with
1920             * @return the number of matching asset category properties
1921             * @throws SystemException if a system exception occurred
1922             */
1923            public int countByCategoryId(long categoryId) throws SystemException {
1924                    Object[] finderArgs = new Object[] { categoryId };
1925    
1926                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1927                                    finderArgs, this);
1928    
1929                    if (count == null) {
1930                            Session session = null;
1931    
1932                            try {
1933                                    session = openSession();
1934    
1935                                    StringBundler query = new StringBundler(2);
1936    
1937                                    query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1938    
1939                                    query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1940    
1941                                    String sql = query.toString();
1942    
1943                                    Query q = session.createQuery(sql);
1944    
1945                                    QueryPos qPos = QueryPos.getInstance(q);
1946    
1947                                    qPos.add(categoryId);
1948    
1949                                    count = (Long)q.uniqueResult();
1950                            }
1951                            catch (Exception e) {
1952                                    throw processException(e);
1953                            }
1954                            finally {
1955                                    if (count == null) {
1956                                            count = Long.valueOf(0);
1957                                    }
1958    
1959                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
1960                                            finderArgs, count);
1961    
1962                                    closeSession(session);
1963                            }
1964                    }
1965    
1966                    return count.intValue();
1967            }
1968    
1969            /**
1970             * Counts all the asset category properties where companyId = &#63; and key = &#63;.
1971             *
1972             * @param companyId the company id to search with
1973             * @param key the key to search with
1974             * @return the number of matching asset category properties
1975             * @throws SystemException if a system exception occurred
1976             */
1977            public int countByC_K(long companyId, String key) throws SystemException {
1978                    Object[] finderArgs = new Object[] { companyId, key };
1979    
1980                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
1981                                    finderArgs, this);
1982    
1983                    if (count == null) {
1984                            Session session = null;
1985    
1986                            try {
1987                                    session = openSession();
1988    
1989                                    StringBundler query = new StringBundler(3);
1990    
1991                                    query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
1992    
1993                                    query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1994    
1995                                    if (key == null) {
1996                                            query.append(_FINDER_COLUMN_C_K_KEY_1);
1997                                    }
1998                                    else {
1999                                            if (key.equals(StringPool.BLANK)) {
2000                                                    query.append(_FINDER_COLUMN_C_K_KEY_3);
2001                                            }
2002                                            else {
2003                                                    query.append(_FINDER_COLUMN_C_K_KEY_2);
2004                                            }
2005                                    }
2006    
2007                                    String sql = query.toString();
2008    
2009                                    Query q = session.createQuery(sql);
2010    
2011                                    QueryPos qPos = QueryPos.getInstance(q);
2012    
2013                                    qPos.add(companyId);
2014    
2015                                    if (key != null) {
2016                                            qPos.add(key);
2017                                    }
2018    
2019                                    count = (Long)q.uniqueResult();
2020                            }
2021                            catch (Exception e) {
2022                                    throw processException(e);
2023                            }
2024                            finally {
2025                                    if (count == null) {
2026                                            count = Long.valueOf(0);
2027                                    }
2028    
2029                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
2030                                            count);
2031    
2032                                    closeSession(session);
2033                            }
2034                    }
2035    
2036                    return count.intValue();
2037            }
2038    
2039            /**
2040             * Counts all the asset category properties where categoryId = &#63; and key = &#63;.
2041             *
2042             * @param categoryId the category id to search with
2043             * @param key the key to search with
2044             * @return the number of matching asset category properties
2045             * @throws SystemException if a system exception occurred
2046             */
2047            public int countByCA_K(long categoryId, String key)
2048                    throws SystemException {
2049                    Object[] finderArgs = new Object[] { categoryId, key };
2050    
2051                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CA_K,
2052                                    finderArgs, this);
2053    
2054                    if (count == null) {
2055                            Session session = null;
2056    
2057                            try {
2058                                    session = openSession();
2059    
2060                                    StringBundler query = new StringBundler(3);
2061    
2062                                    query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2063    
2064                                    query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
2065    
2066                                    if (key == null) {
2067                                            query.append(_FINDER_COLUMN_CA_K_KEY_1);
2068                                    }
2069                                    else {
2070                                            if (key.equals(StringPool.BLANK)) {
2071                                                    query.append(_FINDER_COLUMN_CA_K_KEY_3);
2072                                            }
2073                                            else {
2074                                                    query.append(_FINDER_COLUMN_CA_K_KEY_2);
2075                                            }
2076                                    }
2077    
2078                                    String sql = query.toString();
2079    
2080                                    Query q = session.createQuery(sql);
2081    
2082                                    QueryPos qPos = QueryPos.getInstance(q);
2083    
2084                                    qPos.add(categoryId);
2085    
2086                                    if (key != null) {
2087                                            qPos.add(key);
2088                                    }
2089    
2090                                    count = (Long)q.uniqueResult();
2091                            }
2092                            catch (Exception e) {
2093                                    throw processException(e);
2094                            }
2095                            finally {
2096                                    if (count == null) {
2097                                            count = Long.valueOf(0);
2098                                    }
2099    
2100                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K,
2101                                            finderArgs, count);
2102    
2103                                    closeSession(session);
2104                            }
2105                    }
2106    
2107                    return count.intValue();
2108            }
2109    
2110            /**
2111             * Counts all the asset category properties.
2112             *
2113             * @return the number of asset category properties
2114             * @throws SystemException if a system exception occurred
2115             */
2116            public int countAll() throws SystemException {
2117                    Object[] finderArgs = new Object[0];
2118    
2119                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2120                                    finderArgs, this);
2121    
2122                    if (count == null) {
2123                            Session session = null;
2124    
2125                            try {
2126                                    session = openSession();
2127    
2128                                    Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2129    
2130                                    count = (Long)q.uniqueResult();
2131                            }
2132                            catch (Exception e) {
2133                                    throw processException(e);
2134                            }
2135                            finally {
2136                                    if (count == null) {
2137                                            count = Long.valueOf(0);
2138                                    }
2139    
2140                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2141                                            count);
2142    
2143                                    closeSession(session);
2144                            }
2145                    }
2146    
2147                    return count.intValue();
2148            }
2149    
2150            /**
2151             * Initializes the asset category property persistence.
2152             */
2153            public void afterPropertiesSet() {
2154                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2155                                            com.liferay.portal.util.PropsUtil.get(
2156                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2157    
2158                    if (listenerClassNames.length > 0) {
2159                            try {
2160                                    List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2161    
2162                                    for (String listenerClassName : listenerClassNames) {
2163                                            listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2164                                                            listenerClassName));
2165                                    }
2166    
2167                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2168                            }
2169                            catch (Exception e) {
2170                                    _log.error(e);
2171                            }
2172                    }
2173            }
2174    
2175            public void destroy() {
2176                    EntityCacheUtil.removeCache(AssetCategoryPropertyImpl.class.getName());
2177                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2178                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
2179            }
2180    
2181            @BeanReference(type = AssetCategoryPersistence.class)
2182            protected AssetCategoryPersistence assetCategoryPersistence;
2183            @BeanReference(type = AssetCategoryPropertyPersistence.class)
2184            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2185            @BeanReference(type = AssetEntryPersistence.class)
2186            protected AssetEntryPersistence assetEntryPersistence;
2187            @BeanReference(type = AssetLinkPersistence.class)
2188            protected AssetLinkPersistence assetLinkPersistence;
2189            @BeanReference(type = AssetTagPersistence.class)
2190            protected AssetTagPersistence assetTagPersistence;
2191            @BeanReference(type = AssetTagPropertyPersistence.class)
2192            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2193            @BeanReference(type = AssetTagStatsPersistence.class)
2194            protected AssetTagStatsPersistence assetTagStatsPersistence;
2195            @BeanReference(type = AssetVocabularyPersistence.class)
2196            protected AssetVocabularyPersistence assetVocabularyPersistence;
2197            @BeanReference(type = ResourcePersistence.class)
2198            protected ResourcePersistence resourcePersistence;
2199            @BeanReference(type = UserPersistence.class)
2200            protected UserPersistence userPersistence;
2201            private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2202            private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2203            private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2204            private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2205            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
2206            private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
2207            private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
2208            private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2209            private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
2210            private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2211            private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
2212            private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2213            private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
2214            private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2215            private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2216            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2217            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2218            private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2219    }