001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.kernel.bean.BeanReference;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
020    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
021    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
025    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderPath;
027    import com.liferay.portal.kernel.dao.orm.Query;
028    import com.liferay.portal.kernel.dao.orm.QueryPos;
029    import com.liferay.portal.kernel.dao.orm.QueryUtil;
030    import com.liferay.portal.kernel.dao.orm.SQLQuery;
031    import com.liferay.portal.kernel.dao.orm.Session;
032    import com.liferay.portal.kernel.exception.SystemException;
033    import com.liferay.portal.kernel.log.Log;
034    import com.liferay.portal.kernel.log.LogFactoryUtil;
035    import com.liferay.portal.kernel.util.ArrayUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.kernel.util.UnmodifiableList;
044    import com.liferay.portal.kernel.util.Validator;
045    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046    import com.liferay.portal.model.CacheModel;
047    import com.liferay.portal.model.ModelListener;
048    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
049    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
050    
051    import com.liferay.portlet.asset.NoSuchCategoryException;
052    import com.liferay.portlet.asset.model.AssetCategory;
053    import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
054    import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
055    
056    import java.io.Serializable;
057    
058    import java.util.ArrayList;
059    import java.util.Collections;
060    import java.util.List;
061    import java.util.Set;
062    
063    /**
064     * The persistence implementation for the asset category service.
065     *
066     * <p>
067     * Caching information and settings can be found in <code>portal.properties</code>
068     * </p>
069     *
070     * @author Brian Wing Shun Chan
071     * @see AssetCategoryPersistence
072     * @see AssetCategoryUtil
073     * @generated
074     */
075    public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
076            implements AssetCategoryPersistence {
077            /*
078             * NOTE FOR DEVELOPERS:
079             *
080             * Never modify or reference this class directly. Always use {@link AssetCategoryUtil} to access the asset category persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
081             */
082            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
083            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
084                    ".List1";
085            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List2";
087            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
088                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
089                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
090                            "findAll", new String[0]);
091            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
092                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
093                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
094                            "findAll", new String[0]);
095            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
096                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
097                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
098            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
099                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
100                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
101                            "findByUuid",
102                            new String[] {
103                                    String.class.getName(),
104                                    
105                            Integer.class.getName(), Integer.class.getName(),
106                                    OrderByComparator.class.getName()
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
109                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
110                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
111                            "findByUuid", new String[] { String.class.getName() },
112                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
113                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
114            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
115                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
117                            new String[] { String.class.getName() });
118    
119            /**
120             * Returns all the asset categories where uuid = &#63;.
121             *
122             * @param uuid the uuid
123             * @return the matching asset categories
124             * @throws SystemException if a system exception occurred
125             */
126            @Override
127            public List<AssetCategory> findByUuid(String uuid)
128                    throws SystemException {
129                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
130            }
131    
132            /**
133             * Returns a range of all the asset categories where uuid = &#63;.
134             *
135             * <p>
136             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
137             * </p>
138             *
139             * @param uuid the uuid
140             * @param start the lower bound of the range of asset categories
141             * @param end the upper bound of the range of asset categories (not inclusive)
142             * @return the range of matching asset categories
143             * @throws SystemException if a system exception occurred
144             */
145            @Override
146            public List<AssetCategory> findByUuid(String uuid, int start, int end)
147                    throws SystemException {
148                    return findByUuid(uuid, start, end, null);
149            }
150    
151            /**
152             * Returns an ordered range of all the asset categories where uuid = &#63;.
153             *
154             * <p>
155             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
156             * </p>
157             *
158             * @param uuid the uuid
159             * @param start the lower bound of the range of asset categories
160             * @param end the upper bound of the range of asset categories (not inclusive)
161             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
162             * @return the ordered range of matching asset categories
163             * @throws SystemException if a system exception occurred
164             */
165            @Override
166            public List<AssetCategory> findByUuid(String uuid, int start, int end,
167                    OrderByComparator orderByComparator) throws SystemException {
168                    boolean pagination = true;
169                    FinderPath finderPath = null;
170                    Object[] finderArgs = null;
171    
172                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
173                                    (orderByComparator == null)) {
174                            pagination = false;
175                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
176                            finderArgs = new Object[] { uuid };
177                    }
178                    else {
179                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
180                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
181                    }
182    
183                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
184                                    finderArgs, this);
185    
186                    if ((list != null) && !list.isEmpty()) {
187                            for (AssetCategory assetCategory : list) {
188                                    if (!Validator.equals(uuid, assetCategory.getUuid())) {
189                                            list = null;
190    
191                                            break;
192                                    }
193                            }
194                    }
195    
196                    if (list == null) {
197                            StringBundler query = null;
198    
199                            if (orderByComparator != null) {
200                                    query = new StringBundler(3 +
201                                                    (orderByComparator.getOrderByFields().length * 3));
202                            }
203                            else {
204                                    query = new StringBundler(3);
205                            }
206    
207                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
208    
209                            boolean bindUuid = false;
210    
211                            if (uuid == null) {
212                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
213                            }
214                            else if (uuid.equals(StringPool.BLANK)) {
215                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
216                            }
217                            else {
218                                    bindUuid = true;
219    
220                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
221                            }
222    
223                            if (orderByComparator != null) {
224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
225                                            orderByComparator);
226                            }
227                            else
228                             if (pagination) {
229                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
230                            }
231    
232                            String sql = query.toString();
233    
234                            Session session = null;
235    
236                            try {
237                                    session = openSession();
238    
239                                    Query q = session.createQuery(sql);
240    
241                                    QueryPos qPos = QueryPos.getInstance(q);
242    
243                                    if (bindUuid) {
244                                            qPos.add(uuid);
245                                    }
246    
247                                    if (!pagination) {
248                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
249                                                            start, end, false);
250    
251                                            Collections.sort(list);
252    
253                                            list = new UnmodifiableList<AssetCategory>(list);
254                                    }
255                                    else {
256                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
257                                                            start, end);
258                                    }
259    
260                                    cacheResult(list);
261    
262                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
263                            }
264                            catch (Exception e) {
265                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
266    
267                                    throw processException(e);
268                            }
269                            finally {
270                                    closeSession(session);
271                            }
272                    }
273    
274                    return list;
275            }
276    
277            /**
278             * Returns the first asset category in the ordered set where uuid = &#63;.
279             *
280             * @param uuid the uuid
281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
282             * @return the first matching asset category
283             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
284             * @throws SystemException if a system exception occurred
285             */
286            @Override
287            public AssetCategory findByUuid_First(String uuid,
288                    OrderByComparator orderByComparator)
289                    throws NoSuchCategoryException, SystemException {
290                    AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
291    
292                    if (assetCategory != null) {
293                            return assetCategory;
294                    }
295    
296                    StringBundler msg = new StringBundler(4);
297    
298                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
299    
300                    msg.append("uuid=");
301                    msg.append(uuid);
302    
303                    msg.append(StringPool.CLOSE_CURLY_BRACE);
304    
305                    throw new NoSuchCategoryException(msg.toString());
306            }
307    
308            /**
309             * Returns the first asset category in the ordered set where uuid = &#63;.
310             *
311             * @param uuid the uuid
312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
313             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
314             * @throws SystemException if a system exception occurred
315             */
316            @Override
317            public AssetCategory fetchByUuid_First(String uuid,
318                    OrderByComparator orderByComparator) throws SystemException {
319                    List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
320    
321                    if (!list.isEmpty()) {
322                            return list.get(0);
323                    }
324    
325                    return null;
326            }
327    
328            /**
329             * Returns the last asset category in the ordered set where uuid = &#63;.
330             *
331             * @param uuid the uuid
332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
333             * @return the last matching asset category
334             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
335             * @throws SystemException if a system exception occurred
336             */
337            @Override
338            public AssetCategory findByUuid_Last(String uuid,
339                    OrderByComparator orderByComparator)
340                    throws NoSuchCategoryException, SystemException {
341                    AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
342    
343                    if (assetCategory != null) {
344                            return assetCategory;
345                    }
346    
347                    StringBundler msg = new StringBundler(4);
348    
349                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
350    
351                    msg.append("uuid=");
352                    msg.append(uuid);
353    
354                    msg.append(StringPool.CLOSE_CURLY_BRACE);
355    
356                    throw new NoSuchCategoryException(msg.toString());
357            }
358    
359            /**
360             * Returns the last asset category in the ordered set where uuid = &#63;.
361             *
362             * @param uuid the uuid
363             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
364             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
365             * @throws SystemException if a system exception occurred
366             */
367            @Override
368            public AssetCategory fetchByUuid_Last(String uuid,
369                    OrderByComparator orderByComparator) throws SystemException {
370                    int count = countByUuid(uuid);
371    
372                    if (count == 0) {
373                            return null;
374                    }
375    
376                    List<AssetCategory> list = findByUuid(uuid, count - 1, count,
377                                    orderByComparator);
378    
379                    if (!list.isEmpty()) {
380                            return list.get(0);
381                    }
382    
383                    return null;
384            }
385    
386            /**
387             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63;.
388             *
389             * @param categoryId the primary key of the current asset category
390             * @param uuid the uuid
391             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
392             * @return the previous, current, and next asset category
393             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
394             * @throws SystemException if a system exception occurred
395             */
396            @Override
397            public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
398                    OrderByComparator orderByComparator)
399                    throws NoSuchCategoryException, SystemException {
400                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
401    
402                    Session session = null;
403    
404                    try {
405                            session = openSession();
406    
407                            AssetCategory[] array = new AssetCategoryImpl[3];
408    
409                            array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
410                                            orderByComparator, true);
411    
412                            array[1] = assetCategory;
413    
414                            array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
415                                            orderByComparator, false);
416    
417                            return array;
418                    }
419                    catch (Exception e) {
420                            throw processException(e);
421                    }
422                    finally {
423                            closeSession(session);
424                    }
425            }
426    
427            protected AssetCategory getByUuid_PrevAndNext(Session session,
428                    AssetCategory assetCategory, String uuid,
429                    OrderByComparator orderByComparator, boolean previous) {
430                    StringBundler query = null;
431    
432                    if (orderByComparator != null) {
433                            query = new StringBundler(6 +
434                                            (orderByComparator.getOrderByFields().length * 6));
435                    }
436                    else {
437                            query = new StringBundler(3);
438                    }
439    
440                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
441    
442                    boolean bindUuid = false;
443    
444                    if (uuid == null) {
445                            query.append(_FINDER_COLUMN_UUID_UUID_1);
446                    }
447                    else if (uuid.equals(StringPool.BLANK)) {
448                            query.append(_FINDER_COLUMN_UUID_UUID_3);
449                    }
450                    else {
451                            bindUuid = true;
452    
453                            query.append(_FINDER_COLUMN_UUID_UUID_2);
454                    }
455    
456                    if (orderByComparator != null) {
457                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
458    
459                            if (orderByConditionFields.length > 0) {
460                                    query.append(WHERE_AND);
461                            }
462    
463                            for (int i = 0; i < orderByConditionFields.length; i++) {
464                                    query.append(_ORDER_BY_ENTITY_ALIAS);
465                                    query.append(orderByConditionFields[i]);
466    
467                                    if ((i + 1) < orderByConditionFields.length) {
468                                            if (orderByComparator.isAscending() ^ previous) {
469                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
470                                            }
471                                            else {
472                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
473                                            }
474                                    }
475                                    else {
476                                            if (orderByComparator.isAscending() ^ previous) {
477                                                    query.append(WHERE_GREATER_THAN);
478                                            }
479                                            else {
480                                                    query.append(WHERE_LESSER_THAN);
481                                            }
482                                    }
483                            }
484    
485                            query.append(ORDER_BY_CLAUSE);
486    
487                            String[] orderByFields = orderByComparator.getOrderByFields();
488    
489                            for (int i = 0; i < orderByFields.length; i++) {
490                                    query.append(_ORDER_BY_ENTITY_ALIAS);
491                                    query.append(orderByFields[i]);
492    
493                                    if ((i + 1) < orderByFields.length) {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
496                                            }
497                                            else {
498                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
499                                            }
500                                    }
501                                    else {
502                                            if (orderByComparator.isAscending() ^ previous) {
503                                                    query.append(ORDER_BY_ASC);
504                                            }
505                                            else {
506                                                    query.append(ORDER_BY_DESC);
507                                            }
508                                    }
509                            }
510                    }
511                    else {
512                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
513                    }
514    
515                    String sql = query.toString();
516    
517                    Query q = session.createQuery(sql);
518    
519                    q.setFirstResult(0);
520                    q.setMaxResults(2);
521    
522                    QueryPos qPos = QueryPos.getInstance(q);
523    
524                    if (bindUuid) {
525                            qPos.add(uuid);
526                    }
527    
528                    if (orderByComparator != null) {
529                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
530    
531                            for (Object value : values) {
532                                    qPos.add(value);
533                            }
534                    }
535    
536                    List<AssetCategory> list = q.list();
537    
538                    if (list.size() == 2) {
539                            return list.get(1);
540                    }
541                    else {
542                            return null;
543                    }
544            }
545    
546            /**
547             * Removes all the asset categories where uuid = &#63; from the database.
548             *
549             * @param uuid the uuid
550             * @throws SystemException if a system exception occurred
551             */
552            @Override
553            public void removeByUuid(String uuid) throws SystemException {
554                    for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
555                                    QueryUtil.ALL_POS, null)) {
556                            remove(assetCategory);
557                    }
558            }
559    
560            /**
561             * Returns the number of asset categories where uuid = &#63;.
562             *
563             * @param uuid the uuid
564             * @return the number of matching asset categories
565             * @throws SystemException if a system exception occurred
566             */
567            @Override
568            public int countByUuid(String uuid) throws SystemException {
569                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
570    
571                    Object[] finderArgs = new Object[] { uuid };
572    
573                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
574                                    this);
575    
576                    if (count == null) {
577                            StringBundler query = new StringBundler(2);
578    
579                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
580    
581                            boolean bindUuid = false;
582    
583                            if (uuid == null) {
584                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
585                            }
586                            else if (uuid.equals(StringPool.BLANK)) {
587                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
588                            }
589                            else {
590                                    bindUuid = true;
591    
592                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
593                            }
594    
595                            String sql = query.toString();
596    
597                            Session session = null;
598    
599                            try {
600                                    session = openSession();
601    
602                                    Query q = session.createQuery(sql);
603    
604                                    QueryPos qPos = QueryPos.getInstance(q);
605    
606                                    if (bindUuid) {
607                                            qPos.add(uuid);
608                                    }
609    
610                                    count = (Long)q.uniqueResult();
611    
612                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
613                            }
614                            catch (Exception e) {
615                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
616    
617                                    throw processException(e);
618                            }
619                            finally {
620                                    closeSession(session);
621                            }
622                    }
623    
624                    return count.intValue();
625            }
626    
627            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
628            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
629            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
630            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
631                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
632                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
633                            new String[] { String.class.getName(), Long.class.getName() },
634                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
635                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
636            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
637                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
638                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
639                            new String[] { String.class.getName(), Long.class.getName() });
640    
641            /**
642             * Returns the asset category where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
643             *
644             * @param uuid the uuid
645             * @param groupId the group ID
646             * @return the matching asset category
647             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
648             * @throws SystemException if a system exception occurred
649             */
650            @Override
651            public AssetCategory findByUUID_G(String uuid, long groupId)
652                    throws NoSuchCategoryException, SystemException {
653                    AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
654    
655                    if (assetCategory == null) {
656                            StringBundler msg = new StringBundler(6);
657    
658                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
659    
660                            msg.append("uuid=");
661                            msg.append(uuid);
662    
663                            msg.append(", groupId=");
664                            msg.append(groupId);
665    
666                            msg.append(StringPool.CLOSE_CURLY_BRACE);
667    
668                            if (_log.isWarnEnabled()) {
669                                    _log.warn(msg.toString());
670                            }
671    
672                            throw new NoSuchCategoryException(msg.toString());
673                    }
674    
675                    return assetCategory;
676            }
677    
678            /**
679             * Returns the asset category where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
680             *
681             * @param uuid the uuid
682             * @param groupId the group ID
683             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
684             * @throws SystemException if a system exception occurred
685             */
686            @Override
687            public AssetCategory fetchByUUID_G(String uuid, long groupId)
688                    throws SystemException {
689                    return fetchByUUID_G(uuid, groupId, true);
690            }
691    
692            /**
693             * Returns the asset category where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
694             *
695             * @param uuid the uuid
696             * @param groupId the group ID
697             * @param retrieveFromCache whether to use the finder cache
698             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
699             * @throws SystemException if a system exception occurred
700             */
701            @Override
702            public AssetCategory fetchByUUID_G(String uuid, long groupId,
703                    boolean retrieveFromCache) throws SystemException {
704                    Object[] finderArgs = new Object[] { uuid, groupId };
705    
706                    Object result = null;
707    
708                    if (retrieveFromCache) {
709                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
710                                            finderArgs, this);
711                    }
712    
713                    if (result instanceof AssetCategory) {
714                            AssetCategory assetCategory = (AssetCategory)result;
715    
716                            if (!Validator.equals(uuid, assetCategory.getUuid()) ||
717                                            (groupId != assetCategory.getGroupId())) {
718                                    result = null;
719                            }
720                    }
721    
722                    if (result == null) {
723                            StringBundler query = new StringBundler(4);
724    
725                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
726    
727                            boolean bindUuid = false;
728    
729                            if (uuid == null) {
730                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
731                            }
732                            else if (uuid.equals(StringPool.BLANK)) {
733                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
734                            }
735                            else {
736                                    bindUuid = true;
737    
738                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
739                            }
740    
741                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
742    
743                            String sql = query.toString();
744    
745                            Session session = null;
746    
747                            try {
748                                    session = openSession();
749    
750                                    Query q = session.createQuery(sql);
751    
752                                    QueryPos qPos = QueryPos.getInstance(q);
753    
754                                    if (bindUuid) {
755                                            qPos.add(uuid);
756                                    }
757    
758                                    qPos.add(groupId);
759    
760                                    List<AssetCategory> list = q.list();
761    
762                                    if (list.isEmpty()) {
763                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
764                                                    finderArgs, list);
765                                    }
766                                    else {
767                                            AssetCategory assetCategory = list.get(0);
768    
769                                            result = assetCategory;
770    
771                                            cacheResult(assetCategory);
772    
773                                            if ((assetCategory.getUuid() == null) ||
774                                                            !assetCategory.getUuid().equals(uuid) ||
775                                                            (assetCategory.getGroupId() != groupId)) {
776                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
777                                                            finderArgs, assetCategory);
778                                            }
779                                    }
780                            }
781                            catch (Exception e) {
782                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
783                                            finderArgs);
784    
785                                    throw processException(e);
786                            }
787                            finally {
788                                    closeSession(session);
789                            }
790                    }
791    
792                    if (result instanceof List<?>) {
793                            return null;
794                    }
795                    else {
796                            return (AssetCategory)result;
797                    }
798            }
799    
800            /**
801             * Removes the asset category where uuid = &#63; and groupId = &#63; from the database.
802             *
803             * @param uuid the uuid
804             * @param groupId the group ID
805             * @return the asset category that was removed
806             * @throws SystemException if a system exception occurred
807             */
808            @Override
809            public AssetCategory removeByUUID_G(String uuid, long groupId)
810                    throws NoSuchCategoryException, SystemException {
811                    AssetCategory assetCategory = findByUUID_G(uuid, groupId);
812    
813                    return remove(assetCategory);
814            }
815    
816            /**
817             * Returns the number of asset categories where uuid = &#63; and groupId = &#63;.
818             *
819             * @param uuid the uuid
820             * @param groupId the group ID
821             * @return the number of matching asset categories
822             * @throws SystemException if a system exception occurred
823             */
824            @Override
825            public int countByUUID_G(String uuid, long groupId)
826                    throws SystemException {
827                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
828    
829                    Object[] finderArgs = new Object[] { uuid, groupId };
830    
831                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
832                                    this);
833    
834                    if (count == null) {
835                            StringBundler query = new StringBundler(3);
836    
837                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
838    
839                            boolean bindUuid = false;
840    
841                            if (uuid == null) {
842                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
843                            }
844                            else if (uuid.equals(StringPool.BLANK)) {
845                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
846                            }
847                            else {
848                                    bindUuid = true;
849    
850                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
851                            }
852    
853                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
854    
855                            String sql = query.toString();
856    
857                            Session session = null;
858    
859                            try {
860                                    session = openSession();
861    
862                                    Query q = session.createQuery(sql);
863    
864                                    QueryPos qPos = QueryPos.getInstance(q);
865    
866                                    if (bindUuid) {
867                                            qPos.add(uuid);
868                                    }
869    
870                                    qPos.add(groupId);
871    
872                                    count = (Long)q.uniqueResult();
873    
874                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
875                            }
876                            catch (Exception e) {
877                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
878    
879                                    throw processException(e);
880                            }
881                            finally {
882                                    closeSession(session);
883                            }
884                    }
885    
886                    return count.intValue();
887            }
888    
889            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
890            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
891            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
892            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
893            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
894                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
895                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
896                            "findByUuid_C",
897                            new String[] {
898                                    String.class.getName(), Long.class.getName(),
899                                    
900                            Integer.class.getName(), Integer.class.getName(),
901                                    OrderByComparator.class.getName()
902                            });
903            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
904                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
905                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
906                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
907                            "findByUuid_C",
908                            new String[] { String.class.getName(), Long.class.getName() },
909                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
910                            AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
911                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
912            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
913                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
914                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
915                            new String[] { String.class.getName(), Long.class.getName() });
916    
917            /**
918             * Returns all the asset categories where uuid = &#63; and companyId = &#63;.
919             *
920             * @param uuid the uuid
921             * @param companyId the company ID
922             * @return the matching asset categories
923             * @throws SystemException if a system exception occurred
924             */
925            @Override
926            public List<AssetCategory> findByUuid_C(String uuid, long companyId)
927                    throws SystemException {
928                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
929                            QueryUtil.ALL_POS, null);
930            }
931    
932            /**
933             * Returns a range of all the asset categories where uuid = &#63; and companyId = &#63;.
934             *
935             * <p>
936             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
937             * </p>
938             *
939             * @param uuid the uuid
940             * @param companyId the company ID
941             * @param start the lower bound of the range of asset categories
942             * @param end the upper bound of the range of asset categories (not inclusive)
943             * @return the range of matching asset categories
944             * @throws SystemException if a system exception occurred
945             */
946            @Override
947            public List<AssetCategory> findByUuid_C(String uuid, long companyId,
948                    int start, int end) throws SystemException {
949                    return findByUuid_C(uuid, companyId, start, end, null);
950            }
951    
952            /**
953             * Returns an ordered range of all the asset categories where uuid = &#63; and companyId = &#63;.
954             *
955             * <p>
956             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
957             * </p>
958             *
959             * @param uuid the uuid
960             * @param companyId the company ID
961             * @param start the lower bound of the range of asset categories
962             * @param end the upper bound of the range of asset categories (not inclusive)
963             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
964             * @return the ordered range of matching asset categories
965             * @throws SystemException if a system exception occurred
966             */
967            @Override
968            public List<AssetCategory> findByUuid_C(String uuid, long companyId,
969                    int start, int end, OrderByComparator orderByComparator)
970                    throws SystemException {
971                    boolean pagination = true;
972                    FinderPath finderPath = null;
973                    Object[] finderArgs = null;
974    
975                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
976                                    (orderByComparator == null)) {
977                            pagination = false;
978                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
979                            finderArgs = new Object[] { uuid, companyId };
980                    }
981                    else {
982                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
983                            finderArgs = new Object[] {
984                                            uuid, companyId,
985                                            
986                                            start, end, orderByComparator
987                                    };
988                    }
989    
990                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
991                                    finderArgs, this);
992    
993                    if ((list != null) && !list.isEmpty()) {
994                            for (AssetCategory assetCategory : list) {
995                                    if (!Validator.equals(uuid, assetCategory.getUuid()) ||
996                                                    (companyId != assetCategory.getCompanyId())) {
997                                            list = null;
998    
999                                            break;
1000                                    }
1001                            }
1002                    }
1003    
1004                    if (list == null) {
1005                            StringBundler query = null;
1006    
1007                            if (orderByComparator != null) {
1008                                    query = new StringBundler(4 +
1009                                                    (orderByComparator.getOrderByFields().length * 3));
1010                            }
1011                            else {
1012                                    query = new StringBundler(4);
1013                            }
1014    
1015                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1016    
1017                            boolean bindUuid = false;
1018    
1019                            if (uuid == null) {
1020                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1021                            }
1022                            else if (uuid.equals(StringPool.BLANK)) {
1023                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1024                            }
1025                            else {
1026                                    bindUuid = true;
1027    
1028                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1029                            }
1030    
1031                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1032    
1033                            if (orderByComparator != null) {
1034                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1035                                            orderByComparator);
1036                            }
1037                            else
1038                             if (pagination) {
1039                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1040                            }
1041    
1042                            String sql = query.toString();
1043    
1044                            Session session = null;
1045    
1046                            try {
1047                                    session = openSession();
1048    
1049                                    Query q = session.createQuery(sql);
1050    
1051                                    QueryPos qPos = QueryPos.getInstance(q);
1052    
1053                                    if (bindUuid) {
1054                                            qPos.add(uuid);
1055                                    }
1056    
1057                                    qPos.add(companyId);
1058    
1059                                    if (!pagination) {
1060                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1061                                                            start, end, false);
1062    
1063                                            Collections.sort(list);
1064    
1065                                            list = new UnmodifiableList<AssetCategory>(list);
1066                                    }
1067                                    else {
1068                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1069                                                            start, end);
1070                                    }
1071    
1072                                    cacheResult(list);
1073    
1074                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1075                            }
1076                            catch (Exception e) {
1077                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1078    
1079                                    throw processException(e);
1080                            }
1081                            finally {
1082                                    closeSession(session);
1083                            }
1084                    }
1085    
1086                    return list;
1087            }
1088    
1089            /**
1090             * Returns the first asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1091             *
1092             * @param uuid the uuid
1093             * @param companyId the company ID
1094             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1095             * @return the first matching asset category
1096             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1097             * @throws SystemException if a system exception occurred
1098             */
1099            @Override
1100            public AssetCategory findByUuid_C_First(String uuid, long companyId,
1101                    OrderByComparator orderByComparator)
1102                    throws NoSuchCategoryException, SystemException {
1103                    AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1104                                    orderByComparator);
1105    
1106                    if (assetCategory != null) {
1107                            return assetCategory;
1108                    }
1109    
1110                    StringBundler msg = new StringBundler(6);
1111    
1112                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1113    
1114                    msg.append("uuid=");
1115                    msg.append(uuid);
1116    
1117                    msg.append(", companyId=");
1118                    msg.append(companyId);
1119    
1120                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1121    
1122                    throw new NoSuchCategoryException(msg.toString());
1123            }
1124    
1125            /**
1126             * Returns the first asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1127             *
1128             * @param uuid the uuid
1129             * @param companyId the company ID
1130             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1131             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1132             * @throws SystemException if a system exception occurred
1133             */
1134            @Override
1135            public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1136                    OrderByComparator orderByComparator) throws SystemException {
1137                    List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1138                                    orderByComparator);
1139    
1140                    if (!list.isEmpty()) {
1141                            return list.get(0);
1142                    }
1143    
1144                    return null;
1145            }
1146    
1147            /**
1148             * Returns the last asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1149             *
1150             * @param uuid the uuid
1151             * @param companyId the company ID
1152             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1153             * @return the last matching asset category
1154             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1155             * @throws SystemException if a system exception occurred
1156             */
1157            @Override
1158            public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1159                    OrderByComparator orderByComparator)
1160                    throws NoSuchCategoryException, SystemException {
1161                    AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1162                                    orderByComparator);
1163    
1164                    if (assetCategory != null) {
1165                            return assetCategory;
1166                    }
1167    
1168                    StringBundler msg = new StringBundler(6);
1169    
1170                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1171    
1172                    msg.append("uuid=");
1173                    msg.append(uuid);
1174    
1175                    msg.append(", companyId=");
1176                    msg.append(companyId);
1177    
1178                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1179    
1180                    throw new NoSuchCategoryException(msg.toString());
1181            }
1182    
1183            /**
1184             * Returns the last asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1185             *
1186             * @param uuid the uuid
1187             * @param companyId the company ID
1188             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1189             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1190             * @throws SystemException if a system exception occurred
1191             */
1192            @Override
1193            public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1194                    OrderByComparator orderByComparator) throws SystemException {
1195                    int count = countByUuid_C(uuid, companyId);
1196    
1197                    if (count == 0) {
1198                            return null;
1199                    }
1200    
1201                    List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1202                                    count, orderByComparator);
1203    
1204                    if (!list.isEmpty()) {
1205                            return list.get(0);
1206                    }
1207    
1208                    return null;
1209            }
1210    
1211            /**
1212             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1213             *
1214             * @param categoryId the primary key of the current asset category
1215             * @param uuid the uuid
1216             * @param companyId the company ID
1217             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1218             * @return the previous, current, and next asset category
1219             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1220             * @throws SystemException if a system exception occurred
1221             */
1222            @Override
1223            public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1224                    String uuid, long companyId, OrderByComparator orderByComparator)
1225                    throws NoSuchCategoryException, SystemException {
1226                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1227    
1228                    Session session = null;
1229    
1230                    try {
1231                            session = openSession();
1232    
1233                            AssetCategory[] array = new AssetCategoryImpl[3];
1234    
1235                            array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1236                                            companyId, orderByComparator, true);
1237    
1238                            array[1] = assetCategory;
1239    
1240                            array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1241                                            companyId, orderByComparator, false);
1242    
1243                            return array;
1244                    }
1245                    catch (Exception e) {
1246                            throw processException(e);
1247                    }
1248                    finally {
1249                            closeSession(session);
1250                    }
1251            }
1252    
1253            protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1254                    AssetCategory assetCategory, String uuid, long companyId,
1255                    OrderByComparator orderByComparator, boolean previous) {
1256                    StringBundler query = null;
1257    
1258                    if (orderByComparator != null) {
1259                            query = new StringBundler(6 +
1260                                            (orderByComparator.getOrderByFields().length * 6));
1261                    }
1262                    else {
1263                            query = new StringBundler(3);
1264                    }
1265    
1266                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1267    
1268                    boolean bindUuid = false;
1269    
1270                    if (uuid == null) {
1271                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1272                    }
1273                    else if (uuid.equals(StringPool.BLANK)) {
1274                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1275                    }
1276                    else {
1277                            bindUuid = true;
1278    
1279                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1280                    }
1281    
1282                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1283    
1284                    if (orderByComparator != null) {
1285                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1286    
1287                            if (orderByConditionFields.length > 0) {
1288                                    query.append(WHERE_AND);
1289                            }
1290    
1291                            for (int i = 0; i < orderByConditionFields.length; i++) {
1292                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1293                                    query.append(orderByConditionFields[i]);
1294    
1295                                    if ((i + 1) < orderByConditionFields.length) {
1296                                            if (orderByComparator.isAscending() ^ previous) {
1297                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1298                                            }
1299                                            else {
1300                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1301                                            }
1302                                    }
1303                                    else {
1304                                            if (orderByComparator.isAscending() ^ previous) {
1305                                                    query.append(WHERE_GREATER_THAN);
1306                                            }
1307                                            else {
1308                                                    query.append(WHERE_LESSER_THAN);
1309                                            }
1310                                    }
1311                            }
1312    
1313                            query.append(ORDER_BY_CLAUSE);
1314    
1315                            String[] orderByFields = orderByComparator.getOrderByFields();
1316    
1317                            for (int i = 0; i < orderByFields.length; i++) {
1318                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1319                                    query.append(orderByFields[i]);
1320    
1321                                    if ((i + 1) < orderByFields.length) {
1322                                            if (orderByComparator.isAscending() ^ previous) {
1323                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1324                                            }
1325                                            else {
1326                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1327                                            }
1328                                    }
1329                                    else {
1330                                            if (orderByComparator.isAscending() ^ previous) {
1331                                                    query.append(ORDER_BY_ASC);
1332                                            }
1333                                            else {
1334                                                    query.append(ORDER_BY_DESC);
1335                                            }
1336                                    }
1337                            }
1338                    }
1339                    else {
1340                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1341                    }
1342    
1343                    String sql = query.toString();
1344    
1345                    Query q = session.createQuery(sql);
1346    
1347                    q.setFirstResult(0);
1348                    q.setMaxResults(2);
1349    
1350                    QueryPos qPos = QueryPos.getInstance(q);
1351    
1352                    if (bindUuid) {
1353                            qPos.add(uuid);
1354                    }
1355    
1356                    qPos.add(companyId);
1357    
1358                    if (orderByComparator != null) {
1359                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1360    
1361                            for (Object value : values) {
1362                                    qPos.add(value);
1363                            }
1364                    }
1365    
1366                    List<AssetCategory> list = q.list();
1367    
1368                    if (list.size() == 2) {
1369                            return list.get(1);
1370                    }
1371                    else {
1372                            return null;
1373                    }
1374            }
1375    
1376            /**
1377             * Removes all the asset categories where uuid = &#63; and companyId = &#63; from the database.
1378             *
1379             * @param uuid the uuid
1380             * @param companyId the company ID
1381             * @throws SystemException if a system exception occurred
1382             */
1383            @Override
1384            public void removeByUuid_C(String uuid, long companyId)
1385                    throws SystemException {
1386                    for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1387                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1388                            remove(assetCategory);
1389                    }
1390            }
1391    
1392            /**
1393             * Returns the number of asset categories where uuid = &#63; and companyId = &#63;.
1394             *
1395             * @param uuid the uuid
1396             * @param companyId the company ID
1397             * @return the number of matching asset categories
1398             * @throws SystemException if a system exception occurred
1399             */
1400            @Override
1401            public int countByUuid_C(String uuid, long companyId)
1402                    throws SystemException {
1403                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1404    
1405                    Object[] finderArgs = new Object[] { uuid, companyId };
1406    
1407                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1408                                    this);
1409    
1410                    if (count == null) {
1411                            StringBundler query = new StringBundler(3);
1412    
1413                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
1414    
1415                            boolean bindUuid = false;
1416    
1417                            if (uuid == null) {
1418                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1419                            }
1420                            else if (uuid.equals(StringPool.BLANK)) {
1421                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1422                            }
1423                            else {
1424                                    bindUuid = true;
1425    
1426                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1427                            }
1428    
1429                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1430    
1431                            String sql = query.toString();
1432    
1433                            Session session = null;
1434    
1435                            try {
1436                                    session = openSession();
1437    
1438                                    Query q = session.createQuery(sql);
1439    
1440                                    QueryPos qPos = QueryPos.getInstance(q);
1441    
1442                                    if (bindUuid) {
1443                                            qPos.add(uuid);
1444                                    }
1445    
1446                                    qPos.add(companyId);
1447    
1448                                    count = (Long)q.uniqueResult();
1449    
1450                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1451                            }
1452                            catch (Exception e) {
1453                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1454    
1455                                    throw processException(e);
1456                            }
1457                            finally {
1458                                    closeSession(session);
1459                            }
1460                    }
1461    
1462                    return count.intValue();
1463            }
1464    
1465            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
1466            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
1467            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
1468            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
1469            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1470                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1471                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1472                            "findByGroupId",
1473                            new String[] {
1474                                    Long.class.getName(),
1475                                    
1476                            Integer.class.getName(), Integer.class.getName(),
1477                                    OrderByComparator.class.getName()
1478                            });
1479            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1480                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1481                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1482                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1483                            "findByGroupId", new String[] { Long.class.getName() },
1484                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1485                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
1486            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1487                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1488                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1489                            new String[] { Long.class.getName() });
1490    
1491            /**
1492             * Returns all the asset categories where groupId = &#63;.
1493             *
1494             * @param groupId the group ID
1495             * @return the matching asset categories
1496             * @throws SystemException if a system exception occurred
1497             */
1498            @Override
1499            public List<AssetCategory> findByGroupId(long groupId)
1500                    throws SystemException {
1501                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1502            }
1503    
1504            /**
1505             * Returns a range of all the asset categories where groupId = &#63;.
1506             *
1507             * <p>
1508             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1509             * </p>
1510             *
1511             * @param groupId the group ID
1512             * @param start the lower bound of the range of asset categories
1513             * @param end the upper bound of the range of asset categories (not inclusive)
1514             * @return the range of matching asset categories
1515             * @throws SystemException if a system exception occurred
1516             */
1517            @Override
1518            public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1519                    throws SystemException {
1520                    return findByGroupId(groupId, start, end, null);
1521            }
1522    
1523            /**
1524             * Returns an ordered range of all the asset categories where groupId = &#63;.
1525             *
1526             * <p>
1527             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1528             * </p>
1529             *
1530             * @param groupId the group ID
1531             * @param start the lower bound of the range of asset categories
1532             * @param end the upper bound of the range of asset categories (not inclusive)
1533             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1534             * @return the ordered range of matching asset categories
1535             * @throws SystemException if a system exception occurred
1536             */
1537            @Override
1538            public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1539                    OrderByComparator orderByComparator) throws SystemException {
1540                    boolean pagination = true;
1541                    FinderPath finderPath = null;
1542                    Object[] finderArgs = null;
1543    
1544                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1545                                    (orderByComparator == null)) {
1546                            pagination = false;
1547                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1548                            finderArgs = new Object[] { groupId };
1549                    }
1550                    else {
1551                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1552                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1553                    }
1554    
1555                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1556                                    finderArgs, this);
1557    
1558                    if ((list != null) && !list.isEmpty()) {
1559                            for (AssetCategory assetCategory : list) {
1560                                    if ((groupId != assetCategory.getGroupId())) {
1561                                            list = null;
1562    
1563                                            break;
1564                                    }
1565                            }
1566                    }
1567    
1568                    if (list == null) {
1569                            StringBundler query = null;
1570    
1571                            if (orderByComparator != null) {
1572                                    query = new StringBundler(3 +
1573                                                    (orderByComparator.getOrderByFields().length * 3));
1574                            }
1575                            else {
1576                                    query = new StringBundler(3);
1577                            }
1578    
1579                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1580    
1581                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1582    
1583                            if (orderByComparator != null) {
1584                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1585                                            orderByComparator);
1586                            }
1587                            else
1588                             if (pagination) {
1589                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1590                            }
1591    
1592                            String sql = query.toString();
1593    
1594                            Session session = null;
1595    
1596                            try {
1597                                    session = openSession();
1598    
1599                                    Query q = session.createQuery(sql);
1600    
1601                                    QueryPos qPos = QueryPos.getInstance(q);
1602    
1603                                    qPos.add(groupId);
1604    
1605                                    if (!pagination) {
1606                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1607                                                            start, end, false);
1608    
1609                                            Collections.sort(list);
1610    
1611                                            list = new UnmodifiableList<AssetCategory>(list);
1612                                    }
1613                                    else {
1614                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1615                                                            start, end);
1616                                    }
1617    
1618                                    cacheResult(list);
1619    
1620                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1621                            }
1622                            catch (Exception e) {
1623                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1624    
1625                                    throw processException(e);
1626                            }
1627                            finally {
1628                                    closeSession(session);
1629                            }
1630                    }
1631    
1632                    return list;
1633            }
1634    
1635            /**
1636             * Returns the first asset category in the ordered set where groupId = &#63;.
1637             *
1638             * @param groupId the group ID
1639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1640             * @return the first matching asset category
1641             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1642             * @throws SystemException if a system exception occurred
1643             */
1644            @Override
1645            public AssetCategory findByGroupId_First(long groupId,
1646                    OrderByComparator orderByComparator)
1647                    throws NoSuchCategoryException, SystemException {
1648                    AssetCategory assetCategory = fetchByGroupId_First(groupId,
1649                                    orderByComparator);
1650    
1651                    if (assetCategory != null) {
1652                            return assetCategory;
1653                    }
1654    
1655                    StringBundler msg = new StringBundler(4);
1656    
1657                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1658    
1659                    msg.append("groupId=");
1660                    msg.append(groupId);
1661    
1662                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1663    
1664                    throw new NoSuchCategoryException(msg.toString());
1665            }
1666    
1667            /**
1668             * Returns the first asset category in the ordered set where groupId = &#63;.
1669             *
1670             * @param groupId the group ID
1671             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1672             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1673             * @throws SystemException if a system exception occurred
1674             */
1675            @Override
1676            public AssetCategory fetchByGroupId_First(long groupId,
1677                    OrderByComparator orderByComparator) throws SystemException {
1678                    List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1679                                    orderByComparator);
1680    
1681                    if (!list.isEmpty()) {
1682                            return list.get(0);
1683                    }
1684    
1685                    return null;
1686            }
1687    
1688            /**
1689             * Returns the last asset category in the ordered set where groupId = &#63;.
1690             *
1691             * @param groupId the group ID
1692             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1693             * @return the last matching asset category
1694             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1695             * @throws SystemException if a system exception occurred
1696             */
1697            @Override
1698            public AssetCategory findByGroupId_Last(long groupId,
1699                    OrderByComparator orderByComparator)
1700                    throws NoSuchCategoryException, SystemException {
1701                    AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1702                                    orderByComparator);
1703    
1704                    if (assetCategory != null) {
1705                            return assetCategory;
1706                    }
1707    
1708                    StringBundler msg = new StringBundler(4);
1709    
1710                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1711    
1712                    msg.append("groupId=");
1713                    msg.append(groupId);
1714    
1715                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1716    
1717                    throw new NoSuchCategoryException(msg.toString());
1718            }
1719    
1720            /**
1721             * Returns the last asset category in the ordered set where groupId = &#63;.
1722             *
1723             * @param groupId the group ID
1724             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1725             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1726             * @throws SystemException if a system exception occurred
1727             */
1728            @Override
1729            public AssetCategory fetchByGroupId_Last(long groupId,
1730                    OrderByComparator orderByComparator) throws SystemException {
1731                    int count = countByGroupId(groupId);
1732    
1733                    if (count == 0) {
1734                            return null;
1735                    }
1736    
1737                    List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1738                                    orderByComparator);
1739    
1740                    if (!list.isEmpty()) {
1741                            return list.get(0);
1742                    }
1743    
1744                    return null;
1745            }
1746    
1747            /**
1748             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63;.
1749             *
1750             * @param categoryId the primary key of the current asset category
1751             * @param groupId the group ID
1752             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1753             * @return the previous, current, and next asset category
1754             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1755             * @throws SystemException if a system exception occurred
1756             */
1757            @Override
1758            public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1759                    long groupId, OrderByComparator orderByComparator)
1760                    throws NoSuchCategoryException, SystemException {
1761                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1762    
1763                    Session session = null;
1764    
1765                    try {
1766                            session = openSession();
1767    
1768                            AssetCategory[] array = new AssetCategoryImpl[3];
1769    
1770                            array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1771                                            groupId, orderByComparator, true);
1772    
1773                            array[1] = assetCategory;
1774    
1775                            array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1776                                            groupId, orderByComparator, false);
1777    
1778                            return array;
1779                    }
1780                    catch (Exception e) {
1781                            throw processException(e);
1782                    }
1783                    finally {
1784                            closeSession(session);
1785                    }
1786            }
1787    
1788            protected AssetCategory getByGroupId_PrevAndNext(Session session,
1789                    AssetCategory assetCategory, long groupId,
1790                    OrderByComparator orderByComparator, boolean previous) {
1791                    StringBundler query = null;
1792    
1793                    if (orderByComparator != null) {
1794                            query = new StringBundler(6 +
1795                                            (orderByComparator.getOrderByFields().length * 6));
1796                    }
1797                    else {
1798                            query = new StringBundler(3);
1799                    }
1800    
1801                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1802    
1803                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1804    
1805                    if (orderByComparator != null) {
1806                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1807    
1808                            if (orderByConditionFields.length > 0) {
1809                                    query.append(WHERE_AND);
1810                            }
1811    
1812                            for (int i = 0; i < orderByConditionFields.length; i++) {
1813                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1814                                    query.append(orderByConditionFields[i]);
1815    
1816                                    if ((i + 1) < orderByConditionFields.length) {
1817                                            if (orderByComparator.isAscending() ^ previous) {
1818                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1819                                            }
1820                                            else {
1821                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1822                                            }
1823                                    }
1824                                    else {
1825                                            if (orderByComparator.isAscending() ^ previous) {
1826                                                    query.append(WHERE_GREATER_THAN);
1827                                            }
1828                                            else {
1829                                                    query.append(WHERE_LESSER_THAN);
1830                                            }
1831                                    }
1832                            }
1833    
1834                            query.append(ORDER_BY_CLAUSE);
1835    
1836                            String[] orderByFields = orderByComparator.getOrderByFields();
1837    
1838                            for (int i = 0; i < orderByFields.length; i++) {
1839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1840                                    query.append(orderByFields[i]);
1841    
1842                                    if ((i + 1) < orderByFields.length) {
1843                                            if (orderByComparator.isAscending() ^ previous) {
1844                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1845                                            }
1846                                            else {
1847                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1848                                            }
1849                                    }
1850                                    else {
1851                                            if (orderByComparator.isAscending() ^ previous) {
1852                                                    query.append(ORDER_BY_ASC);
1853                                            }
1854                                            else {
1855                                                    query.append(ORDER_BY_DESC);
1856                                            }
1857                                    }
1858                            }
1859                    }
1860                    else {
1861                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1862                    }
1863    
1864                    String sql = query.toString();
1865    
1866                    Query q = session.createQuery(sql);
1867    
1868                    q.setFirstResult(0);
1869                    q.setMaxResults(2);
1870    
1871                    QueryPos qPos = QueryPos.getInstance(q);
1872    
1873                    qPos.add(groupId);
1874    
1875                    if (orderByComparator != null) {
1876                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1877    
1878                            for (Object value : values) {
1879                                    qPos.add(value);
1880                            }
1881                    }
1882    
1883                    List<AssetCategory> list = q.list();
1884    
1885                    if (list.size() == 2) {
1886                            return list.get(1);
1887                    }
1888                    else {
1889                            return null;
1890                    }
1891            }
1892    
1893            /**
1894             * Returns all the asset categories that the user has permission to view where groupId = &#63;.
1895             *
1896             * @param groupId the group ID
1897             * @return the matching asset categories that the user has permission to view
1898             * @throws SystemException if a system exception occurred
1899             */
1900            @Override
1901            public List<AssetCategory> filterFindByGroupId(long groupId)
1902                    throws SystemException {
1903                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1904                            QueryUtil.ALL_POS, null);
1905            }
1906    
1907            /**
1908             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63;.
1909             *
1910             * <p>
1911             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1912             * </p>
1913             *
1914             * @param groupId the group ID
1915             * @param start the lower bound of the range of asset categories
1916             * @param end the upper bound of the range of asset categories (not inclusive)
1917             * @return the range of matching asset categories that the user has permission to view
1918             * @throws SystemException if a system exception occurred
1919             */
1920            @Override
1921            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1922                    int end) throws SystemException {
1923                    return filterFindByGroupId(groupId, start, end, null);
1924            }
1925    
1926            /**
1927             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63;.
1928             *
1929             * <p>
1930             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1931             * </p>
1932             *
1933             * @param groupId the group ID
1934             * @param start the lower bound of the range of asset categories
1935             * @param end the upper bound of the range of asset categories (not inclusive)
1936             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1937             * @return the ordered range of matching asset categories that the user has permission to view
1938             * @throws SystemException if a system exception occurred
1939             */
1940            @Override
1941            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1942                    int end, OrderByComparator orderByComparator) throws SystemException {
1943                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1944                            return findByGroupId(groupId, start, end, orderByComparator);
1945                    }
1946    
1947                    StringBundler query = null;
1948    
1949                    if (orderByComparator != null) {
1950                            query = new StringBundler(3 +
1951                                            (orderByComparator.getOrderByFields().length * 3));
1952                    }
1953                    else {
1954                            query = new StringBundler(3);
1955                    }
1956    
1957                    if (getDB().isSupportsInlineDistinct()) {
1958                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1959                    }
1960                    else {
1961                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1962                    }
1963    
1964                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1965    
1966                    if (!getDB().isSupportsInlineDistinct()) {
1967                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1968                    }
1969    
1970                    if (orderByComparator != null) {
1971                            if (getDB().isSupportsInlineDistinct()) {
1972                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1973                                            orderByComparator, true);
1974                            }
1975                            else {
1976                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1977                                            orderByComparator, true);
1978                            }
1979                    }
1980                    else {
1981                            if (getDB().isSupportsInlineDistinct()) {
1982                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1983                            }
1984                            else {
1985                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1986                            }
1987                    }
1988    
1989                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1990                                    AssetCategory.class.getName(),
1991                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1992    
1993                    Session session = null;
1994    
1995                    try {
1996                            session = openSession();
1997    
1998                            SQLQuery q = session.createSQLQuery(sql);
1999    
2000                            if (getDB().isSupportsInlineDistinct()) {
2001                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2002                            }
2003                            else {
2004                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2005                            }
2006    
2007                            QueryPos qPos = QueryPos.getInstance(q);
2008    
2009                            qPos.add(groupId);
2010    
2011                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2012                                    end);
2013                    }
2014                    catch (Exception e) {
2015                            throw processException(e);
2016                    }
2017                    finally {
2018                            closeSession(session);
2019                    }
2020            }
2021    
2022            /**
2023             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63;.
2024             *
2025             * @param categoryId the primary key of the current asset category
2026             * @param groupId the group ID
2027             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2028             * @return the previous, current, and next asset category
2029             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2030             * @throws SystemException if a system exception occurred
2031             */
2032            @Override
2033            public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2034                    long groupId, OrderByComparator orderByComparator)
2035                    throws NoSuchCategoryException, SystemException {
2036                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2037                            return findByGroupId_PrevAndNext(categoryId, groupId,
2038                                    orderByComparator);
2039                    }
2040    
2041                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2042    
2043                    Session session = null;
2044    
2045                    try {
2046                            session = openSession();
2047    
2048                            AssetCategory[] array = new AssetCategoryImpl[3];
2049    
2050                            array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2051                                            groupId, orderByComparator, true);
2052    
2053                            array[1] = assetCategory;
2054    
2055                            array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2056                                            groupId, orderByComparator, false);
2057    
2058                            return array;
2059                    }
2060                    catch (Exception e) {
2061                            throw processException(e);
2062                    }
2063                    finally {
2064                            closeSession(session);
2065                    }
2066            }
2067    
2068            protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2069                    AssetCategory assetCategory, long groupId,
2070                    OrderByComparator orderByComparator, boolean previous) {
2071                    StringBundler query = null;
2072    
2073                    if (orderByComparator != null) {
2074                            query = new StringBundler(6 +
2075                                            (orderByComparator.getOrderByFields().length * 6));
2076                    }
2077                    else {
2078                            query = new StringBundler(3);
2079                    }
2080    
2081                    if (getDB().isSupportsInlineDistinct()) {
2082                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2083                    }
2084                    else {
2085                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2086                    }
2087    
2088                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2089    
2090                    if (!getDB().isSupportsInlineDistinct()) {
2091                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2092                    }
2093    
2094                    if (orderByComparator != null) {
2095                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2096    
2097                            if (orderByConditionFields.length > 0) {
2098                                    query.append(WHERE_AND);
2099                            }
2100    
2101                            for (int i = 0; i < orderByConditionFields.length; i++) {
2102                                    if (getDB().isSupportsInlineDistinct()) {
2103                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2104                                    }
2105                                    else {
2106                                            query.append(_ORDER_BY_ENTITY_TABLE);
2107                                    }
2108    
2109                                    query.append(orderByConditionFields[i]);
2110    
2111                                    if ((i + 1) < orderByConditionFields.length) {
2112                                            if (orderByComparator.isAscending() ^ previous) {
2113                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2114                                            }
2115                                            else {
2116                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2117                                            }
2118                                    }
2119                                    else {
2120                                            if (orderByComparator.isAscending() ^ previous) {
2121                                                    query.append(WHERE_GREATER_THAN);
2122                                            }
2123                                            else {
2124                                                    query.append(WHERE_LESSER_THAN);
2125                                            }
2126                                    }
2127                            }
2128    
2129                            query.append(ORDER_BY_CLAUSE);
2130    
2131                            String[] orderByFields = orderByComparator.getOrderByFields();
2132    
2133                            for (int i = 0; i < orderByFields.length; i++) {
2134                                    if (getDB().isSupportsInlineDistinct()) {
2135                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2136                                    }
2137                                    else {
2138                                            query.append(_ORDER_BY_ENTITY_TABLE);
2139                                    }
2140    
2141                                    query.append(orderByFields[i]);
2142    
2143                                    if ((i + 1) < orderByFields.length) {
2144                                            if (orderByComparator.isAscending() ^ previous) {
2145                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2146                                            }
2147                                            else {
2148                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2149                                            }
2150                                    }
2151                                    else {
2152                                            if (orderByComparator.isAscending() ^ previous) {
2153                                                    query.append(ORDER_BY_ASC);
2154                                            }
2155                                            else {
2156                                                    query.append(ORDER_BY_DESC);
2157                                            }
2158                                    }
2159                            }
2160                    }
2161                    else {
2162                            if (getDB().isSupportsInlineDistinct()) {
2163                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2164                            }
2165                            else {
2166                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2167                            }
2168                    }
2169    
2170                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2171                                    AssetCategory.class.getName(),
2172                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2173    
2174                    SQLQuery q = session.createSQLQuery(sql);
2175    
2176                    q.setFirstResult(0);
2177                    q.setMaxResults(2);
2178    
2179                    if (getDB().isSupportsInlineDistinct()) {
2180                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2181                    }
2182                    else {
2183                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2184                    }
2185    
2186                    QueryPos qPos = QueryPos.getInstance(q);
2187    
2188                    qPos.add(groupId);
2189    
2190                    if (orderByComparator != null) {
2191                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2192    
2193                            for (Object value : values) {
2194                                    qPos.add(value);
2195                            }
2196                    }
2197    
2198                    List<AssetCategory> list = q.list();
2199    
2200                    if (list.size() == 2) {
2201                            return list.get(1);
2202                    }
2203                    else {
2204                            return null;
2205                    }
2206            }
2207    
2208            /**
2209             * Removes all the asset categories where groupId = &#63; from the database.
2210             *
2211             * @param groupId the group ID
2212             * @throws SystemException if a system exception occurred
2213             */
2214            @Override
2215            public void removeByGroupId(long groupId) throws SystemException {
2216                    for (AssetCategory assetCategory : findByGroupId(groupId,
2217                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2218                            remove(assetCategory);
2219                    }
2220            }
2221    
2222            /**
2223             * Returns the number of asset categories where groupId = &#63;.
2224             *
2225             * @param groupId the group ID
2226             * @return the number of matching asset categories
2227             * @throws SystemException if a system exception occurred
2228             */
2229            @Override
2230            public int countByGroupId(long groupId) throws SystemException {
2231                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2232    
2233                    Object[] finderArgs = new Object[] { groupId };
2234    
2235                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2236                                    this);
2237    
2238                    if (count == null) {
2239                            StringBundler query = new StringBundler(2);
2240    
2241                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2242    
2243                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2244    
2245                            String sql = query.toString();
2246    
2247                            Session session = null;
2248    
2249                            try {
2250                                    session = openSession();
2251    
2252                                    Query q = session.createQuery(sql);
2253    
2254                                    QueryPos qPos = QueryPos.getInstance(q);
2255    
2256                                    qPos.add(groupId);
2257    
2258                                    count = (Long)q.uniqueResult();
2259    
2260                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2261                            }
2262                            catch (Exception e) {
2263                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2264    
2265                                    throw processException(e);
2266                            }
2267                            finally {
2268                                    closeSession(session);
2269                            }
2270                    }
2271    
2272                    return count.intValue();
2273            }
2274    
2275            /**
2276             * Returns the number of asset categories that the user has permission to view where groupId = &#63;.
2277             *
2278             * @param groupId the group ID
2279             * @return the number of matching asset categories that the user has permission to view
2280             * @throws SystemException if a system exception occurred
2281             */
2282            @Override
2283            public int filterCountByGroupId(long groupId) throws SystemException {
2284                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2285                            return countByGroupId(groupId);
2286                    }
2287    
2288                    StringBundler query = new StringBundler(2);
2289    
2290                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2291    
2292                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2293    
2294                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2295                                    AssetCategory.class.getName(),
2296                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2297    
2298                    Session session = null;
2299    
2300                    try {
2301                            session = openSession();
2302    
2303                            SQLQuery q = session.createSQLQuery(sql);
2304    
2305                            q.addScalar(COUNT_COLUMN_NAME,
2306                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2307    
2308                            QueryPos qPos = QueryPos.getInstance(q);
2309    
2310                            qPos.add(groupId);
2311    
2312                            Long count = (Long)q.uniqueResult();
2313    
2314                            return count.intValue();
2315                    }
2316                    catch (Exception e) {
2317                            throw processException(e);
2318                    }
2319                    finally {
2320                            closeSession(session);
2321                    }
2322            }
2323    
2324            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2325            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2326                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2327                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2328                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2329                            "findByParentCategoryId",
2330                            new String[] {
2331                                    Long.class.getName(),
2332                                    
2333                            Integer.class.getName(), Integer.class.getName(),
2334                                    OrderByComparator.class.getName()
2335                            });
2336            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2337                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2338                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2339                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2340                            "findByParentCategoryId", new String[] { Long.class.getName() },
2341                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2342                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2343            public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2344                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2345                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2346                            "countByParentCategoryId", new String[] { Long.class.getName() });
2347    
2348            /**
2349             * Returns all the asset categories where parentCategoryId = &#63;.
2350             *
2351             * @param parentCategoryId the parent category ID
2352             * @return the matching asset categories
2353             * @throws SystemException if a system exception occurred
2354             */
2355            @Override
2356            public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2357                    throws SystemException {
2358                    return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2359                            QueryUtil.ALL_POS, null);
2360            }
2361    
2362            /**
2363             * Returns a range of all the asset categories where parentCategoryId = &#63;.
2364             *
2365             * <p>
2366             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2367             * </p>
2368             *
2369             * @param parentCategoryId the parent category ID
2370             * @param start the lower bound of the range of asset categories
2371             * @param end the upper bound of the range of asset categories (not inclusive)
2372             * @return the range of matching asset categories
2373             * @throws SystemException if a system exception occurred
2374             */
2375            @Override
2376            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2377                    int start, int end) throws SystemException {
2378                    return findByParentCategoryId(parentCategoryId, start, end, null);
2379            }
2380    
2381            /**
2382             * Returns an ordered range of all the asset categories where parentCategoryId = &#63;.
2383             *
2384             * <p>
2385             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2386             * </p>
2387             *
2388             * @param parentCategoryId the parent category ID
2389             * @param start the lower bound of the range of asset categories
2390             * @param end the upper bound of the range of asset categories (not inclusive)
2391             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2392             * @return the ordered range of matching asset categories
2393             * @throws SystemException if a system exception occurred
2394             */
2395            @Override
2396            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2397                    int start, int end, OrderByComparator orderByComparator)
2398                    throws SystemException {
2399                    boolean pagination = true;
2400                    FinderPath finderPath = null;
2401                    Object[] finderArgs = null;
2402    
2403                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2404                                    (orderByComparator == null)) {
2405                            pagination = false;
2406                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2407                            finderArgs = new Object[] { parentCategoryId };
2408                    }
2409                    else {
2410                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2411                            finderArgs = new Object[] {
2412                                            parentCategoryId,
2413                                            
2414                                            start, end, orderByComparator
2415                                    };
2416                    }
2417    
2418                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2419                                    finderArgs, this);
2420    
2421                    if ((list != null) && !list.isEmpty()) {
2422                            for (AssetCategory assetCategory : list) {
2423                                    if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2424                                            list = null;
2425    
2426                                            break;
2427                                    }
2428                            }
2429                    }
2430    
2431                    if (list == null) {
2432                            StringBundler query = null;
2433    
2434                            if (orderByComparator != null) {
2435                                    query = new StringBundler(3 +
2436                                                    (orderByComparator.getOrderByFields().length * 3));
2437                            }
2438                            else {
2439                                    query = new StringBundler(3);
2440                            }
2441    
2442                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2443    
2444                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2445    
2446                            if (orderByComparator != null) {
2447                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2448                                            orderByComparator);
2449                            }
2450                            else
2451                             if (pagination) {
2452                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2453                            }
2454    
2455                            String sql = query.toString();
2456    
2457                            Session session = null;
2458    
2459                            try {
2460                                    session = openSession();
2461    
2462                                    Query q = session.createQuery(sql);
2463    
2464                                    QueryPos qPos = QueryPos.getInstance(q);
2465    
2466                                    qPos.add(parentCategoryId);
2467    
2468                                    if (!pagination) {
2469                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2470                                                            start, end, false);
2471    
2472                                            Collections.sort(list);
2473    
2474                                            list = new UnmodifiableList<AssetCategory>(list);
2475                                    }
2476                                    else {
2477                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2478                                                            start, end);
2479                                    }
2480    
2481                                    cacheResult(list);
2482    
2483                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2484                            }
2485                            catch (Exception e) {
2486                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2487    
2488                                    throw processException(e);
2489                            }
2490                            finally {
2491                                    closeSession(session);
2492                            }
2493                    }
2494    
2495                    return list;
2496            }
2497    
2498            /**
2499             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2500             *
2501             * @param parentCategoryId the parent category ID
2502             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2503             * @return the first matching asset category
2504             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2505             * @throws SystemException if a system exception occurred
2506             */
2507            @Override
2508            public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2509                    OrderByComparator orderByComparator)
2510                    throws NoSuchCategoryException, SystemException {
2511                    AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2512                                    orderByComparator);
2513    
2514                    if (assetCategory != null) {
2515                            return assetCategory;
2516                    }
2517    
2518                    StringBundler msg = new StringBundler(4);
2519    
2520                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2521    
2522                    msg.append("parentCategoryId=");
2523                    msg.append(parentCategoryId);
2524    
2525                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2526    
2527                    throw new NoSuchCategoryException(msg.toString());
2528            }
2529    
2530            /**
2531             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2532             *
2533             * @param parentCategoryId the parent category ID
2534             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2535             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
2536             * @throws SystemException if a system exception occurred
2537             */
2538            @Override
2539            public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2540                    OrderByComparator orderByComparator) throws SystemException {
2541                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2542                                    1, orderByComparator);
2543    
2544                    if (!list.isEmpty()) {
2545                            return list.get(0);
2546                    }
2547    
2548                    return null;
2549            }
2550    
2551            /**
2552             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2553             *
2554             * @param parentCategoryId the parent category ID
2555             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2556             * @return the last matching asset category
2557             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2558             * @throws SystemException if a system exception occurred
2559             */
2560            @Override
2561            public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2562                    OrderByComparator orderByComparator)
2563                    throws NoSuchCategoryException, SystemException {
2564                    AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2565                                    orderByComparator);
2566    
2567                    if (assetCategory != null) {
2568                            return assetCategory;
2569                    }
2570    
2571                    StringBundler msg = new StringBundler(4);
2572    
2573                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2574    
2575                    msg.append("parentCategoryId=");
2576                    msg.append(parentCategoryId);
2577    
2578                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2579    
2580                    throw new NoSuchCategoryException(msg.toString());
2581            }
2582    
2583            /**
2584             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2585             *
2586             * @param parentCategoryId the parent category ID
2587             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2588             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
2589             * @throws SystemException if a system exception occurred
2590             */
2591            @Override
2592            public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2593                    OrderByComparator orderByComparator) throws SystemException {
2594                    int count = countByParentCategoryId(parentCategoryId);
2595    
2596                    if (count == 0) {
2597                            return null;
2598                    }
2599    
2600                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2601                                    count - 1, count, orderByComparator);
2602    
2603                    if (!list.isEmpty()) {
2604                            return list.get(0);
2605                    }
2606    
2607                    return null;
2608            }
2609    
2610            /**
2611             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63;.
2612             *
2613             * @param categoryId the primary key of the current asset category
2614             * @param parentCategoryId the parent category ID
2615             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2616             * @return the previous, current, and next asset category
2617             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2618             * @throws SystemException if a system exception occurred
2619             */
2620            @Override
2621            public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2622                    long parentCategoryId, OrderByComparator orderByComparator)
2623                    throws NoSuchCategoryException, SystemException {
2624                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2625    
2626                    Session session = null;
2627    
2628                    try {
2629                            session = openSession();
2630    
2631                            AssetCategory[] array = new AssetCategoryImpl[3];
2632    
2633                            array[0] = getByParentCategoryId_PrevAndNext(session,
2634                                            assetCategory, parentCategoryId, orderByComparator, true);
2635    
2636                            array[1] = assetCategory;
2637    
2638                            array[2] = getByParentCategoryId_PrevAndNext(session,
2639                                            assetCategory, parentCategoryId, orderByComparator, false);
2640    
2641                            return array;
2642                    }
2643                    catch (Exception e) {
2644                            throw processException(e);
2645                    }
2646                    finally {
2647                            closeSession(session);
2648                    }
2649            }
2650    
2651            protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2652                    AssetCategory assetCategory, long parentCategoryId,
2653                    OrderByComparator orderByComparator, boolean previous) {
2654                    StringBundler query = null;
2655    
2656                    if (orderByComparator != null) {
2657                            query = new StringBundler(6 +
2658                                            (orderByComparator.getOrderByFields().length * 6));
2659                    }
2660                    else {
2661                            query = new StringBundler(3);
2662                    }
2663    
2664                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2665    
2666                    query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2667    
2668                    if (orderByComparator != null) {
2669                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2670    
2671                            if (orderByConditionFields.length > 0) {
2672                                    query.append(WHERE_AND);
2673                            }
2674    
2675                            for (int i = 0; i < orderByConditionFields.length; i++) {
2676                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2677                                    query.append(orderByConditionFields[i]);
2678    
2679                                    if ((i + 1) < orderByConditionFields.length) {
2680                                            if (orderByComparator.isAscending() ^ previous) {
2681                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2682                                            }
2683                                            else {
2684                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2685                                            }
2686                                    }
2687                                    else {
2688                                            if (orderByComparator.isAscending() ^ previous) {
2689                                                    query.append(WHERE_GREATER_THAN);
2690                                            }
2691                                            else {
2692                                                    query.append(WHERE_LESSER_THAN);
2693                                            }
2694                                    }
2695                            }
2696    
2697                            query.append(ORDER_BY_CLAUSE);
2698    
2699                            String[] orderByFields = orderByComparator.getOrderByFields();
2700    
2701                            for (int i = 0; i < orderByFields.length; i++) {
2702                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2703                                    query.append(orderByFields[i]);
2704    
2705                                    if ((i + 1) < orderByFields.length) {
2706                                            if (orderByComparator.isAscending() ^ previous) {
2707                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2708                                            }
2709                                            else {
2710                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2711                                            }
2712                                    }
2713                                    else {
2714                                            if (orderByComparator.isAscending() ^ previous) {
2715                                                    query.append(ORDER_BY_ASC);
2716                                            }
2717                                            else {
2718                                                    query.append(ORDER_BY_DESC);
2719                                            }
2720                                    }
2721                            }
2722                    }
2723                    else {
2724                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2725                    }
2726    
2727                    String sql = query.toString();
2728    
2729                    Query q = session.createQuery(sql);
2730    
2731                    q.setFirstResult(0);
2732                    q.setMaxResults(2);
2733    
2734                    QueryPos qPos = QueryPos.getInstance(q);
2735    
2736                    qPos.add(parentCategoryId);
2737    
2738                    if (orderByComparator != null) {
2739                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2740    
2741                            for (Object value : values) {
2742                                    qPos.add(value);
2743                            }
2744                    }
2745    
2746                    List<AssetCategory> list = q.list();
2747    
2748                    if (list.size() == 2) {
2749                            return list.get(1);
2750                    }
2751                    else {
2752                            return null;
2753                    }
2754            }
2755    
2756            /**
2757             * Removes all the asset categories where parentCategoryId = &#63; from the database.
2758             *
2759             * @param parentCategoryId the parent category ID
2760             * @throws SystemException if a system exception occurred
2761             */
2762            @Override
2763            public void removeByParentCategoryId(long parentCategoryId)
2764                    throws SystemException {
2765                    for (AssetCategory assetCategory : findByParentCategoryId(
2766                                    parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2767                            remove(assetCategory);
2768                    }
2769            }
2770    
2771            /**
2772             * Returns the number of asset categories where parentCategoryId = &#63;.
2773             *
2774             * @param parentCategoryId the parent category ID
2775             * @return the number of matching asset categories
2776             * @throws SystemException if a system exception occurred
2777             */
2778            @Override
2779            public int countByParentCategoryId(long parentCategoryId)
2780                    throws SystemException {
2781                    FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2782    
2783                    Object[] finderArgs = new Object[] { parentCategoryId };
2784    
2785                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2786                                    this);
2787    
2788                    if (count == null) {
2789                            StringBundler query = new StringBundler(2);
2790    
2791                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2792    
2793                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2794    
2795                            String sql = query.toString();
2796    
2797                            Session session = null;
2798    
2799                            try {
2800                                    session = openSession();
2801    
2802                                    Query q = session.createQuery(sql);
2803    
2804                                    QueryPos qPos = QueryPos.getInstance(q);
2805    
2806                                    qPos.add(parentCategoryId);
2807    
2808                                    count = (Long)q.uniqueResult();
2809    
2810                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2811                            }
2812                            catch (Exception e) {
2813                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2814    
2815                                    throw processException(e);
2816                            }
2817                            finally {
2818                                    closeSession(session);
2819                            }
2820                    }
2821    
2822                    return count.intValue();
2823            }
2824    
2825            private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2826                    "assetCategory.parentCategoryId = ?";
2827            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2828                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2829                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2830                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2831                            "findByVocabularyId",
2832                            new String[] {
2833                                    Long.class.getName(),
2834                                    
2835                            Integer.class.getName(), Integer.class.getName(),
2836                                    OrderByComparator.class.getName()
2837                            });
2838            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2839                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2840                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2841                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2842                            "findByVocabularyId", new String[] { Long.class.getName() },
2843                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2844                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2845            public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2846                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2847                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2848                            new String[] { Long.class.getName() });
2849    
2850            /**
2851             * Returns all the asset categories where vocabularyId = &#63;.
2852             *
2853             * @param vocabularyId the vocabulary ID
2854             * @return the matching asset categories
2855             * @throws SystemException if a system exception occurred
2856             */
2857            @Override
2858            public List<AssetCategory> findByVocabularyId(long vocabularyId)
2859                    throws SystemException {
2860                    return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2861                            QueryUtil.ALL_POS, null);
2862            }
2863    
2864            /**
2865             * Returns a range of all the asset categories where vocabularyId = &#63;.
2866             *
2867             * <p>
2868             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2869             * </p>
2870             *
2871             * @param vocabularyId the vocabulary ID
2872             * @param start the lower bound of the range of asset categories
2873             * @param end the upper bound of the range of asset categories (not inclusive)
2874             * @return the range of matching asset categories
2875             * @throws SystemException if a system exception occurred
2876             */
2877            @Override
2878            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2879                    int end) throws SystemException {
2880                    return findByVocabularyId(vocabularyId, start, end, null);
2881            }
2882    
2883            /**
2884             * Returns an ordered range of all the asset categories where vocabularyId = &#63;.
2885             *
2886             * <p>
2887             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2888             * </p>
2889             *
2890             * @param vocabularyId the vocabulary ID
2891             * @param start the lower bound of the range of asset categories
2892             * @param end the upper bound of the range of asset categories (not inclusive)
2893             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2894             * @return the ordered range of matching asset categories
2895             * @throws SystemException if a system exception occurred
2896             */
2897            @Override
2898            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2899                    int end, OrderByComparator orderByComparator) throws SystemException {
2900                    boolean pagination = true;
2901                    FinderPath finderPath = null;
2902                    Object[] finderArgs = null;
2903    
2904                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2905                                    (orderByComparator == null)) {
2906                            pagination = false;
2907                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2908                            finderArgs = new Object[] { vocabularyId };
2909                    }
2910                    else {
2911                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2912                            finderArgs = new Object[] {
2913                                            vocabularyId,
2914                                            
2915                                            start, end, orderByComparator
2916                                    };
2917                    }
2918    
2919                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2920                                    finderArgs, this);
2921    
2922                    if ((list != null) && !list.isEmpty()) {
2923                            for (AssetCategory assetCategory : list) {
2924                                    if ((vocabularyId != assetCategory.getVocabularyId())) {
2925                                            list = null;
2926    
2927                                            break;
2928                                    }
2929                            }
2930                    }
2931    
2932                    if (list == null) {
2933                            StringBundler query = null;
2934    
2935                            if (orderByComparator != null) {
2936                                    query = new StringBundler(3 +
2937                                                    (orderByComparator.getOrderByFields().length * 3));
2938                            }
2939                            else {
2940                                    query = new StringBundler(3);
2941                            }
2942    
2943                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2944    
2945                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2946    
2947                            if (orderByComparator != null) {
2948                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2949                                            orderByComparator);
2950                            }
2951                            else
2952                             if (pagination) {
2953                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2954                            }
2955    
2956                            String sql = query.toString();
2957    
2958                            Session session = null;
2959    
2960                            try {
2961                                    session = openSession();
2962    
2963                                    Query q = session.createQuery(sql);
2964    
2965                                    QueryPos qPos = QueryPos.getInstance(q);
2966    
2967                                    qPos.add(vocabularyId);
2968    
2969                                    if (!pagination) {
2970                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2971                                                            start, end, false);
2972    
2973                                            Collections.sort(list);
2974    
2975                                            list = new UnmodifiableList<AssetCategory>(list);
2976                                    }
2977                                    else {
2978                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2979                                                            start, end);
2980                                    }
2981    
2982                                    cacheResult(list);
2983    
2984                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2985                            }
2986                            catch (Exception e) {
2987                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2988    
2989                                    throw processException(e);
2990                            }
2991                            finally {
2992                                    closeSession(session);
2993                            }
2994                    }
2995    
2996                    return list;
2997            }
2998    
2999            /**
3000             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
3001             *
3002             * @param vocabularyId the vocabulary ID
3003             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3004             * @return the first matching asset category
3005             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3006             * @throws SystemException if a system exception occurred
3007             */
3008            @Override
3009            public AssetCategory findByVocabularyId_First(long vocabularyId,
3010                    OrderByComparator orderByComparator)
3011                    throws NoSuchCategoryException, SystemException {
3012                    AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
3013                                    orderByComparator);
3014    
3015                    if (assetCategory != null) {
3016                            return assetCategory;
3017                    }
3018    
3019                    StringBundler msg = new StringBundler(4);
3020    
3021                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3022    
3023                    msg.append("vocabularyId=");
3024                    msg.append(vocabularyId);
3025    
3026                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3027    
3028                    throw new NoSuchCategoryException(msg.toString());
3029            }
3030    
3031            /**
3032             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
3033             *
3034             * @param vocabularyId the vocabulary ID
3035             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3036             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
3037             * @throws SystemException if a system exception occurred
3038             */
3039            @Override
3040            public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3041                    OrderByComparator orderByComparator) throws SystemException {
3042                    List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3043                                    orderByComparator);
3044    
3045                    if (!list.isEmpty()) {
3046                            return list.get(0);
3047                    }
3048    
3049                    return null;
3050            }
3051    
3052            /**
3053             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
3054             *
3055             * @param vocabularyId the vocabulary ID
3056             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3057             * @return the last matching asset category
3058             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3059             * @throws SystemException if a system exception occurred
3060             */
3061            @Override
3062            public AssetCategory findByVocabularyId_Last(long vocabularyId,
3063                    OrderByComparator orderByComparator)
3064                    throws NoSuchCategoryException, SystemException {
3065                    AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3066                                    orderByComparator);
3067    
3068                    if (assetCategory != null) {
3069                            return assetCategory;
3070                    }
3071    
3072                    StringBundler msg = new StringBundler(4);
3073    
3074                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3075    
3076                    msg.append("vocabularyId=");
3077                    msg.append(vocabularyId);
3078    
3079                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3080    
3081                    throw new NoSuchCategoryException(msg.toString());
3082            }
3083    
3084            /**
3085             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
3086             *
3087             * @param vocabularyId the vocabulary ID
3088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3089             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
3090             * @throws SystemException if a system exception occurred
3091             */
3092            @Override
3093            public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3094                    OrderByComparator orderByComparator) throws SystemException {
3095                    int count = countByVocabularyId(vocabularyId);
3096    
3097                    if (count == 0) {
3098                            return null;
3099                    }
3100    
3101                    List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3102                                    count, orderByComparator);
3103    
3104                    if (!list.isEmpty()) {
3105                            return list.get(0);
3106                    }
3107    
3108                    return null;
3109            }
3110    
3111            /**
3112             * Returns the asset categories before and after the current asset category in the ordered set where vocabularyId = &#63;.
3113             *
3114             * @param categoryId the primary key of the current asset category
3115             * @param vocabularyId the vocabulary ID
3116             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3117             * @return the previous, current, and next asset category
3118             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3119             * @throws SystemException if a system exception occurred
3120             */
3121            @Override
3122            public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3123                    long vocabularyId, OrderByComparator orderByComparator)
3124                    throws NoSuchCategoryException, SystemException {
3125                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3126    
3127                    Session session = null;
3128    
3129                    try {
3130                            session = openSession();
3131    
3132                            AssetCategory[] array = new AssetCategoryImpl[3];
3133    
3134                            array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3135                                            vocabularyId, orderByComparator, true);
3136    
3137                            array[1] = assetCategory;
3138    
3139                            array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3140                                            vocabularyId, orderByComparator, false);
3141    
3142                            return array;
3143                    }
3144                    catch (Exception e) {
3145                            throw processException(e);
3146                    }
3147                    finally {
3148                            closeSession(session);
3149                    }
3150            }
3151    
3152            protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3153                    AssetCategory assetCategory, long vocabularyId,
3154                    OrderByComparator orderByComparator, boolean previous) {
3155                    StringBundler query = null;
3156    
3157                    if (orderByComparator != null) {
3158                            query = new StringBundler(6 +
3159                                            (orderByComparator.getOrderByFields().length * 6));
3160                    }
3161                    else {
3162                            query = new StringBundler(3);
3163                    }
3164    
3165                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3166    
3167                    query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3168    
3169                    if (orderByComparator != null) {
3170                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3171    
3172                            if (orderByConditionFields.length > 0) {
3173                                    query.append(WHERE_AND);
3174                            }
3175    
3176                            for (int i = 0; i < orderByConditionFields.length; i++) {
3177                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3178                                    query.append(orderByConditionFields[i]);
3179    
3180                                    if ((i + 1) < orderByConditionFields.length) {
3181                                            if (orderByComparator.isAscending() ^ previous) {
3182                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3183                                            }
3184                                            else {
3185                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3186                                            }
3187                                    }
3188                                    else {
3189                                            if (orderByComparator.isAscending() ^ previous) {
3190                                                    query.append(WHERE_GREATER_THAN);
3191                                            }
3192                                            else {
3193                                                    query.append(WHERE_LESSER_THAN);
3194                                            }
3195                                    }
3196                            }
3197    
3198                            query.append(ORDER_BY_CLAUSE);
3199    
3200                            String[] orderByFields = orderByComparator.getOrderByFields();
3201    
3202                            for (int i = 0; i < orderByFields.length; i++) {
3203                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3204                                    query.append(orderByFields[i]);
3205    
3206                                    if ((i + 1) < orderByFields.length) {
3207                                            if (orderByComparator.isAscending() ^ previous) {
3208                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3209                                            }
3210                                            else {
3211                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3212                                            }
3213                                    }
3214                                    else {
3215                                            if (orderByComparator.isAscending() ^ previous) {
3216                                                    query.append(ORDER_BY_ASC);
3217                                            }
3218                                            else {
3219                                                    query.append(ORDER_BY_DESC);
3220                                            }
3221                                    }
3222                            }
3223                    }
3224                    else {
3225                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3226                    }
3227    
3228                    String sql = query.toString();
3229    
3230                    Query q = session.createQuery(sql);
3231    
3232                    q.setFirstResult(0);
3233                    q.setMaxResults(2);
3234    
3235                    QueryPos qPos = QueryPos.getInstance(q);
3236    
3237                    qPos.add(vocabularyId);
3238    
3239                    if (orderByComparator != null) {
3240                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3241    
3242                            for (Object value : values) {
3243                                    qPos.add(value);
3244                            }
3245                    }
3246    
3247                    List<AssetCategory> list = q.list();
3248    
3249                    if (list.size() == 2) {
3250                            return list.get(1);
3251                    }
3252                    else {
3253                            return null;
3254                    }
3255            }
3256    
3257            /**
3258             * Removes all the asset categories where vocabularyId = &#63; from the database.
3259             *
3260             * @param vocabularyId the vocabulary ID
3261             * @throws SystemException if a system exception occurred
3262             */
3263            @Override
3264            public void removeByVocabularyId(long vocabularyId)
3265                    throws SystemException {
3266                    for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3267                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3268                            remove(assetCategory);
3269                    }
3270            }
3271    
3272            /**
3273             * Returns the number of asset categories where vocabularyId = &#63;.
3274             *
3275             * @param vocabularyId the vocabulary ID
3276             * @return the number of matching asset categories
3277             * @throws SystemException if a system exception occurred
3278             */
3279            @Override
3280            public int countByVocabularyId(long vocabularyId) throws SystemException {
3281                    FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3282    
3283                    Object[] finderArgs = new Object[] { vocabularyId };
3284    
3285                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3286                                    this);
3287    
3288                    if (count == null) {
3289                            StringBundler query = new StringBundler(2);
3290    
3291                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3292    
3293                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3294    
3295                            String sql = query.toString();
3296    
3297                            Session session = null;
3298    
3299                            try {
3300                                    session = openSession();
3301    
3302                                    Query q = session.createQuery(sql);
3303    
3304                                    QueryPos qPos = QueryPos.getInstance(q);
3305    
3306                                    qPos.add(vocabularyId);
3307    
3308                                    count = (Long)q.uniqueResult();
3309    
3310                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3311                            }
3312                            catch (Exception e) {
3313                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3314    
3315                                    throw processException(e);
3316                            }
3317                            finally {
3318                                    closeSession(session);
3319                            }
3320                    }
3321    
3322                    return count.intValue();
3323            }
3324    
3325            private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3326            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3327                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3328                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3329                            "findByG_V",
3330                            new String[] {
3331                                    Long.class.getName(), Long.class.getName(),
3332                                    
3333                            Integer.class.getName(), Integer.class.getName(),
3334                                    OrderByComparator.class.getName()
3335                            });
3336            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3337                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3338                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3339                            "findByG_V",
3340                            new String[] { Long.class.getName(), Long.class.getName() },
3341                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3342                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3343                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3344            public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3345                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3346                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3347                            new String[] { Long.class.getName(), Long.class.getName() });
3348            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3349                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3350                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3351                            new String[] { Long.class.getName(), Long.class.getName() });
3352    
3353            /**
3354             * Returns all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3355             *
3356             * @param groupId the group ID
3357             * @param vocabularyId the vocabulary ID
3358             * @return the matching asset categories
3359             * @throws SystemException if a system exception occurred
3360             */
3361            @Override
3362            public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3363                    throws SystemException {
3364                    return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3365                            QueryUtil.ALL_POS, null);
3366            }
3367    
3368            /**
3369             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3370             *
3371             * <p>
3372             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3373             * </p>
3374             *
3375             * @param groupId the group ID
3376             * @param vocabularyId the vocabulary ID
3377             * @param start the lower bound of the range of asset categories
3378             * @param end the upper bound of the range of asset categories (not inclusive)
3379             * @return the range of matching asset categories
3380             * @throws SystemException if a system exception occurred
3381             */
3382            @Override
3383            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3384                    int start, int end) throws SystemException {
3385                    return findByG_V(groupId, vocabularyId, start, end, null);
3386            }
3387    
3388            /**
3389             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3390             *
3391             * <p>
3392             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3393             * </p>
3394             *
3395             * @param groupId the group ID
3396             * @param vocabularyId the vocabulary ID
3397             * @param start the lower bound of the range of asset categories
3398             * @param end the upper bound of the range of asset categories (not inclusive)
3399             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3400             * @return the ordered range of matching asset categories
3401             * @throws SystemException if a system exception occurred
3402             */
3403            @Override
3404            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3405                    int start, int end, OrderByComparator orderByComparator)
3406                    throws SystemException {
3407                    boolean pagination = true;
3408                    FinderPath finderPath = null;
3409                    Object[] finderArgs = null;
3410    
3411                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3412                                    (orderByComparator == null)) {
3413                            pagination = false;
3414                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3415                            finderArgs = new Object[] { groupId, vocabularyId };
3416                    }
3417                    else {
3418                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3419                            finderArgs = new Object[] {
3420                                            groupId, vocabularyId,
3421                                            
3422                                            start, end, orderByComparator
3423                                    };
3424                    }
3425    
3426                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3427                                    finderArgs, this);
3428    
3429                    if ((list != null) && !list.isEmpty()) {
3430                            for (AssetCategory assetCategory : list) {
3431                                    if ((groupId != assetCategory.getGroupId()) ||
3432                                                    (vocabularyId != assetCategory.getVocabularyId())) {
3433                                            list = null;
3434    
3435                                            break;
3436                                    }
3437                            }
3438                    }
3439    
3440                    if (list == null) {
3441                            StringBundler query = null;
3442    
3443                            if (orderByComparator != null) {
3444                                    query = new StringBundler(4 +
3445                                                    (orderByComparator.getOrderByFields().length * 3));
3446                            }
3447                            else {
3448                                    query = new StringBundler(4);
3449                            }
3450    
3451                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3452    
3453                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3454    
3455                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3456    
3457                            if (orderByComparator != null) {
3458                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3459                                            orderByComparator);
3460                            }
3461                            else
3462                             if (pagination) {
3463                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3464                            }
3465    
3466                            String sql = query.toString();
3467    
3468                            Session session = null;
3469    
3470                            try {
3471                                    session = openSession();
3472    
3473                                    Query q = session.createQuery(sql);
3474    
3475                                    QueryPos qPos = QueryPos.getInstance(q);
3476    
3477                                    qPos.add(groupId);
3478    
3479                                    qPos.add(vocabularyId);
3480    
3481                                    if (!pagination) {
3482                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3483                                                            start, end, false);
3484    
3485                                            Collections.sort(list);
3486    
3487                                            list = new UnmodifiableList<AssetCategory>(list);
3488                                    }
3489                                    else {
3490                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3491                                                            start, end);
3492                                    }
3493    
3494                                    cacheResult(list);
3495    
3496                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3497                            }
3498                            catch (Exception e) {
3499                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3500    
3501                                    throw processException(e);
3502                            }
3503                            finally {
3504                                    closeSession(session);
3505                            }
3506                    }
3507    
3508                    return list;
3509            }
3510    
3511            /**
3512             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3513             *
3514             * @param groupId the group ID
3515             * @param vocabularyId the vocabulary ID
3516             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3517             * @return the first matching asset category
3518             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3519             * @throws SystemException if a system exception occurred
3520             */
3521            @Override
3522            public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3523                    OrderByComparator orderByComparator)
3524                    throws NoSuchCategoryException, SystemException {
3525                    AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3526                                    orderByComparator);
3527    
3528                    if (assetCategory != null) {
3529                            return assetCategory;
3530                    }
3531    
3532                    StringBundler msg = new StringBundler(6);
3533    
3534                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3535    
3536                    msg.append("groupId=");
3537                    msg.append(groupId);
3538    
3539                    msg.append(", vocabularyId=");
3540                    msg.append(vocabularyId);
3541    
3542                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3543    
3544                    throw new NoSuchCategoryException(msg.toString());
3545            }
3546    
3547            /**
3548             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3549             *
3550             * @param groupId the group ID
3551             * @param vocabularyId the vocabulary ID
3552             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3553             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
3554             * @throws SystemException if a system exception occurred
3555             */
3556            @Override
3557            public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3558                    OrderByComparator orderByComparator) throws SystemException {
3559                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3560                                    orderByComparator);
3561    
3562                    if (!list.isEmpty()) {
3563                            return list.get(0);
3564                    }
3565    
3566                    return null;
3567            }
3568    
3569            /**
3570             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3571             *
3572             * @param groupId the group ID
3573             * @param vocabularyId the vocabulary ID
3574             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3575             * @return the last matching asset category
3576             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3577             * @throws SystemException if a system exception occurred
3578             */
3579            @Override
3580            public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3581                    OrderByComparator orderByComparator)
3582                    throws NoSuchCategoryException, SystemException {
3583                    AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3584                                    orderByComparator);
3585    
3586                    if (assetCategory != null) {
3587                            return assetCategory;
3588                    }
3589    
3590                    StringBundler msg = new StringBundler(6);
3591    
3592                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3593    
3594                    msg.append("groupId=");
3595                    msg.append(groupId);
3596    
3597                    msg.append(", vocabularyId=");
3598                    msg.append(vocabularyId);
3599    
3600                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3601    
3602                    throw new NoSuchCategoryException(msg.toString());
3603            }
3604    
3605            /**
3606             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3607             *
3608             * @param groupId the group ID
3609             * @param vocabularyId the vocabulary ID
3610             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3611             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
3612             * @throws SystemException if a system exception occurred
3613             */
3614            @Override
3615            public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3616                    OrderByComparator orderByComparator) throws SystemException {
3617                    int count = countByG_V(groupId, vocabularyId);
3618    
3619                    if (count == 0) {
3620                            return null;
3621                    }
3622    
3623                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3624                                    count, orderByComparator);
3625    
3626                    if (!list.isEmpty()) {
3627                            return list.get(0);
3628                    }
3629    
3630                    return null;
3631            }
3632    
3633            /**
3634             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3635             *
3636             * @param categoryId the primary key of the current asset category
3637             * @param groupId the group ID
3638             * @param vocabularyId the vocabulary ID
3639             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3640             * @return the previous, current, and next asset category
3641             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3642             * @throws SystemException if a system exception occurred
3643             */
3644            @Override
3645            public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3646                    long vocabularyId, OrderByComparator orderByComparator)
3647                    throws NoSuchCategoryException, SystemException {
3648                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3649    
3650                    Session session = null;
3651    
3652                    try {
3653                            session = openSession();
3654    
3655                            AssetCategory[] array = new AssetCategoryImpl[3];
3656    
3657                            array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3658                                            vocabularyId, orderByComparator, true);
3659    
3660                            array[1] = assetCategory;
3661    
3662                            array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3663                                            vocabularyId, orderByComparator, false);
3664    
3665                            return array;
3666                    }
3667                    catch (Exception e) {
3668                            throw processException(e);
3669                    }
3670                    finally {
3671                            closeSession(session);
3672                    }
3673            }
3674    
3675            protected AssetCategory getByG_V_PrevAndNext(Session session,
3676                    AssetCategory assetCategory, long groupId, long vocabularyId,
3677                    OrderByComparator orderByComparator, boolean previous) {
3678                    StringBundler query = null;
3679    
3680                    if (orderByComparator != null) {
3681                            query = new StringBundler(6 +
3682                                            (orderByComparator.getOrderByFields().length * 6));
3683                    }
3684                    else {
3685                            query = new StringBundler(3);
3686                    }
3687    
3688                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3689    
3690                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3691    
3692                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3693    
3694                    if (orderByComparator != null) {
3695                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3696    
3697                            if (orderByConditionFields.length > 0) {
3698                                    query.append(WHERE_AND);
3699                            }
3700    
3701                            for (int i = 0; i < orderByConditionFields.length; i++) {
3702                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3703                                    query.append(orderByConditionFields[i]);
3704    
3705                                    if ((i + 1) < orderByConditionFields.length) {
3706                                            if (orderByComparator.isAscending() ^ previous) {
3707                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3708                                            }
3709                                            else {
3710                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3711                                            }
3712                                    }
3713                                    else {
3714                                            if (orderByComparator.isAscending() ^ previous) {
3715                                                    query.append(WHERE_GREATER_THAN);
3716                                            }
3717                                            else {
3718                                                    query.append(WHERE_LESSER_THAN);
3719                                            }
3720                                    }
3721                            }
3722    
3723                            query.append(ORDER_BY_CLAUSE);
3724    
3725                            String[] orderByFields = orderByComparator.getOrderByFields();
3726    
3727                            for (int i = 0; i < orderByFields.length; i++) {
3728                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3729                                    query.append(orderByFields[i]);
3730    
3731                                    if ((i + 1) < orderByFields.length) {
3732                                            if (orderByComparator.isAscending() ^ previous) {
3733                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3734                                            }
3735                                            else {
3736                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3737                                            }
3738                                    }
3739                                    else {
3740                                            if (orderByComparator.isAscending() ^ previous) {
3741                                                    query.append(ORDER_BY_ASC);
3742                                            }
3743                                            else {
3744                                                    query.append(ORDER_BY_DESC);
3745                                            }
3746                                    }
3747                            }
3748                    }
3749                    else {
3750                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3751                    }
3752    
3753                    String sql = query.toString();
3754    
3755                    Query q = session.createQuery(sql);
3756    
3757                    q.setFirstResult(0);
3758                    q.setMaxResults(2);
3759    
3760                    QueryPos qPos = QueryPos.getInstance(q);
3761    
3762                    qPos.add(groupId);
3763    
3764                    qPos.add(vocabularyId);
3765    
3766                    if (orderByComparator != null) {
3767                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3768    
3769                            for (Object value : values) {
3770                                    qPos.add(value);
3771                            }
3772                    }
3773    
3774                    List<AssetCategory> list = q.list();
3775    
3776                    if (list.size() == 2) {
3777                            return list.get(1);
3778                    }
3779                    else {
3780                            return null;
3781                    }
3782            }
3783    
3784            /**
3785             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3786             *
3787             * @param groupId the group ID
3788             * @param vocabularyId the vocabulary ID
3789             * @return the matching asset categories that the user has permission to view
3790             * @throws SystemException if a system exception occurred
3791             */
3792            @Override
3793            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3794                    throws SystemException {
3795                    return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3796                            QueryUtil.ALL_POS, null);
3797            }
3798    
3799            /**
3800             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3801             *
3802             * <p>
3803             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3804             * </p>
3805             *
3806             * @param groupId the group ID
3807             * @param vocabularyId the vocabulary ID
3808             * @param start the lower bound of the range of asset categories
3809             * @param end the upper bound of the range of asset categories (not inclusive)
3810             * @return the range of matching asset categories that the user has permission to view
3811             * @throws SystemException if a system exception occurred
3812             */
3813            @Override
3814            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3815                    int start, int end) throws SystemException {
3816                    return filterFindByG_V(groupId, vocabularyId, start, end, null);
3817            }
3818    
3819            /**
3820             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and vocabularyId = &#63;.
3821             *
3822             * <p>
3823             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
3824             * </p>
3825             *
3826             * @param groupId the group ID
3827             * @param vocabularyId the vocabulary ID
3828             * @param start the lower bound of the range of asset categories
3829             * @param end the upper bound of the range of asset categories (not inclusive)
3830             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3831             * @return the ordered range of matching asset categories that the user has permission to view
3832             * @throws SystemException if a system exception occurred
3833             */
3834            @Override
3835            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3836                    int start, int end, OrderByComparator orderByComparator)
3837                    throws SystemException {
3838                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3839                            return findByG_V(groupId, vocabularyId, start, end,
3840                                    orderByComparator);
3841                    }
3842    
3843                    StringBundler query = null;
3844    
3845                    if (orderByComparator != null) {
3846                            query = new StringBundler(4 +
3847                                            (orderByComparator.getOrderByFields().length * 3));
3848                    }
3849                    else {
3850                            query = new StringBundler(4);
3851                    }
3852    
3853                    if (getDB().isSupportsInlineDistinct()) {
3854                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3855                    }
3856                    else {
3857                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3858                    }
3859    
3860                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3861    
3862                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3863    
3864                    if (!getDB().isSupportsInlineDistinct()) {
3865                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3866                    }
3867    
3868                    if (orderByComparator != null) {
3869                            if (getDB().isSupportsInlineDistinct()) {
3870                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3871                                            orderByComparator, true);
3872                            }
3873                            else {
3874                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3875                                            orderByComparator, true);
3876                            }
3877                    }
3878                    else {
3879                            if (getDB().isSupportsInlineDistinct()) {
3880                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3881                            }
3882                            else {
3883                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3884                            }
3885                    }
3886    
3887                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3888                                    AssetCategory.class.getName(),
3889                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3890    
3891                    Session session = null;
3892    
3893                    try {
3894                            session = openSession();
3895    
3896                            SQLQuery q = session.createSQLQuery(sql);
3897    
3898                            if (getDB().isSupportsInlineDistinct()) {
3899                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3900                            }
3901                            else {
3902                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3903                            }
3904    
3905                            QueryPos qPos = QueryPos.getInstance(q);
3906    
3907                            qPos.add(groupId);
3908    
3909                            qPos.add(vocabularyId);
3910    
3911                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3912                                    end);
3913                    }
3914                    catch (Exception e) {
3915                            throw processException(e);
3916                    }
3917                    finally {
3918                            closeSession(session);
3919                    }
3920            }
3921    
3922            /**
3923             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3924             *
3925             * @param categoryId the primary key of the current asset category
3926             * @param groupId the group ID
3927             * @param vocabularyId the vocabulary ID
3928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3929             * @return the previous, current, and next asset category
3930             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3931             * @throws SystemException if a system exception occurred
3932             */
3933            @Override
3934            public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3935                    long groupId, long vocabularyId, OrderByComparator orderByComparator)
3936                    throws NoSuchCategoryException, SystemException {
3937                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3938                            return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3939                                    orderByComparator);
3940                    }
3941    
3942                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3943    
3944                    Session session = null;
3945    
3946                    try {
3947                            session = openSession();
3948    
3949                            AssetCategory[] array = new AssetCategoryImpl[3];
3950    
3951                            array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3952                                            groupId, vocabularyId, orderByComparator, true);
3953    
3954                            array[1] = assetCategory;
3955    
3956                            array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3957                                            groupId, vocabularyId, orderByComparator, false);
3958    
3959                            return array;
3960                    }
3961                    catch (Exception e) {
3962                            throw processException(e);
3963                    }
3964                    finally {
3965                            closeSession(session);
3966                    }
3967            }
3968    
3969            protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3970                    AssetCategory assetCategory, long groupId, long vocabularyId,
3971                    OrderByComparator orderByComparator, boolean previous) {
3972                    StringBundler query = null;
3973    
3974                    if (orderByComparator != null) {
3975                            query = new StringBundler(6 +
3976                                            (orderByComparator.getOrderByFields().length * 6));
3977                    }
3978                    else {
3979                            query = new StringBundler(3);
3980                    }
3981    
3982                    if (getDB().isSupportsInlineDistinct()) {
3983                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3984                    }
3985                    else {
3986                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3987                    }
3988    
3989                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3990    
3991                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3992    
3993                    if (!getDB().isSupportsInlineDistinct()) {
3994                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3995                    }
3996    
3997                    if (orderByComparator != null) {
3998                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3999    
4000                            if (orderByConditionFields.length > 0) {
4001                                    query.append(WHERE_AND);
4002                            }
4003    
4004                            for (int i = 0; i < orderByConditionFields.length; i++) {
4005                                    if (getDB().isSupportsInlineDistinct()) {
4006                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4007                                    }
4008                                    else {
4009                                            query.append(_ORDER_BY_ENTITY_TABLE);
4010                                    }
4011    
4012                                    query.append(orderByConditionFields[i]);
4013    
4014                                    if ((i + 1) < orderByConditionFields.length) {
4015                                            if (orderByComparator.isAscending() ^ previous) {
4016                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4017                                            }
4018                                            else {
4019                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4020                                            }
4021                                    }
4022                                    else {
4023                                            if (orderByComparator.isAscending() ^ previous) {
4024                                                    query.append(WHERE_GREATER_THAN);
4025                                            }
4026                                            else {
4027                                                    query.append(WHERE_LESSER_THAN);
4028                                            }
4029                                    }
4030                            }
4031    
4032                            query.append(ORDER_BY_CLAUSE);
4033    
4034                            String[] orderByFields = orderByComparator.getOrderByFields();
4035    
4036                            for (int i = 0; i < orderByFields.length; i++) {
4037                                    if (getDB().isSupportsInlineDistinct()) {
4038                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4039                                    }
4040                                    else {
4041                                            query.append(_ORDER_BY_ENTITY_TABLE);
4042                                    }
4043    
4044                                    query.append(orderByFields[i]);
4045    
4046                                    if ((i + 1) < orderByFields.length) {
4047                                            if (orderByComparator.isAscending() ^ previous) {
4048                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4049                                            }
4050                                            else {
4051                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4052                                            }
4053                                    }
4054                                    else {
4055                                            if (orderByComparator.isAscending() ^ previous) {
4056                                                    query.append(ORDER_BY_ASC);
4057                                            }
4058                                            else {
4059                                                    query.append(ORDER_BY_DESC);
4060                                            }
4061                                    }
4062                            }
4063                    }
4064                    else {
4065                            if (getDB().isSupportsInlineDistinct()) {
4066                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4067                            }
4068                            else {
4069                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4070                            }
4071                    }
4072    
4073                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4074                                    AssetCategory.class.getName(),
4075                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4076    
4077                    SQLQuery q = session.createSQLQuery(sql);
4078    
4079                    q.setFirstResult(0);
4080                    q.setMaxResults(2);
4081    
4082                    if (getDB().isSupportsInlineDistinct()) {
4083                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4084                    }
4085                    else {
4086                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4087                    }
4088    
4089                    QueryPos qPos = QueryPos.getInstance(q);
4090    
4091                    qPos.add(groupId);
4092    
4093                    qPos.add(vocabularyId);
4094    
4095                    if (orderByComparator != null) {
4096                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4097    
4098                            for (Object value : values) {
4099                                    qPos.add(value);
4100                            }
4101                    }
4102    
4103                    List<AssetCategory> list = q.list();
4104    
4105                    if (list.size() == 2) {
4106                            return list.get(1);
4107                    }
4108                    else {
4109                            return null;
4110                    }
4111            }
4112    
4113            /**
4114             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4115             *
4116             * @param groupId the group ID
4117             * @param vocabularyIds the vocabulary IDs
4118             * @return the matching asset categories that the user has permission to view
4119             * @throws SystemException if a system exception occurred
4120             */
4121            @Override
4122            public List<AssetCategory> filterFindByG_V(long groupId,
4123                    long[] vocabularyIds) throws SystemException {
4124                    return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4125                            QueryUtil.ALL_POS, null);
4126            }
4127    
4128            /**
4129             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4130             *
4131             * <p>
4132             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4133             * </p>
4134             *
4135             * @param groupId the group ID
4136             * @param vocabularyIds the vocabulary IDs
4137             * @param start the lower bound of the range of asset categories
4138             * @param end the upper bound of the range of asset categories (not inclusive)
4139             * @return the range of matching asset categories that the user has permission to view
4140             * @throws SystemException if a system exception occurred
4141             */
4142            @Override
4143            public List<AssetCategory> filterFindByG_V(long groupId,
4144                    long[] vocabularyIds, int start, int end) throws SystemException {
4145                    return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4146            }
4147    
4148            /**
4149             * Returns an ordered range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4150             *
4151             * <p>
4152             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4153             * </p>
4154             *
4155             * @param groupId the group ID
4156             * @param vocabularyIds the vocabulary IDs
4157             * @param start the lower bound of the range of asset categories
4158             * @param end the upper bound of the range of asset categories (not inclusive)
4159             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4160             * @return the ordered range of matching asset categories that the user has permission to view
4161             * @throws SystemException if a system exception occurred
4162             */
4163            @Override
4164            public List<AssetCategory> filterFindByG_V(long groupId,
4165                    long[] vocabularyIds, int start, int end,
4166                    OrderByComparator orderByComparator) throws SystemException {
4167                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4168                            return findByG_V(groupId, vocabularyIds, start, end,
4169                                    orderByComparator);
4170                    }
4171    
4172                    StringBundler query = new StringBundler();
4173    
4174                    if (getDB().isSupportsInlineDistinct()) {
4175                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4176                    }
4177                    else {
4178                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4179                    }
4180    
4181                    boolean conjunctionable = false;
4182    
4183                    if (conjunctionable) {
4184                            query.append(WHERE_AND);
4185                    }
4186    
4187                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4188    
4189                    conjunctionable = true;
4190    
4191                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4192                            if (conjunctionable) {
4193                                    query.append(WHERE_AND);
4194                            }
4195    
4196                            query.append(StringPool.OPEN_PARENTHESIS);
4197    
4198                            for (int i = 0; i < vocabularyIds.length; i++) {
4199                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4200    
4201                                    if ((i + 1) < vocabularyIds.length) {
4202                                            query.append(WHERE_OR);
4203                                    }
4204                            }
4205    
4206                            query.append(StringPool.CLOSE_PARENTHESIS);
4207    
4208                            conjunctionable = true;
4209                    }
4210    
4211                    if (!getDB().isSupportsInlineDistinct()) {
4212                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4213                    }
4214    
4215                    if (orderByComparator != null) {
4216                            if (getDB().isSupportsInlineDistinct()) {
4217                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4218                                            orderByComparator, true);
4219                            }
4220                            else {
4221                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4222                                            orderByComparator, true);
4223                            }
4224                    }
4225                    else {
4226                            if (getDB().isSupportsInlineDistinct()) {
4227                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4228                            }
4229                            else {
4230                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4231                            }
4232                    }
4233    
4234                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4235                                    AssetCategory.class.getName(),
4236                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4237    
4238                    Session session = null;
4239    
4240                    try {
4241                            session = openSession();
4242    
4243                            SQLQuery q = session.createSQLQuery(sql);
4244    
4245                            if (getDB().isSupportsInlineDistinct()) {
4246                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4247                            }
4248                            else {
4249                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4250                            }
4251    
4252                            QueryPos qPos = QueryPos.getInstance(q);
4253    
4254                            qPos.add(groupId);
4255    
4256                            if (vocabularyIds != null) {
4257                                    qPos.add(vocabularyIds);
4258                            }
4259    
4260                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4261                                    end);
4262                    }
4263                    catch (Exception e) {
4264                            throw processException(e);
4265                    }
4266                    finally {
4267                            closeSession(session);
4268                    }
4269            }
4270    
4271            /**
4272             * Returns all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4273             *
4274             * <p>
4275             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4276             * </p>
4277             *
4278             * @param groupId the group ID
4279             * @param vocabularyIds the vocabulary IDs
4280             * @return the matching asset categories
4281             * @throws SystemException if a system exception occurred
4282             */
4283            @Override
4284            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
4285                    throws SystemException {
4286                    return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4287                            QueryUtil.ALL_POS, null);
4288            }
4289    
4290            /**
4291             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4292             *
4293             * <p>
4294             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4295             * </p>
4296             *
4297             * @param groupId the group ID
4298             * @param vocabularyIds the vocabulary IDs
4299             * @param start the lower bound of the range of asset categories
4300             * @param end the upper bound of the range of asset categories (not inclusive)
4301             * @return the range of matching asset categories
4302             * @throws SystemException if a system exception occurred
4303             */
4304            @Override
4305            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4306                    int start, int end) throws SystemException {
4307                    return findByG_V(groupId, vocabularyIds, start, end, null);
4308            }
4309    
4310            /**
4311             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4312             *
4313             * <p>
4314             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4315             * </p>
4316             *
4317             * @param groupId the group ID
4318             * @param vocabularyIds the vocabulary IDs
4319             * @param start the lower bound of the range of asset categories
4320             * @param end the upper bound of the range of asset categories (not inclusive)
4321             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4322             * @return the ordered range of matching asset categories
4323             * @throws SystemException if a system exception occurred
4324             */
4325            @Override
4326            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4327                    int start, int end, OrderByComparator orderByComparator)
4328                    throws SystemException {
4329                    if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
4330                            return findByG_V(groupId, vocabularyIds[0], start, end,
4331                                    orderByComparator);
4332                    }
4333    
4334                    boolean pagination = true;
4335                    Object[] finderArgs = null;
4336    
4337                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4338                                    (orderByComparator == null)) {
4339                            pagination = false;
4340                            finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4341                    }
4342                    else {
4343                            finderArgs = new Object[] {
4344                                            groupId, StringUtil.merge(vocabularyIds),
4345                                            
4346                                            start, end, orderByComparator
4347                                    };
4348                    }
4349    
4350                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4351                                    finderArgs, this);
4352    
4353                    if ((list != null) && !list.isEmpty()) {
4354                            for (AssetCategory assetCategory : list) {
4355                                    if ((groupId != assetCategory.getGroupId()) ||
4356                                                    !ArrayUtil.contains(vocabularyIds,
4357                                                            assetCategory.getVocabularyId())) {
4358                                            list = null;
4359    
4360                                            break;
4361                                    }
4362                            }
4363                    }
4364    
4365                    if (list == null) {
4366                            StringBundler query = new StringBundler();
4367    
4368                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4369    
4370                            boolean conjunctionable = false;
4371    
4372                            if (conjunctionable) {
4373                                    query.append(WHERE_AND);
4374                            }
4375    
4376                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4377    
4378                            conjunctionable = true;
4379    
4380                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4381                                    if (conjunctionable) {
4382                                            query.append(WHERE_AND);
4383                                    }
4384    
4385                                    query.append(StringPool.OPEN_PARENTHESIS);
4386    
4387                                    for (int i = 0; i < vocabularyIds.length; i++) {
4388                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4389    
4390                                            if ((i + 1) < vocabularyIds.length) {
4391                                                    query.append(WHERE_OR);
4392                                            }
4393                                    }
4394    
4395                                    query.append(StringPool.CLOSE_PARENTHESIS);
4396    
4397                                    conjunctionable = true;
4398                            }
4399    
4400                            if (orderByComparator != null) {
4401                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4402                                            orderByComparator);
4403                            }
4404                            else
4405                             if (pagination) {
4406                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4407                            }
4408    
4409                            String sql = query.toString();
4410    
4411                            Session session = null;
4412    
4413                            try {
4414                                    session = openSession();
4415    
4416                                    Query q = session.createQuery(sql);
4417    
4418                                    QueryPos qPos = QueryPos.getInstance(q);
4419    
4420                                    qPos.add(groupId);
4421    
4422                                    if (vocabularyIds != null) {
4423                                            qPos.add(vocabularyIds);
4424                                    }
4425    
4426                                    if (!pagination) {
4427                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4428                                                            start, end, false);
4429    
4430                                            Collections.sort(list);
4431    
4432                                            list = new UnmodifiableList<AssetCategory>(list);
4433                                    }
4434                                    else {
4435                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4436                                                            start, end);
4437                                    }
4438    
4439                                    cacheResult(list);
4440    
4441                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4442                                            finderArgs, list);
4443                            }
4444                            catch (Exception e) {
4445                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4446                                            finderArgs);
4447    
4448                                    throw processException(e);
4449                            }
4450                            finally {
4451                                    closeSession(session);
4452                            }
4453                    }
4454    
4455                    return list;
4456            }
4457    
4458            /**
4459             * Removes all the asset categories where groupId = &#63; and vocabularyId = &#63; from the database.
4460             *
4461             * @param groupId the group ID
4462             * @param vocabularyId the vocabulary ID
4463             * @throws SystemException if a system exception occurred
4464             */
4465            @Override
4466            public void removeByG_V(long groupId, long vocabularyId)
4467                    throws SystemException {
4468                    for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4469                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4470                            remove(assetCategory);
4471                    }
4472            }
4473    
4474            /**
4475             * Returns the number of asset categories where groupId = &#63; and vocabularyId = &#63;.
4476             *
4477             * @param groupId the group ID
4478             * @param vocabularyId the vocabulary ID
4479             * @return the number of matching asset categories
4480             * @throws SystemException if a system exception occurred
4481             */
4482            @Override
4483            public int countByG_V(long groupId, long vocabularyId)
4484                    throws SystemException {
4485                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4486    
4487                    Object[] finderArgs = new Object[] { groupId, vocabularyId };
4488    
4489                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4490                                    this);
4491    
4492                    if (count == null) {
4493                            StringBundler query = new StringBundler(3);
4494    
4495                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4496    
4497                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4498    
4499                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4500    
4501                            String sql = query.toString();
4502    
4503                            Session session = null;
4504    
4505                            try {
4506                                    session = openSession();
4507    
4508                                    Query q = session.createQuery(sql);
4509    
4510                                    QueryPos qPos = QueryPos.getInstance(q);
4511    
4512                                    qPos.add(groupId);
4513    
4514                                    qPos.add(vocabularyId);
4515    
4516                                    count = (Long)q.uniqueResult();
4517    
4518                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4519                            }
4520                            catch (Exception e) {
4521                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4522    
4523                                    throw processException(e);
4524                            }
4525                            finally {
4526                                    closeSession(session);
4527                            }
4528                    }
4529    
4530                    return count.intValue();
4531            }
4532    
4533            /**
4534             * Returns the number of asset categories where groupId = &#63; and vocabularyId = any &#63;.
4535             *
4536             * @param groupId the group ID
4537             * @param vocabularyIds the vocabulary IDs
4538             * @return the number of matching asset categories
4539             * @throws SystemException if a system exception occurred
4540             */
4541            @Override
4542            public int countByG_V(long groupId, long[] vocabularyIds)
4543                    throws SystemException {
4544                    Object[] finderArgs = new Object[] {
4545                                    groupId, StringUtil.merge(vocabularyIds)
4546                            };
4547    
4548                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4549                                    finderArgs, this);
4550    
4551                    if (count == null) {
4552                            StringBundler query = new StringBundler();
4553    
4554                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4555    
4556                            boolean conjunctionable = false;
4557    
4558                            if (conjunctionable) {
4559                                    query.append(WHERE_AND);
4560                            }
4561    
4562                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4563    
4564                            conjunctionable = true;
4565    
4566                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4567                                    if (conjunctionable) {
4568                                            query.append(WHERE_AND);
4569                                    }
4570    
4571                                    query.append(StringPool.OPEN_PARENTHESIS);
4572    
4573                                    for (int i = 0; i < vocabularyIds.length; i++) {
4574                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4575    
4576                                            if ((i + 1) < vocabularyIds.length) {
4577                                                    query.append(WHERE_OR);
4578                                            }
4579                                    }
4580    
4581                                    query.append(StringPool.CLOSE_PARENTHESIS);
4582    
4583                                    conjunctionable = true;
4584                            }
4585    
4586                            String sql = query.toString();
4587    
4588                            Session session = null;
4589    
4590                            try {
4591                                    session = openSession();
4592    
4593                                    Query q = session.createQuery(sql);
4594    
4595                                    QueryPos qPos = QueryPos.getInstance(q);
4596    
4597                                    qPos.add(groupId);
4598    
4599                                    if (vocabularyIds != null) {
4600                                            qPos.add(vocabularyIds);
4601                                    }
4602    
4603                                    count = (Long)q.uniqueResult();
4604    
4605                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4606                                            finderArgs, count);
4607                            }
4608                            catch (Exception e) {
4609                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4610                                            finderArgs);
4611    
4612                                    throw processException(e);
4613                            }
4614                            finally {
4615                                    closeSession(session);
4616                            }
4617                    }
4618    
4619                    return count.intValue();
4620            }
4621    
4622            /**
4623             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
4624             *
4625             * @param groupId the group ID
4626             * @param vocabularyId the vocabulary ID
4627             * @return the number of matching asset categories that the user has permission to view
4628             * @throws SystemException if a system exception occurred
4629             */
4630            @Override
4631            public int filterCountByG_V(long groupId, long vocabularyId)
4632                    throws SystemException {
4633                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4634                            return countByG_V(groupId, vocabularyId);
4635                    }
4636    
4637                    StringBundler query = new StringBundler(3);
4638    
4639                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4640    
4641                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4642    
4643                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4644    
4645                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4646                                    AssetCategory.class.getName(),
4647                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4648    
4649                    Session session = null;
4650    
4651                    try {
4652                            session = openSession();
4653    
4654                            SQLQuery q = session.createSQLQuery(sql);
4655    
4656                            q.addScalar(COUNT_COLUMN_NAME,
4657                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4658    
4659                            QueryPos qPos = QueryPos.getInstance(q);
4660    
4661                            qPos.add(groupId);
4662    
4663                            qPos.add(vocabularyId);
4664    
4665                            Long count = (Long)q.uniqueResult();
4666    
4667                            return count.intValue();
4668                    }
4669                    catch (Exception e) {
4670                            throw processException(e);
4671                    }
4672                    finally {
4673                            closeSession(session);
4674                    }
4675            }
4676    
4677            /**
4678             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4679             *
4680             * @param groupId the group ID
4681             * @param vocabularyIds the vocabulary IDs
4682             * @return the number of matching asset categories that the user has permission to view
4683             * @throws SystemException if a system exception occurred
4684             */
4685            @Override
4686            public int filterCountByG_V(long groupId, long[] vocabularyIds)
4687                    throws SystemException {
4688                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4689                            return countByG_V(groupId, vocabularyIds);
4690                    }
4691    
4692                    StringBundler query = new StringBundler();
4693    
4694                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4695    
4696                    boolean conjunctionable = false;
4697    
4698                    if (conjunctionable) {
4699                            query.append(WHERE_AND);
4700                    }
4701    
4702                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4703    
4704                    conjunctionable = true;
4705    
4706                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4707                            if (conjunctionable) {
4708                                    query.append(WHERE_AND);
4709                            }
4710    
4711                            query.append(StringPool.OPEN_PARENTHESIS);
4712    
4713                            for (int i = 0; i < vocabularyIds.length; i++) {
4714                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4715    
4716                                    if ((i + 1) < vocabularyIds.length) {
4717                                            query.append(WHERE_OR);
4718                                    }
4719                            }
4720    
4721                            query.append(StringPool.CLOSE_PARENTHESIS);
4722    
4723                            conjunctionable = true;
4724                    }
4725    
4726                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4727                                    AssetCategory.class.getName(),
4728                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4729    
4730                    Session session = null;
4731    
4732                    try {
4733                            session = openSession();
4734    
4735                            SQLQuery q = session.createSQLQuery(sql);
4736    
4737                            q.addScalar(COUNT_COLUMN_NAME,
4738                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4739    
4740                            QueryPos qPos = QueryPos.getInstance(q);
4741    
4742                            qPos.add(groupId);
4743    
4744                            if (vocabularyIds != null) {
4745                                    qPos.add(vocabularyIds);
4746                            }
4747    
4748                            Long count = (Long)q.uniqueResult();
4749    
4750                            return count.intValue();
4751                    }
4752                    catch (Exception e) {
4753                            throw processException(e);
4754                    }
4755                    finally {
4756                            closeSession(session);
4757                    }
4758            }
4759    
4760            private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4761            private static final String _FINDER_COLUMN_G_V_GROUPID_5 = "(" +
4762                    removeConjunction(_FINDER_COLUMN_G_V_GROUPID_2) + ")";
4763            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4764            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_5 = "(" +
4765                    removeConjunction(_FINDER_COLUMN_G_V_VOCABULARYID_2) + ")";
4766            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4767                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4768                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4769                            "findByP_N",
4770                            new String[] {
4771                                    Long.class.getName(), String.class.getName(),
4772                                    
4773                            Integer.class.getName(), Integer.class.getName(),
4774                                    OrderByComparator.class.getName()
4775                            });
4776            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4777                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4778                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4779                            "findByP_N",
4780                            new String[] { Long.class.getName(), String.class.getName() },
4781                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4782                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4783            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4784                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4785                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4786                            new String[] { Long.class.getName(), String.class.getName() });
4787    
4788            /**
4789             * Returns all the asset categories where parentCategoryId = &#63; and name = &#63;.
4790             *
4791             * @param parentCategoryId the parent category ID
4792             * @param name the name
4793             * @return the matching asset categories
4794             * @throws SystemException if a system exception occurred
4795             */
4796            @Override
4797            public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4798                    throws SystemException {
4799                    return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4800                            QueryUtil.ALL_POS, null);
4801            }
4802    
4803            /**
4804             * Returns a range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4805             *
4806             * <p>
4807             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4808             * </p>
4809             *
4810             * @param parentCategoryId the parent category ID
4811             * @param name the name
4812             * @param start the lower bound of the range of asset categories
4813             * @param end the upper bound of the range of asset categories (not inclusive)
4814             * @return the range of matching asset categories
4815             * @throws SystemException if a system exception occurred
4816             */
4817            @Override
4818            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4819                    int start, int end) throws SystemException {
4820                    return findByP_N(parentCategoryId, name, start, end, null);
4821            }
4822    
4823            /**
4824             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4825             *
4826             * <p>
4827             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
4828             * </p>
4829             *
4830             * @param parentCategoryId the parent category ID
4831             * @param name the name
4832             * @param start the lower bound of the range of asset categories
4833             * @param end the upper bound of the range of asset categories (not inclusive)
4834             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4835             * @return the ordered range of matching asset categories
4836             * @throws SystemException if a system exception occurred
4837             */
4838            @Override
4839            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4840                    int start, int end, OrderByComparator orderByComparator)
4841                    throws SystemException {
4842                    boolean pagination = true;
4843                    FinderPath finderPath = null;
4844                    Object[] finderArgs = null;
4845    
4846                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4847                                    (orderByComparator == null)) {
4848                            pagination = false;
4849                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4850                            finderArgs = new Object[] { parentCategoryId, name };
4851                    }
4852                    else {
4853                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4854                            finderArgs = new Object[] {
4855                                            parentCategoryId, name,
4856                                            
4857                                            start, end, orderByComparator
4858                                    };
4859                    }
4860    
4861                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4862                                    finderArgs, this);
4863    
4864                    if ((list != null) && !list.isEmpty()) {
4865                            for (AssetCategory assetCategory : list) {
4866                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4867                                                    !Validator.equals(name, assetCategory.getName())) {
4868                                            list = null;
4869    
4870                                            break;
4871                                    }
4872                            }
4873                    }
4874    
4875                    if (list == null) {
4876                            StringBundler query = null;
4877    
4878                            if (orderByComparator != null) {
4879                                    query = new StringBundler(4 +
4880                                                    (orderByComparator.getOrderByFields().length * 3));
4881                            }
4882                            else {
4883                                    query = new StringBundler(4);
4884                            }
4885    
4886                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4887    
4888                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4889    
4890                            boolean bindName = false;
4891    
4892                            if (name == null) {
4893                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
4894                            }
4895                            else if (name.equals(StringPool.BLANK)) {
4896                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
4897                            }
4898                            else {
4899                                    bindName = true;
4900    
4901                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
4902                            }
4903    
4904                            if (orderByComparator != null) {
4905                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4906                                            orderByComparator);
4907                            }
4908                            else
4909                             if (pagination) {
4910                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4911                            }
4912    
4913                            String sql = query.toString();
4914    
4915                            Session session = null;
4916    
4917                            try {
4918                                    session = openSession();
4919    
4920                                    Query q = session.createQuery(sql);
4921    
4922                                    QueryPos qPos = QueryPos.getInstance(q);
4923    
4924                                    qPos.add(parentCategoryId);
4925    
4926                                    if (bindName) {
4927                                            qPos.add(name);
4928                                    }
4929    
4930                                    if (!pagination) {
4931                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4932                                                            start, end, false);
4933    
4934                                            Collections.sort(list);
4935    
4936                                            list = new UnmodifiableList<AssetCategory>(list);
4937                                    }
4938                                    else {
4939                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4940                                                            start, end);
4941                                    }
4942    
4943                                    cacheResult(list);
4944    
4945                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4946                            }
4947                            catch (Exception e) {
4948                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4949    
4950                                    throw processException(e);
4951                            }
4952                            finally {
4953                                    closeSession(session);
4954                            }
4955                    }
4956    
4957                    return list;
4958            }
4959    
4960            /**
4961             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4962             *
4963             * @param parentCategoryId the parent category ID
4964             * @param name the name
4965             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4966             * @return the first matching asset category
4967             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4968             * @throws SystemException if a system exception occurred
4969             */
4970            @Override
4971            public AssetCategory findByP_N_First(long parentCategoryId, String name,
4972                    OrderByComparator orderByComparator)
4973                    throws NoSuchCategoryException, SystemException {
4974                    AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4975                                    orderByComparator);
4976    
4977                    if (assetCategory != null) {
4978                            return assetCategory;
4979                    }
4980    
4981                    StringBundler msg = new StringBundler(6);
4982    
4983                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4984    
4985                    msg.append("parentCategoryId=");
4986                    msg.append(parentCategoryId);
4987    
4988                    msg.append(", name=");
4989                    msg.append(name);
4990    
4991                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4992    
4993                    throw new NoSuchCategoryException(msg.toString());
4994            }
4995    
4996            /**
4997             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4998             *
4999             * @param parentCategoryId the parent category ID
5000             * @param name the name
5001             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5002             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5003             * @throws SystemException if a system exception occurred
5004             */
5005            @Override
5006            public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
5007                    OrderByComparator orderByComparator) throws SystemException {
5008                    List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
5009                                    orderByComparator);
5010    
5011                    if (!list.isEmpty()) {
5012                            return list.get(0);
5013                    }
5014    
5015                    return null;
5016            }
5017    
5018            /**
5019             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5020             *
5021             * @param parentCategoryId the parent category ID
5022             * @param name the name
5023             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5024             * @return the last matching asset category
5025             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5026             * @throws SystemException if a system exception occurred
5027             */
5028            @Override
5029            public AssetCategory findByP_N_Last(long parentCategoryId, String name,
5030                    OrderByComparator orderByComparator)
5031                    throws NoSuchCategoryException, SystemException {
5032                    AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
5033                                    orderByComparator);
5034    
5035                    if (assetCategory != null) {
5036                            return assetCategory;
5037                    }
5038    
5039                    StringBundler msg = new StringBundler(6);
5040    
5041                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5042    
5043                    msg.append("parentCategoryId=");
5044                    msg.append(parentCategoryId);
5045    
5046                    msg.append(", name=");
5047                    msg.append(name);
5048    
5049                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5050    
5051                    throw new NoSuchCategoryException(msg.toString());
5052            }
5053    
5054            /**
5055             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5056             *
5057             * @param parentCategoryId the parent category ID
5058             * @param name the name
5059             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5060             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5061             * @throws SystemException if a system exception occurred
5062             */
5063            @Override
5064            public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
5065                    OrderByComparator orderByComparator) throws SystemException {
5066                    int count = countByP_N(parentCategoryId, name);
5067    
5068                    if (count == 0) {
5069                            return null;
5070                    }
5071    
5072                    List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
5073                                    count, orderByComparator);
5074    
5075                    if (!list.isEmpty()) {
5076                            return list.get(0);
5077                    }
5078    
5079                    return null;
5080            }
5081    
5082            /**
5083             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5084             *
5085             * @param categoryId the primary key of the current asset category
5086             * @param parentCategoryId the parent category ID
5087             * @param name the name
5088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5089             * @return the previous, current, and next asset category
5090             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5091             * @throws SystemException if a system exception occurred
5092             */
5093            @Override
5094            public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
5095                    long parentCategoryId, String name, OrderByComparator orderByComparator)
5096                    throws NoSuchCategoryException, SystemException {
5097                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5098    
5099                    Session session = null;
5100    
5101                    try {
5102                            session = openSession();
5103    
5104                            AssetCategory[] array = new AssetCategoryImpl[3];
5105    
5106                            array[0] = getByP_N_PrevAndNext(session, assetCategory,
5107                                            parentCategoryId, name, orderByComparator, true);
5108    
5109                            array[1] = assetCategory;
5110    
5111                            array[2] = getByP_N_PrevAndNext(session, assetCategory,
5112                                            parentCategoryId, name, orderByComparator, false);
5113    
5114                            return array;
5115                    }
5116                    catch (Exception e) {
5117                            throw processException(e);
5118                    }
5119                    finally {
5120                            closeSession(session);
5121                    }
5122            }
5123    
5124            protected AssetCategory getByP_N_PrevAndNext(Session session,
5125                    AssetCategory assetCategory, long parentCategoryId, String name,
5126                    OrderByComparator orderByComparator, boolean previous) {
5127                    StringBundler query = null;
5128    
5129                    if (orderByComparator != null) {
5130                            query = new StringBundler(6 +
5131                                            (orderByComparator.getOrderByFields().length * 6));
5132                    }
5133                    else {
5134                            query = new StringBundler(3);
5135                    }
5136    
5137                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5138    
5139                    query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5140    
5141                    boolean bindName = false;
5142    
5143                    if (name == null) {
5144                            query.append(_FINDER_COLUMN_P_N_NAME_1);
5145                    }
5146                    else if (name.equals(StringPool.BLANK)) {
5147                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5148                    }
5149                    else {
5150                            bindName = true;
5151    
5152                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5153                    }
5154    
5155                    if (orderByComparator != null) {
5156                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5157    
5158                            if (orderByConditionFields.length > 0) {
5159                                    query.append(WHERE_AND);
5160                            }
5161    
5162                            for (int i = 0; i < orderByConditionFields.length; i++) {
5163                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5164                                    query.append(orderByConditionFields[i]);
5165    
5166                                    if ((i + 1) < orderByConditionFields.length) {
5167                                            if (orderByComparator.isAscending() ^ previous) {
5168                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5169                                            }
5170                                            else {
5171                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5172                                            }
5173                                    }
5174                                    else {
5175                                            if (orderByComparator.isAscending() ^ previous) {
5176                                                    query.append(WHERE_GREATER_THAN);
5177                                            }
5178                                            else {
5179                                                    query.append(WHERE_LESSER_THAN);
5180                                            }
5181                                    }
5182                            }
5183    
5184                            query.append(ORDER_BY_CLAUSE);
5185    
5186                            String[] orderByFields = orderByComparator.getOrderByFields();
5187    
5188                            for (int i = 0; i < orderByFields.length; i++) {
5189                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5190                                    query.append(orderByFields[i]);
5191    
5192                                    if ((i + 1) < orderByFields.length) {
5193                                            if (orderByComparator.isAscending() ^ previous) {
5194                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5195                                            }
5196                                            else {
5197                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5198                                            }
5199                                    }
5200                                    else {
5201                                            if (orderByComparator.isAscending() ^ previous) {
5202                                                    query.append(ORDER_BY_ASC);
5203                                            }
5204                                            else {
5205                                                    query.append(ORDER_BY_DESC);
5206                                            }
5207                                    }
5208                            }
5209                    }
5210                    else {
5211                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5212                    }
5213    
5214                    String sql = query.toString();
5215    
5216                    Query q = session.createQuery(sql);
5217    
5218                    q.setFirstResult(0);
5219                    q.setMaxResults(2);
5220    
5221                    QueryPos qPos = QueryPos.getInstance(q);
5222    
5223                    qPos.add(parentCategoryId);
5224    
5225                    if (bindName) {
5226                            qPos.add(name);
5227                    }
5228    
5229                    if (orderByComparator != null) {
5230                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5231    
5232                            for (Object value : values) {
5233                                    qPos.add(value);
5234                            }
5235                    }
5236    
5237                    List<AssetCategory> list = q.list();
5238    
5239                    if (list.size() == 2) {
5240                            return list.get(1);
5241                    }
5242                    else {
5243                            return null;
5244                    }
5245            }
5246    
5247            /**
5248             * Removes all the asset categories where parentCategoryId = &#63; and name = &#63; from the database.
5249             *
5250             * @param parentCategoryId the parent category ID
5251             * @param name the name
5252             * @throws SystemException if a system exception occurred
5253             */
5254            @Override
5255            public void removeByP_N(long parentCategoryId, String name)
5256                    throws SystemException {
5257                    for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5258                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5259                            remove(assetCategory);
5260                    }
5261            }
5262    
5263            /**
5264             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63;.
5265             *
5266             * @param parentCategoryId the parent category ID
5267             * @param name the name
5268             * @return the number of matching asset categories
5269             * @throws SystemException if a system exception occurred
5270             */
5271            @Override
5272            public int countByP_N(long parentCategoryId, String name)
5273                    throws SystemException {
5274                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5275    
5276                    Object[] finderArgs = new Object[] { parentCategoryId, name };
5277    
5278                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5279                                    this);
5280    
5281                    if (count == null) {
5282                            StringBundler query = new StringBundler(3);
5283    
5284                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5285    
5286                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5287    
5288                            boolean bindName = false;
5289    
5290                            if (name == null) {
5291                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5292                            }
5293                            else if (name.equals(StringPool.BLANK)) {
5294                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
5295                            }
5296                            else {
5297                                    bindName = true;
5298    
5299                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
5300                            }
5301    
5302                            String sql = query.toString();
5303    
5304                            Session session = null;
5305    
5306                            try {
5307                                    session = openSession();
5308    
5309                                    Query q = session.createQuery(sql);
5310    
5311                                    QueryPos qPos = QueryPos.getInstance(q);
5312    
5313                                    qPos.add(parentCategoryId);
5314    
5315                                    if (bindName) {
5316                                            qPos.add(name);
5317                                    }
5318    
5319                                    count = (Long)q.uniqueResult();
5320    
5321                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5322                            }
5323                            catch (Exception e) {
5324                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5325    
5326                                    throw processException(e);
5327                            }
5328                            finally {
5329                                    closeSession(session);
5330                            }
5331                    }
5332    
5333                    return count.intValue();
5334            }
5335    
5336            private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5337            private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5338            private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5339            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5340            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5341                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5342                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5343                            "findByP_V",
5344                            new String[] {
5345                                    Long.class.getName(), Long.class.getName(),
5346                                    
5347                            Integer.class.getName(), Integer.class.getName(),
5348                                    OrderByComparator.class.getName()
5349                            });
5350            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5351                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5352                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5353                            "findByP_V",
5354                            new String[] { Long.class.getName(), Long.class.getName() },
5355                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5356                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5357                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5358            public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5359                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5360                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5361                            new String[] { Long.class.getName(), Long.class.getName() });
5362    
5363            /**
5364             * Returns all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5365             *
5366             * @param parentCategoryId the parent category ID
5367             * @param vocabularyId the vocabulary ID
5368             * @return the matching asset categories
5369             * @throws SystemException if a system exception occurred
5370             */
5371            @Override
5372            public List<AssetCategory> findByP_V(long parentCategoryId,
5373                    long vocabularyId) throws SystemException {
5374                    return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5375                            QueryUtil.ALL_POS, null);
5376            }
5377    
5378            /**
5379             * Returns a range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5380             *
5381             * <p>
5382             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5383             * </p>
5384             *
5385             * @param parentCategoryId the parent category ID
5386             * @param vocabularyId the vocabulary ID
5387             * @param start the lower bound of the range of asset categories
5388             * @param end the upper bound of the range of asset categories (not inclusive)
5389             * @return the range of matching asset categories
5390             * @throws SystemException if a system exception occurred
5391             */
5392            @Override
5393            public List<AssetCategory> findByP_V(long parentCategoryId,
5394                    long vocabularyId, int start, int end) throws SystemException {
5395                    return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5396            }
5397    
5398            /**
5399             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5400             *
5401             * <p>
5402             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5403             * </p>
5404             *
5405             * @param parentCategoryId the parent category ID
5406             * @param vocabularyId the vocabulary ID
5407             * @param start the lower bound of the range of asset categories
5408             * @param end the upper bound of the range of asset categories (not inclusive)
5409             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5410             * @return the ordered range of matching asset categories
5411             * @throws SystemException if a system exception occurred
5412             */
5413            @Override
5414            public List<AssetCategory> findByP_V(long parentCategoryId,
5415                    long vocabularyId, int start, int end,
5416                    OrderByComparator orderByComparator) throws SystemException {
5417                    boolean pagination = true;
5418                    FinderPath finderPath = null;
5419                    Object[] finderArgs = null;
5420    
5421                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5422                                    (orderByComparator == null)) {
5423                            pagination = false;
5424                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5425                            finderArgs = new Object[] { parentCategoryId, vocabularyId };
5426                    }
5427                    else {
5428                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5429                            finderArgs = new Object[] {
5430                                            parentCategoryId, vocabularyId,
5431                                            
5432                                            start, end, orderByComparator
5433                                    };
5434                    }
5435    
5436                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5437                                    finderArgs, this);
5438    
5439                    if ((list != null) && !list.isEmpty()) {
5440                            for (AssetCategory assetCategory : list) {
5441                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5442                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5443                                            list = null;
5444    
5445                                            break;
5446                                    }
5447                            }
5448                    }
5449    
5450                    if (list == null) {
5451                            StringBundler query = null;
5452    
5453                            if (orderByComparator != null) {
5454                                    query = new StringBundler(4 +
5455                                                    (orderByComparator.getOrderByFields().length * 3));
5456                            }
5457                            else {
5458                                    query = new StringBundler(4);
5459                            }
5460    
5461                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5462    
5463                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5464    
5465                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5466    
5467                            if (orderByComparator != null) {
5468                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5469                                            orderByComparator);
5470                            }
5471                            else
5472                             if (pagination) {
5473                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5474                            }
5475    
5476                            String sql = query.toString();
5477    
5478                            Session session = null;
5479    
5480                            try {
5481                                    session = openSession();
5482    
5483                                    Query q = session.createQuery(sql);
5484    
5485                                    QueryPos qPos = QueryPos.getInstance(q);
5486    
5487                                    qPos.add(parentCategoryId);
5488    
5489                                    qPos.add(vocabularyId);
5490    
5491                                    if (!pagination) {
5492                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5493                                                            start, end, false);
5494    
5495                                            Collections.sort(list);
5496    
5497                                            list = new UnmodifiableList<AssetCategory>(list);
5498                                    }
5499                                    else {
5500                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5501                                                            start, end);
5502                                    }
5503    
5504                                    cacheResult(list);
5505    
5506                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5507                            }
5508                            catch (Exception e) {
5509                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5510    
5511                                    throw processException(e);
5512                            }
5513                            finally {
5514                                    closeSession(session);
5515                            }
5516                    }
5517    
5518                    return list;
5519            }
5520    
5521            /**
5522             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5523             *
5524             * @param parentCategoryId the parent category ID
5525             * @param vocabularyId the vocabulary ID
5526             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5527             * @return the first matching asset category
5528             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5529             * @throws SystemException if a system exception occurred
5530             */
5531            @Override
5532            public AssetCategory findByP_V_First(long parentCategoryId,
5533                    long vocabularyId, OrderByComparator orderByComparator)
5534                    throws NoSuchCategoryException, SystemException {
5535                    AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5536                                    vocabularyId, orderByComparator);
5537    
5538                    if (assetCategory != null) {
5539                            return assetCategory;
5540                    }
5541    
5542                    StringBundler msg = new StringBundler(6);
5543    
5544                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5545    
5546                    msg.append("parentCategoryId=");
5547                    msg.append(parentCategoryId);
5548    
5549                    msg.append(", vocabularyId=");
5550                    msg.append(vocabularyId);
5551    
5552                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5553    
5554                    throw new NoSuchCategoryException(msg.toString());
5555            }
5556    
5557            /**
5558             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5559             *
5560             * @param parentCategoryId the parent category ID
5561             * @param vocabularyId the vocabulary ID
5562             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5563             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5564             * @throws SystemException if a system exception occurred
5565             */
5566            @Override
5567            public AssetCategory fetchByP_V_First(long parentCategoryId,
5568                    long vocabularyId, OrderByComparator orderByComparator)
5569                    throws SystemException {
5570                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5571                                    1, orderByComparator);
5572    
5573                    if (!list.isEmpty()) {
5574                            return list.get(0);
5575                    }
5576    
5577                    return null;
5578            }
5579    
5580            /**
5581             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5582             *
5583             * @param parentCategoryId the parent category ID
5584             * @param vocabularyId the vocabulary ID
5585             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5586             * @return the last matching asset category
5587             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5588             * @throws SystemException if a system exception occurred
5589             */
5590            @Override
5591            public AssetCategory findByP_V_Last(long parentCategoryId,
5592                    long vocabularyId, OrderByComparator orderByComparator)
5593                    throws NoSuchCategoryException, SystemException {
5594                    AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5595                                    vocabularyId, orderByComparator);
5596    
5597                    if (assetCategory != null) {
5598                            return assetCategory;
5599                    }
5600    
5601                    StringBundler msg = new StringBundler(6);
5602    
5603                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5604    
5605                    msg.append("parentCategoryId=");
5606                    msg.append(parentCategoryId);
5607    
5608                    msg.append(", vocabularyId=");
5609                    msg.append(vocabularyId);
5610    
5611                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5612    
5613                    throw new NoSuchCategoryException(msg.toString());
5614            }
5615    
5616            /**
5617             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5618             *
5619             * @param parentCategoryId the parent category ID
5620             * @param vocabularyId the vocabulary ID
5621             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5622             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5623             * @throws SystemException if a system exception occurred
5624             */
5625            @Override
5626            public AssetCategory fetchByP_V_Last(long parentCategoryId,
5627                    long vocabularyId, OrderByComparator orderByComparator)
5628                    throws SystemException {
5629                    int count = countByP_V(parentCategoryId, vocabularyId);
5630    
5631                    if (count == 0) {
5632                            return null;
5633                    }
5634    
5635                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5636                                    count - 1, count, orderByComparator);
5637    
5638                    if (!list.isEmpty()) {
5639                            return list.get(0);
5640                    }
5641    
5642                    return null;
5643            }
5644    
5645            /**
5646             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5647             *
5648             * @param categoryId the primary key of the current asset category
5649             * @param parentCategoryId the parent category ID
5650             * @param vocabularyId the vocabulary ID
5651             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5652             * @return the previous, current, and next asset category
5653             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5654             * @throws SystemException if a system exception occurred
5655             */
5656            @Override
5657            public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5658                    long parentCategoryId, long vocabularyId,
5659                    OrderByComparator orderByComparator)
5660                    throws NoSuchCategoryException, SystemException {
5661                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5662    
5663                    Session session = null;
5664    
5665                    try {
5666                            session = openSession();
5667    
5668                            AssetCategory[] array = new AssetCategoryImpl[3];
5669    
5670                            array[0] = getByP_V_PrevAndNext(session, assetCategory,
5671                                            parentCategoryId, vocabularyId, orderByComparator, true);
5672    
5673                            array[1] = assetCategory;
5674    
5675                            array[2] = getByP_V_PrevAndNext(session, assetCategory,
5676                                            parentCategoryId, vocabularyId, orderByComparator, false);
5677    
5678                            return array;
5679                    }
5680                    catch (Exception e) {
5681                            throw processException(e);
5682                    }
5683                    finally {
5684                            closeSession(session);
5685                    }
5686            }
5687    
5688            protected AssetCategory getByP_V_PrevAndNext(Session session,
5689                    AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5690                    OrderByComparator orderByComparator, boolean previous) {
5691                    StringBundler query = null;
5692    
5693                    if (orderByComparator != null) {
5694                            query = new StringBundler(6 +
5695                                            (orderByComparator.getOrderByFields().length * 6));
5696                    }
5697                    else {
5698                            query = new StringBundler(3);
5699                    }
5700    
5701                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5702    
5703                    query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5704    
5705                    query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5706    
5707                    if (orderByComparator != null) {
5708                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5709    
5710                            if (orderByConditionFields.length > 0) {
5711                                    query.append(WHERE_AND);
5712                            }
5713    
5714                            for (int i = 0; i < orderByConditionFields.length; i++) {
5715                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5716                                    query.append(orderByConditionFields[i]);
5717    
5718                                    if ((i + 1) < orderByConditionFields.length) {
5719                                            if (orderByComparator.isAscending() ^ previous) {
5720                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5721                                            }
5722                                            else {
5723                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5724                                            }
5725                                    }
5726                                    else {
5727                                            if (orderByComparator.isAscending() ^ previous) {
5728                                                    query.append(WHERE_GREATER_THAN);
5729                                            }
5730                                            else {
5731                                                    query.append(WHERE_LESSER_THAN);
5732                                            }
5733                                    }
5734                            }
5735    
5736                            query.append(ORDER_BY_CLAUSE);
5737    
5738                            String[] orderByFields = orderByComparator.getOrderByFields();
5739    
5740                            for (int i = 0; i < orderByFields.length; i++) {
5741                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5742                                    query.append(orderByFields[i]);
5743    
5744                                    if ((i + 1) < orderByFields.length) {
5745                                            if (orderByComparator.isAscending() ^ previous) {
5746                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5747                                            }
5748                                            else {
5749                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5750                                            }
5751                                    }
5752                                    else {
5753                                            if (orderByComparator.isAscending() ^ previous) {
5754                                                    query.append(ORDER_BY_ASC);
5755                                            }
5756                                            else {
5757                                                    query.append(ORDER_BY_DESC);
5758                                            }
5759                                    }
5760                            }
5761                    }
5762                    else {
5763                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5764                    }
5765    
5766                    String sql = query.toString();
5767    
5768                    Query q = session.createQuery(sql);
5769    
5770                    q.setFirstResult(0);
5771                    q.setMaxResults(2);
5772    
5773                    QueryPos qPos = QueryPos.getInstance(q);
5774    
5775                    qPos.add(parentCategoryId);
5776    
5777                    qPos.add(vocabularyId);
5778    
5779                    if (orderByComparator != null) {
5780                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5781    
5782                            for (Object value : values) {
5783                                    qPos.add(value);
5784                            }
5785                    }
5786    
5787                    List<AssetCategory> list = q.list();
5788    
5789                    if (list.size() == 2) {
5790                            return list.get(1);
5791                    }
5792                    else {
5793                            return null;
5794                    }
5795            }
5796    
5797            /**
5798             * Removes all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63; from the database.
5799             *
5800             * @param parentCategoryId the parent category ID
5801             * @param vocabularyId the vocabulary ID
5802             * @throws SystemException if a system exception occurred
5803             */
5804            @Override
5805            public void removeByP_V(long parentCategoryId, long vocabularyId)
5806                    throws SystemException {
5807                    for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5808                                    vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5809                            remove(assetCategory);
5810                    }
5811            }
5812    
5813            /**
5814             * Returns the number of asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5815             *
5816             * @param parentCategoryId the parent category ID
5817             * @param vocabularyId the vocabulary ID
5818             * @return the number of matching asset categories
5819             * @throws SystemException if a system exception occurred
5820             */
5821            @Override
5822            public int countByP_V(long parentCategoryId, long vocabularyId)
5823                    throws SystemException {
5824                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5825    
5826                    Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5827    
5828                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5829                                    this);
5830    
5831                    if (count == null) {
5832                            StringBundler query = new StringBundler(3);
5833    
5834                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5835    
5836                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5837    
5838                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5839    
5840                            String sql = query.toString();
5841    
5842                            Session session = null;
5843    
5844                            try {
5845                                    session = openSession();
5846    
5847                                    Query q = session.createQuery(sql);
5848    
5849                                    QueryPos qPos = QueryPos.getInstance(q);
5850    
5851                                    qPos.add(parentCategoryId);
5852    
5853                                    qPos.add(vocabularyId);
5854    
5855                                    count = (Long)q.uniqueResult();
5856    
5857                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5858                            }
5859                            catch (Exception e) {
5860                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5861    
5862                                    throw processException(e);
5863                            }
5864                            finally {
5865                                    closeSession(session);
5866                            }
5867                    }
5868    
5869                    return count.intValue();
5870            }
5871    
5872            private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5873            private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5874            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5875                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5876                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5877                            "findByN_V",
5878                            new String[] {
5879                                    String.class.getName(), Long.class.getName(),
5880                                    
5881                            Integer.class.getName(), Integer.class.getName(),
5882                                    OrderByComparator.class.getName()
5883                            });
5884            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5885                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5886                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5887                            "findByN_V",
5888                            new String[] { String.class.getName(), Long.class.getName() },
5889                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5890                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5891            public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5892                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5893                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
5894                            new String[] { String.class.getName(), Long.class.getName() });
5895    
5896            /**
5897             * Returns all the asset categories where name = &#63; and vocabularyId = &#63;.
5898             *
5899             * @param name the name
5900             * @param vocabularyId the vocabulary ID
5901             * @return the matching asset categories
5902             * @throws SystemException if a system exception occurred
5903             */
5904            @Override
5905            public List<AssetCategory> findByN_V(String name, long vocabularyId)
5906                    throws SystemException {
5907                    return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5908                            QueryUtil.ALL_POS, null);
5909            }
5910    
5911            /**
5912             * Returns a range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5913             *
5914             * <p>
5915             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5916             * </p>
5917             *
5918             * @param name the name
5919             * @param vocabularyId the vocabulary ID
5920             * @param start the lower bound of the range of asset categories
5921             * @param end the upper bound of the range of asset categories (not inclusive)
5922             * @return the range of matching asset categories
5923             * @throws SystemException if a system exception occurred
5924             */
5925            @Override
5926            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5927                    int start, int end) throws SystemException {
5928                    return findByN_V(name, vocabularyId, start, end, null);
5929            }
5930    
5931            /**
5932             * Returns an ordered range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5933             *
5934             * <p>
5935             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
5936             * </p>
5937             *
5938             * @param name the name
5939             * @param vocabularyId the vocabulary ID
5940             * @param start the lower bound of the range of asset categories
5941             * @param end the upper bound of the range of asset categories (not inclusive)
5942             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5943             * @return the ordered range of matching asset categories
5944             * @throws SystemException if a system exception occurred
5945             */
5946            @Override
5947            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5948                    int start, int end, OrderByComparator orderByComparator)
5949                    throws SystemException {
5950                    boolean pagination = true;
5951                    FinderPath finderPath = null;
5952                    Object[] finderArgs = null;
5953    
5954                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5955                                    (orderByComparator == null)) {
5956                            pagination = false;
5957                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5958                            finderArgs = new Object[] { name, vocabularyId };
5959                    }
5960                    else {
5961                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5962                            finderArgs = new Object[] {
5963                                            name, vocabularyId,
5964                                            
5965                                            start, end, orderByComparator
5966                                    };
5967                    }
5968    
5969                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5970                                    finderArgs, this);
5971    
5972                    if ((list != null) && !list.isEmpty()) {
5973                            for (AssetCategory assetCategory : list) {
5974                                    if (!Validator.equals(name, assetCategory.getName()) ||
5975                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5976                                            list = null;
5977    
5978                                            break;
5979                                    }
5980                            }
5981                    }
5982    
5983                    if (list == null) {
5984                            StringBundler query = null;
5985    
5986                            if (orderByComparator != null) {
5987                                    query = new StringBundler(4 +
5988                                                    (orderByComparator.getOrderByFields().length * 3));
5989                            }
5990                            else {
5991                                    query = new StringBundler(4);
5992                            }
5993    
5994                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5995    
5996                            boolean bindName = false;
5997    
5998                            if (name == null) {
5999                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
6000                            }
6001                            else if (name.equals(StringPool.BLANK)) {
6002                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
6003                            }
6004                            else {
6005                                    bindName = true;
6006    
6007                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
6008                            }
6009    
6010                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6011    
6012                            if (orderByComparator != null) {
6013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6014                                            orderByComparator);
6015                            }
6016                            else
6017                             if (pagination) {
6018                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6019                            }
6020    
6021                            String sql = query.toString();
6022    
6023                            Session session = null;
6024    
6025                            try {
6026                                    session = openSession();
6027    
6028                                    Query q = session.createQuery(sql);
6029    
6030                                    QueryPos qPos = QueryPos.getInstance(q);
6031    
6032                                    if (bindName) {
6033                                            qPos.add(name);
6034                                    }
6035    
6036                                    qPos.add(vocabularyId);
6037    
6038                                    if (!pagination) {
6039                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6040                                                            start, end, false);
6041    
6042                                            Collections.sort(list);
6043    
6044                                            list = new UnmodifiableList<AssetCategory>(list);
6045                                    }
6046                                    else {
6047                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6048                                                            start, end);
6049                                    }
6050    
6051                                    cacheResult(list);
6052    
6053                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6054                            }
6055                            catch (Exception e) {
6056                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6057    
6058                                    throw processException(e);
6059                            }
6060                            finally {
6061                                    closeSession(session);
6062                            }
6063                    }
6064    
6065                    return list;
6066            }
6067    
6068            /**
6069             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6070             *
6071             * @param name the name
6072             * @param vocabularyId the vocabulary ID
6073             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6074             * @return the first matching asset category
6075             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6076             * @throws SystemException if a system exception occurred
6077             */
6078            @Override
6079            public AssetCategory findByN_V_First(String name, long vocabularyId,
6080                    OrderByComparator orderByComparator)
6081                    throws NoSuchCategoryException, SystemException {
6082                    AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
6083                                    orderByComparator);
6084    
6085                    if (assetCategory != null) {
6086                            return assetCategory;
6087                    }
6088    
6089                    StringBundler msg = new StringBundler(6);
6090    
6091                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6092    
6093                    msg.append("name=");
6094                    msg.append(name);
6095    
6096                    msg.append(", vocabularyId=");
6097                    msg.append(vocabularyId);
6098    
6099                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6100    
6101                    throw new NoSuchCategoryException(msg.toString());
6102            }
6103    
6104            /**
6105             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6106             *
6107             * @param name the name
6108             * @param vocabularyId the vocabulary ID
6109             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6110             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
6111             * @throws SystemException if a system exception occurred
6112             */
6113            @Override
6114            public AssetCategory fetchByN_V_First(String name, long vocabularyId,
6115                    OrderByComparator orderByComparator) throws SystemException {
6116                    List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
6117                                    orderByComparator);
6118    
6119                    if (!list.isEmpty()) {
6120                            return list.get(0);
6121                    }
6122    
6123                    return null;
6124            }
6125    
6126            /**
6127             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6128             *
6129             * @param name the name
6130             * @param vocabularyId the vocabulary ID
6131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6132             * @return the last matching asset category
6133             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6134             * @throws SystemException if a system exception occurred
6135             */
6136            @Override
6137            public AssetCategory findByN_V_Last(String name, long vocabularyId,
6138                    OrderByComparator orderByComparator)
6139                    throws NoSuchCategoryException, SystemException {
6140                    AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
6141                                    orderByComparator);
6142    
6143                    if (assetCategory != null) {
6144                            return assetCategory;
6145                    }
6146    
6147                    StringBundler msg = new StringBundler(6);
6148    
6149                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6150    
6151                    msg.append("name=");
6152                    msg.append(name);
6153    
6154                    msg.append(", vocabularyId=");
6155                    msg.append(vocabularyId);
6156    
6157                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6158    
6159                    throw new NoSuchCategoryException(msg.toString());
6160            }
6161    
6162            /**
6163             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6164             *
6165             * @param name the name
6166             * @param vocabularyId the vocabulary ID
6167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6168             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
6169             * @throws SystemException if a system exception occurred
6170             */
6171            @Override
6172            public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6173                    OrderByComparator orderByComparator) throws SystemException {
6174                    int count = countByN_V(name, vocabularyId);
6175    
6176                    if (count == 0) {
6177                            return null;
6178                    }
6179    
6180                    List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6181                                    count, orderByComparator);
6182    
6183                    if (!list.isEmpty()) {
6184                            return list.get(0);
6185                    }
6186    
6187                    return null;
6188            }
6189    
6190            /**
6191             * Returns the asset categories before and after the current asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6192             *
6193             * @param categoryId the primary key of the current asset category
6194             * @param name the name
6195             * @param vocabularyId the vocabulary ID
6196             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6197             * @return the previous, current, and next asset category
6198             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6199             * @throws SystemException if a system exception occurred
6200             */
6201            @Override
6202            public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6203                    long vocabularyId, OrderByComparator orderByComparator)
6204                    throws NoSuchCategoryException, SystemException {
6205                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6206    
6207                    Session session = null;
6208    
6209                    try {
6210                            session = openSession();
6211    
6212                            AssetCategory[] array = new AssetCategoryImpl[3];
6213    
6214                            array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6215                                            vocabularyId, orderByComparator, true);
6216    
6217                            array[1] = assetCategory;
6218    
6219                            array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6220                                            vocabularyId, orderByComparator, false);
6221    
6222                            return array;
6223                    }
6224                    catch (Exception e) {
6225                            throw processException(e);
6226                    }
6227                    finally {
6228                            closeSession(session);
6229                    }
6230            }
6231    
6232            protected AssetCategory getByN_V_PrevAndNext(Session session,
6233                    AssetCategory assetCategory, String name, long vocabularyId,
6234                    OrderByComparator orderByComparator, boolean previous) {
6235                    StringBundler query = null;
6236    
6237                    if (orderByComparator != null) {
6238                            query = new StringBundler(6 +
6239                                            (orderByComparator.getOrderByFields().length * 6));
6240                    }
6241                    else {
6242                            query = new StringBundler(3);
6243                    }
6244    
6245                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6246    
6247                    boolean bindName = false;
6248    
6249                    if (name == null) {
6250                            query.append(_FINDER_COLUMN_N_V_NAME_1);
6251                    }
6252                    else if (name.equals(StringPool.BLANK)) {
6253                            query.append(_FINDER_COLUMN_N_V_NAME_3);
6254                    }
6255                    else {
6256                            bindName = true;
6257    
6258                            query.append(_FINDER_COLUMN_N_V_NAME_2);
6259                    }
6260    
6261                    query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6262    
6263                    if (orderByComparator != null) {
6264                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6265    
6266                            if (orderByConditionFields.length > 0) {
6267                                    query.append(WHERE_AND);
6268                            }
6269    
6270                            for (int i = 0; i < orderByConditionFields.length; i++) {
6271                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6272                                    query.append(orderByConditionFields[i]);
6273    
6274                                    if ((i + 1) < orderByConditionFields.length) {
6275                                            if (orderByComparator.isAscending() ^ previous) {
6276                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6277                                            }
6278                                            else {
6279                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6280                                            }
6281                                    }
6282                                    else {
6283                                            if (orderByComparator.isAscending() ^ previous) {
6284                                                    query.append(WHERE_GREATER_THAN);
6285                                            }
6286                                            else {
6287                                                    query.append(WHERE_LESSER_THAN);
6288                                            }
6289                                    }
6290                            }
6291    
6292                            query.append(ORDER_BY_CLAUSE);
6293    
6294                            String[] orderByFields = orderByComparator.getOrderByFields();
6295    
6296                            for (int i = 0; i < orderByFields.length; i++) {
6297                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6298                                    query.append(orderByFields[i]);
6299    
6300                                    if ((i + 1) < orderByFields.length) {
6301                                            if (orderByComparator.isAscending() ^ previous) {
6302                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6303                                            }
6304                                            else {
6305                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6306                                            }
6307                                    }
6308                                    else {
6309                                            if (orderByComparator.isAscending() ^ previous) {
6310                                                    query.append(ORDER_BY_ASC);
6311                                            }
6312                                            else {
6313                                                    query.append(ORDER_BY_DESC);
6314                                            }
6315                                    }
6316                            }
6317                    }
6318                    else {
6319                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6320                    }
6321    
6322                    String sql = query.toString();
6323    
6324                    Query q = session.createQuery(sql);
6325    
6326                    q.setFirstResult(0);
6327                    q.setMaxResults(2);
6328    
6329                    QueryPos qPos = QueryPos.getInstance(q);
6330    
6331                    if (bindName) {
6332                            qPos.add(name);
6333                    }
6334    
6335                    qPos.add(vocabularyId);
6336    
6337                    if (orderByComparator != null) {
6338                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6339    
6340                            for (Object value : values) {
6341                                    qPos.add(value);
6342                            }
6343                    }
6344    
6345                    List<AssetCategory> list = q.list();
6346    
6347                    if (list.size() == 2) {
6348                            return list.get(1);
6349                    }
6350                    else {
6351                            return null;
6352                    }
6353            }
6354    
6355            /**
6356             * Removes all the asset categories where name = &#63; and vocabularyId = &#63; from the database.
6357             *
6358             * @param name the name
6359             * @param vocabularyId the vocabulary ID
6360             * @throws SystemException if a system exception occurred
6361             */
6362            @Override
6363            public void removeByN_V(String name, long vocabularyId)
6364                    throws SystemException {
6365                    for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6366                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6367                            remove(assetCategory);
6368                    }
6369            }
6370    
6371            /**
6372             * Returns the number of asset categories where name = &#63; and vocabularyId = &#63;.
6373             *
6374             * @param name the name
6375             * @param vocabularyId the vocabulary ID
6376             * @return the number of matching asset categories
6377             * @throws SystemException if a system exception occurred
6378             */
6379            @Override
6380            public int countByN_V(String name, long vocabularyId)
6381                    throws SystemException {
6382                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6383    
6384                    Object[] finderArgs = new Object[] { name, vocabularyId };
6385    
6386                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6387                                    this);
6388    
6389                    if (count == null) {
6390                            StringBundler query = new StringBundler(3);
6391    
6392                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6393    
6394                            boolean bindName = false;
6395    
6396                            if (name == null) {
6397                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
6398                            }
6399                            else if (name.equals(StringPool.BLANK)) {
6400                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
6401                            }
6402                            else {
6403                                    bindName = true;
6404    
6405                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
6406                            }
6407    
6408                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6409    
6410                            String sql = query.toString();
6411    
6412                            Session session = null;
6413    
6414                            try {
6415                                    session = openSession();
6416    
6417                                    Query q = session.createQuery(sql);
6418    
6419                                    QueryPos qPos = QueryPos.getInstance(q);
6420    
6421                                    if (bindName) {
6422                                            qPos.add(name);
6423                                    }
6424    
6425                                    qPos.add(vocabularyId);
6426    
6427                                    count = (Long)q.uniqueResult();
6428    
6429                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6430                            }
6431                            catch (Exception e) {
6432                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6433    
6434                                    throw processException(e);
6435                            }
6436                            finally {
6437                                    closeSession(session);
6438                            }
6439                    }
6440    
6441                    return count.intValue();
6442            }
6443    
6444            private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6445            private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6446            private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6447            private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6448            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6449                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6450                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6451                            "findByG_P_V",
6452                            new String[] {
6453                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6454                                    
6455                            Integer.class.getName(), Integer.class.getName(),
6456                                    OrderByComparator.class.getName()
6457                            });
6458            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6459                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6460                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6461                            "findByG_P_V",
6462                            new String[] {
6463                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6464                            },
6465                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6466                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6467                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6468                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6469            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6470                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6471                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6472                            new String[] {
6473                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6474                            });
6475    
6476            /**
6477             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6478             *
6479             * @param groupId the group ID
6480             * @param parentCategoryId the parent category ID
6481             * @param vocabularyId the vocabulary ID
6482             * @return the matching asset categories
6483             * @throws SystemException if a system exception occurred
6484             */
6485            @Override
6486            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6487                    long vocabularyId) throws SystemException {
6488                    return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6489                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6490            }
6491    
6492            /**
6493             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6494             *
6495             * <p>
6496             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6497             * </p>
6498             *
6499             * @param groupId the group ID
6500             * @param parentCategoryId the parent category ID
6501             * @param vocabularyId the vocabulary ID
6502             * @param start the lower bound of the range of asset categories
6503             * @param end the upper bound of the range of asset categories (not inclusive)
6504             * @return the range of matching asset categories
6505             * @throws SystemException if a system exception occurred
6506             */
6507            @Override
6508            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6509                    long vocabularyId, int start, int end) throws SystemException {
6510                    return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6511                            null);
6512            }
6513    
6514            /**
6515             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6516             *
6517             * <p>
6518             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6519             * </p>
6520             *
6521             * @param groupId the group ID
6522             * @param parentCategoryId the parent category ID
6523             * @param vocabularyId the vocabulary ID
6524             * @param start the lower bound of the range of asset categories
6525             * @param end the upper bound of the range of asset categories (not inclusive)
6526             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6527             * @return the ordered range of matching asset categories
6528             * @throws SystemException if a system exception occurred
6529             */
6530            @Override
6531            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6532                    long vocabularyId, int start, int end,
6533                    OrderByComparator orderByComparator) throws SystemException {
6534                    boolean pagination = true;
6535                    FinderPath finderPath = null;
6536                    Object[] finderArgs = null;
6537    
6538                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6539                                    (orderByComparator == null)) {
6540                            pagination = false;
6541                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6542                            finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6543                    }
6544                    else {
6545                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6546                            finderArgs = new Object[] {
6547                                            groupId, parentCategoryId, vocabularyId,
6548                                            
6549                                            start, end, orderByComparator
6550                                    };
6551                    }
6552    
6553                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6554                                    finderArgs, this);
6555    
6556                    if ((list != null) && !list.isEmpty()) {
6557                            for (AssetCategory assetCategory : list) {
6558                                    if ((groupId != assetCategory.getGroupId()) ||
6559                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
6560                                                    (vocabularyId != assetCategory.getVocabularyId())) {
6561                                            list = null;
6562    
6563                                            break;
6564                                    }
6565                            }
6566                    }
6567    
6568                    if (list == null) {
6569                            StringBundler query = null;
6570    
6571                            if (orderByComparator != null) {
6572                                    query = new StringBundler(5 +
6573                                                    (orderByComparator.getOrderByFields().length * 3));
6574                            }
6575                            else {
6576                                    query = new StringBundler(5);
6577                            }
6578    
6579                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6580    
6581                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6582    
6583                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6584    
6585                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6586    
6587                            if (orderByComparator != null) {
6588                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6589                                            orderByComparator);
6590                            }
6591                            else
6592                             if (pagination) {
6593                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6594                            }
6595    
6596                            String sql = query.toString();
6597    
6598                            Session session = null;
6599    
6600                            try {
6601                                    session = openSession();
6602    
6603                                    Query q = session.createQuery(sql);
6604    
6605                                    QueryPos qPos = QueryPos.getInstance(q);
6606    
6607                                    qPos.add(groupId);
6608    
6609                                    qPos.add(parentCategoryId);
6610    
6611                                    qPos.add(vocabularyId);
6612    
6613                                    if (!pagination) {
6614                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6615                                                            start, end, false);
6616    
6617                                            Collections.sort(list);
6618    
6619                                            list = new UnmodifiableList<AssetCategory>(list);
6620                                    }
6621                                    else {
6622                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6623                                                            start, end);
6624                                    }
6625    
6626                                    cacheResult(list);
6627    
6628                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6629                            }
6630                            catch (Exception e) {
6631                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6632    
6633                                    throw processException(e);
6634                            }
6635                            finally {
6636                                    closeSession(session);
6637                            }
6638                    }
6639    
6640                    return list;
6641            }
6642    
6643            /**
6644             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6645             *
6646             * @param groupId the group ID
6647             * @param parentCategoryId the parent category ID
6648             * @param vocabularyId the vocabulary ID
6649             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6650             * @return the first matching asset category
6651             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6652             * @throws SystemException if a system exception occurred
6653             */
6654            @Override
6655            public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6656                    long vocabularyId, OrderByComparator orderByComparator)
6657                    throws NoSuchCategoryException, SystemException {
6658                    AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6659                                    parentCategoryId, vocabularyId, orderByComparator);
6660    
6661                    if (assetCategory != null) {
6662                            return assetCategory;
6663                    }
6664    
6665                    StringBundler msg = new StringBundler(8);
6666    
6667                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6668    
6669                    msg.append("groupId=");
6670                    msg.append(groupId);
6671    
6672                    msg.append(", parentCategoryId=");
6673                    msg.append(parentCategoryId);
6674    
6675                    msg.append(", vocabularyId=");
6676                    msg.append(vocabularyId);
6677    
6678                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6679    
6680                    throw new NoSuchCategoryException(msg.toString());
6681            }
6682    
6683            /**
6684             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6685             *
6686             * @param groupId the group ID
6687             * @param parentCategoryId the parent category ID
6688             * @param vocabularyId the vocabulary ID
6689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6690             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
6691             * @throws SystemException if a system exception occurred
6692             */
6693            @Override
6694            public AssetCategory fetchByG_P_V_First(long groupId,
6695                    long parentCategoryId, long vocabularyId,
6696                    OrderByComparator orderByComparator) throws SystemException {
6697                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6698                                    vocabularyId, 0, 1, orderByComparator);
6699    
6700                    if (!list.isEmpty()) {
6701                            return list.get(0);
6702                    }
6703    
6704                    return null;
6705            }
6706    
6707            /**
6708             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6709             *
6710             * @param groupId the group ID
6711             * @param parentCategoryId the parent category ID
6712             * @param vocabularyId the vocabulary ID
6713             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6714             * @return the last matching asset category
6715             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6716             * @throws SystemException if a system exception occurred
6717             */
6718            @Override
6719            public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6720                    long vocabularyId, OrderByComparator orderByComparator)
6721                    throws NoSuchCategoryException, SystemException {
6722                    AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6723                                    parentCategoryId, vocabularyId, orderByComparator);
6724    
6725                    if (assetCategory != null) {
6726                            return assetCategory;
6727                    }
6728    
6729                    StringBundler msg = new StringBundler(8);
6730    
6731                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6732    
6733                    msg.append("groupId=");
6734                    msg.append(groupId);
6735    
6736                    msg.append(", parentCategoryId=");
6737                    msg.append(parentCategoryId);
6738    
6739                    msg.append(", vocabularyId=");
6740                    msg.append(vocabularyId);
6741    
6742                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6743    
6744                    throw new NoSuchCategoryException(msg.toString());
6745            }
6746    
6747            /**
6748             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6749             *
6750             * @param groupId the group ID
6751             * @param parentCategoryId the parent category ID
6752             * @param vocabularyId the vocabulary ID
6753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6754             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
6755             * @throws SystemException if a system exception occurred
6756             */
6757            @Override
6758            public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6759                    long vocabularyId, OrderByComparator orderByComparator)
6760                    throws SystemException {
6761                    int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6762    
6763                    if (count == 0) {
6764                            return null;
6765                    }
6766    
6767                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6768                                    vocabularyId, count - 1, count, orderByComparator);
6769    
6770                    if (!list.isEmpty()) {
6771                            return list.get(0);
6772                    }
6773    
6774                    return null;
6775            }
6776    
6777            /**
6778             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6779             *
6780             * @param categoryId the primary key of the current asset category
6781             * @param groupId the group ID
6782             * @param parentCategoryId the parent category ID
6783             * @param vocabularyId the vocabulary ID
6784             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6785             * @return the previous, current, and next asset category
6786             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6787             * @throws SystemException if a system exception occurred
6788             */
6789            @Override
6790            public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6791                    long groupId, long parentCategoryId, long vocabularyId,
6792                    OrderByComparator orderByComparator)
6793                    throws NoSuchCategoryException, SystemException {
6794                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6795    
6796                    Session session = null;
6797    
6798                    try {
6799                            session = openSession();
6800    
6801                            AssetCategory[] array = new AssetCategoryImpl[3];
6802    
6803                            array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6804                                            parentCategoryId, vocabularyId, orderByComparator, true);
6805    
6806                            array[1] = assetCategory;
6807    
6808                            array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6809                                            parentCategoryId, vocabularyId, orderByComparator, false);
6810    
6811                            return array;
6812                    }
6813                    catch (Exception e) {
6814                            throw processException(e);
6815                    }
6816                    finally {
6817                            closeSession(session);
6818                    }
6819            }
6820    
6821            protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6822                    AssetCategory assetCategory, long groupId, long parentCategoryId,
6823                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6824                    StringBundler query = null;
6825    
6826                    if (orderByComparator != null) {
6827                            query = new StringBundler(6 +
6828                                            (orderByComparator.getOrderByFields().length * 6));
6829                    }
6830                    else {
6831                            query = new StringBundler(3);
6832                    }
6833    
6834                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6835    
6836                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6837    
6838                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6839    
6840                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6841    
6842                    if (orderByComparator != null) {
6843                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6844    
6845                            if (orderByConditionFields.length > 0) {
6846                                    query.append(WHERE_AND);
6847                            }
6848    
6849                            for (int i = 0; i < orderByConditionFields.length; i++) {
6850                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6851                                    query.append(orderByConditionFields[i]);
6852    
6853                                    if ((i + 1) < orderByConditionFields.length) {
6854                                            if (orderByComparator.isAscending() ^ previous) {
6855                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6856                                            }
6857                                            else {
6858                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6859                                            }
6860                                    }
6861                                    else {
6862                                            if (orderByComparator.isAscending() ^ previous) {
6863                                                    query.append(WHERE_GREATER_THAN);
6864                                            }
6865                                            else {
6866                                                    query.append(WHERE_LESSER_THAN);
6867                                            }
6868                                    }
6869                            }
6870    
6871                            query.append(ORDER_BY_CLAUSE);
6872    
6873                            String[] orderByFields = orderByComparator.getOrderByFields();
6874    
6875                            for (int i = 0; i < orderByFields.length; i++) {
6876                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6877                                    query.append(orderByFields[i]);
6878    
6879                                    if ((i + 1) < orderByFields.length) {
6880                                            if (orderByComparator.isAscending() ^ previous) {
6881                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6882                                            }
6883                                            else {
6884                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6885                                            }
6886                                    }
6887                                    else {
6888                                            if (orderByComparator.isAscending() ^ previous) {
6889                                                    query.append(ORDER_BY_ASC);
6890                                            }
6891                                            else {
6892                                                    query.append(ORDER_BY_DESC);
6893                                            }
6894                                    }
6895                            }
6896                    }
6897                    else {
6898                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6899                    }
6900    
6901                    String sql = query.toString();
6902    
6903                    Query q = session.createQuery(sql);
6904    
6905                    q.setFirstResult(0);
6906                    q.setMaxResults(2);
6907    
6908                    QueryPos qPos = QueryPos.getInstance(q);
6909    
6910                    qPos.add(groupId);
6911    
6912                    qPos.add(parentCategoryId);
6913    
6914                    qPos.add(vocabularyId);
6915    
6916                    if (orderByComparator != null) {
6917                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6918    
6919                            for (Object value : values) {
6920                                    qPos.add(value);
6921                            }
6922                    }
6923    
6924                    List<AssetCategory> list = q.list();
6925    
6926                    if (list.size() == 2) {
6927                            return list.get(1);
6928                    }
6929                    else {
6930                            return null;
6931                    }
6932            }
6933    
6934            /**
6935             * Returns all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6936             *
6937             * @param groupId the group ID
6938             * @param parentCategoryId the parent category ID
6939             * @param vocabularyId the vocabulary ID
6940             * @return the matching asset categories that the user has permission to view
6941             * @throws SystemException if a system exception occurred
6942             */
6943            @Override
6944            public List<AssetCategory> filterFindByG_P_V(long groupId,
6945                    long parentCategoryId, long vocabularyId) throws SystemException {
6946                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6947                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6948            }
6949    
6950            /**
6951             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6952             *
6953             * <p>
6954             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6955             * </p>
6956             *
6957             * @param groupId the group ID
6958             * @param parentCategoryId the parent category ID
6959             * @param vocabularyId the vocabulary ID
6960             * @param start the lower bound of the range of asset categories
6961             * @param end the upper bound of the range of asset categories (not inclusive)
6962             * @return the range of matching asset categories that the user has permission to view
6963             * @throws SystemException if a system exception occurred
6964             */
6965            @Override
6966            public List<AssetCategory> filterFindByG_P_V(long groupId,
6967                    long parentCategoryId, long vocabularyId, int start, int end)
6968                    throws SystemException {
6969                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6970                            start, end, null);
6971            }
6972    
6973            /**
6974             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6975             *
6976             * <p>
6977             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
6978             * </p>
6979             *
6980             * @param groupId the group ID
6981             * @param parentCategoryId the parent category ID
6982             * @param vocabularyId the vocabulary ID
6983             * @param start the lower bound of the range of asset categories
6984             * @param end the upper bound of the range of asset categories (not inclusive)
6985             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6986             * @return the ordered range of matching asset categories that the user has permission to view
6987             * @throws SystemException if a system exception occurred
6988             */
6989            @Override
6990            public List<AssetCategory> filterFindByG_P_V(long groupId,
6991                    long parentCategoryId, long vocabularyId, int start, int end,
6992                    OrderByComparator orderByComparator) throws SystemException {
6993                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6994                            return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
6995                                    end, orderByComparator);
6996                    }
6997    
6998                    StringBundler query = null;
6999    
7000                    if (orderByComparator != null) {
7001                            query = new StringBundler(5 +
7002                                            (orderByComparator.getOrderByFields().length * 3));
7003                    }
7004                    else {
7005                            query = new StringBundler(5);
7006                    }
7007    
7008                    if (getDB().isSupportsInlineDistinct()) {
7009                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7010                    }
7011                    else {
7012                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7013                    }
7014    
7015                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7016    
7017                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7018    
7019                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7020    
7021                    if (!getDB().isSupportsInlineDistinct()) {
7022                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7023                    }
7024    
7025                    if (orderByComparator != null) {
7026                            if (getDB().isSupportsInlineDistinct()) {
7027                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7028                                            orderByComparator, true);
7029                            }
7030                            else {
7031                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7032                                            orderByComparator, true);
7033                            }
7034                    }
7035                    else {
7036                            if (getDB().isSupportsInlineDistinct()) {
7037                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7038                            }
7039                            else {
7040                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7041                            }
7042                    }
7043    
7044                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7045                                    AssetCategory.class.getName(),
7046                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7047    
7048                    Session session = null;
7049    
7050                    try {
7051                            session = openSession();
7052    
7053                            SQLQuery q = session.createSQLQuery(sql);
7054    
7055                            if (getDB().isSupportsInlineDistinct()) {
7056                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7057                            }
7058                            else {
7059                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7060                            }
7061    
7062                            QueryPos qPos = QueryPos.getInstance(q);
7063    
7064                            qPos.add(groupId);
7065    
7066                            qPos.add(parentCategoryId);
7067    
7068                            qPos.add(vocabularyId);
7069    
7070                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7071                                    end);
7072                    }
7073                    catch (Exception e) {
7074                            throw processException(e);
7075                    }
7076                    finally {
7077                            closeSession(session);
7078                    }
7079            }
7080    
7081            /**
7082             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
7083             *
7084             * @param categoryId the primary key of the current asset category
7085             * @param groupId the group ID
7086             * @param parentCategoryId the parent category ID
7087             * @param vocabularyId the vocabulary ID
7088             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7089             * @return the previous, current, and next asset category
7090             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7091             * @throws SystemException if a system exception occurred
7092             */
7093            @Override
7094            public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
7095                    long groupId, long parentCategoryId, long vocabularyId,
7096                    OrderByComparator orderByComparator)
7097                    throws NoSuchCategoryException, SystemException {
7098                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7099                            return findByG_P_V_PrevAndNext(categoryId, groupId,
7100                                    parentCategoryId, vocabularyId, orderByComparator);
7101                    }
7102    
7103                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7104    
7105                    Session session = null;
7106    
7107                    try {
7108                            session = openSession();
7109    
7110                            AssetCategory[] array = new AssetCategoryImpl[3];
7111    
7112                            array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7113                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
7114                                            true);
7115    
7116                            array[1] = assetCategory;
7117    
7118                            array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7119                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
7120                                            false);
7121    
7122                            return array;
7123                    }
7124                    catch (Exception e) {
7125                            throw processException(e);
7126                    }
7127                    finally {
7128                            closeSession(session);
7129                    }
7130            }
7131    
7132            protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
7133                    AssetCategory assetCategory, long groupId, long parentCategoryId,
7134                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7135                    StringBundler query = null;
7136    
7137                    if (orderByComparator != null) {
7138                            query = new StringBundler(6 +
7139                                            (orderByComparator.getOrderByFields().length * 6));
7140                    }
7141                    else {
7142                            query = new StringBundler(3);
7143                    }
7144    
7145                    if (getDB().isSupportsInlineDistinct()) {
7146                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7147                    }
7148                    else {
7149                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7150                    }
7151    
7152                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7153    
7154                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7155    
7156                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7157    
7158                    if (!getDB().isSupportsInlineDistinct()) {
7159                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7160                    }
7161    
7162                    if (orderByComparator != null) {
7163                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7164    
7165                            if (orderByConditionFields.length > 0) {
7166                                    query.append(WHERE_AND);
7167                            }
7168    
7169                            for (int i = 0; i < orderByConditionFields.length; i++) {
7170                                    if (getDB().isSupportsInlineDistinct()) {
7171                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7172                                    }
7173                                    else {
7174                                            query.append(_ORDER_BY_ENTITY_TABLE);
7175                                    }
7176    
7177                                    query.append(orderByConditionFields[i]);
7178    
7179                                    if ((i + 1) < orderByConditionFields.length) {
7180                                            if (orderByComparator.isAscending() ^ previous) {
7181                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7182                                            }
7183                                            else {
7184                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7185                                            }
7186                                    }
7187                                    else {
7188                                            if (orderByComparator.isAscending() ^ previous) {
7189                                                    query.append(WHERE_GREATER_THAN);
7190                                            }
7191                                            else {
7192                                                    query.append(WHERE_LESSER_THAN);
7193                                            }
7194                                    }
7195                            }
7196    
7197                            query.append(ORDER_BY_CLAUSE);
7198    
7199                            String[] orderByFields = orderByComparator.getOrderByFields();
7200    
7201                            for (int i = 0; i < orderByFields.length; i++) {
7202                                    if (getDB().isSupportsInlineDistinct()) {
7203                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7204                                    }
7205                                    else {
7206                                            query.append(_ORDER_BY_ENTITY_TABLE);
7207                                    }
7208    
7209                                    query.append(orderByFields[i]);
7210    
7211                                    if ((i + 1) < orderByFields.length) {
7212                                            if (orderByComparator.isAscending() ^ previous) {
7213                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7214                                            }
7215                                            else {
7216                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7217                                            }
7218                                    }
7219                                    else {
7220                                            if (orderByComparator.isAscending() ^ previous) {
7221                                                    query.append(ORDER_BY_ASC);
7222                                            }
7223                                            else {
7224                                                    query.append(ORDER_BY_DESC);
7225                                            }
7226                                    }
7227                            }
7228                    }
7229                    else {
7230                            if (getDB().isSupportsInlineDistinct()) {
7231                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7232                            }
7233                            else {
7234                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7235                            }
7236                    }
7237    
7238                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7239                                    AssetCategory.class.getName(),
7240                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7241    
7242                    SQLQuery q = session.createSQLQuery(sql);
7243    
7244                    q.setFirstResult(0);
7245                    q.setMaxResults(2);
7246    
7247                    if (getDB().isSupportsInlineDistinct()) {
7248                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7249                    }
7250                    else {
7251                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7252                    }
7253    
7254                    QueryPos qPos = QueryPos.getInstance(q);
7255    
7256                    qPos.add(groupId);
7257    
7258                    qPos.add(parentCategoryId);
7259    
7260                    qPos.add(vocabularyId);
7261    
7262                    if (orderByComparator != null) {
7263                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7264    
7265                            for (Object value : values) {
7266                                    qPos.add(value);
7267                            }
7268                    }
7269    
7270                    List<AssetCategory> list = q.list();
7271    
7272                    if (list.size() == 2) {
7273                            return list.get(1);
7274                    }
7275                    else {
7276                            return null;
7277                    }
7278            }
7279    
7280            /**
7281             * Removes all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63; from the database.
7282             *
7283             * @param groupId the group ID
7284             * @param parentCategoryId the parent category ID
7285             * @param vocabularyId the vocabulary ID
7286             * @throws SystemException if a system exception occurred
7287             */
7288            @Override
7289            public void removeByG_P_V(long groupId, long parentCategoryId,
7290                    long vocabularyId) throws SystemException {
7291                    for (AssetCategory assetCategory : findByG_P_V(groupId,
7292                                    parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7293                                    QueryUtil.ALL_POS, null)) {
7294                            remove(assetCategory);
7295                    }
7296            }
7297    
7298            /**
7299             * Returns the number of asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
7300             *
7301             * @param groupId the group ID
7302             * @param parentCategoryId the parent category ID
7303             * @param vocabularyId the vocabulary ID
7304             * @return the number of matching asset categories
7305             * @throws SystemException if a system exception occurred
7306             */
7307            @Override
7308            public int countByG_P_V(long groupId, long parentCategoryId,
7309                    long vocabularyId) throws SystemException {
7310                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7311    
7312                    Object[] finderArgs = new Object[] {
7313                                    groupId, parentCategoryId, vocabularyId
7314                            };
7315    
7316                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7317                                    this);
7318    
7319                    if (count == null) {
7320                            StringBundler query = new StringBundler(4);
7321    
7322                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7323    
7324                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7325    
7326                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7327    
7328                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7329    
7330                            String sql = query.toString();
7331    
7332                            Session session = null;
7333    
7334                            try {
7335                                    session = openSession();
7336    
7337                                    Query q = session.createQuery(sql);
7338    
7339                                    QueryPos qPos = QueryPos.getInstance(q);
7340    
7341                                    qPos.add(groupId);
7342    
7343                                    qPos.add(parentCategoryId);
7344    
7345                                    qPos.add(vocabularyId);
7346    
7347                                    count = (Long)q.uniqueResult();
7348    
7349                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7350                            }
7351                            catch (Exception e) {
7352                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7353    
7354                                    throw processException(e);
7355                            }
7356                            finally {
7357                                    closeSession(session);
7358                            }
7359                    }
7360    
7361                    return count.intValue();
7362            }
7363    
7364            /**
7365             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
7366             *
7367             * @param groupId the group ID
7368             * @param parentCategoryId the parent category ID
7369             * @param vocabularyId the vocabulary ID
7370             * @return the number of matching asset categories that the user has permission to view
7371             * @throws SystemException if a system exception occurred
7372             */
7373            @Override
7374            public int filterCountByG_P_V(long groupId, long parentCategoryId,
7375                    long vocabularyId) throws SystemException {
7376                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7377                            return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7378                    }
7379    
7380                    StringBundler query = new StringBundler(4);
7381    
7382                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7383    
7384                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7385    
7386                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7387    
7388                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7389    
7390                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7391                                    AssetCategory.class.getName(),
7392                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7393    
7394                    Session session = null;
7395    
7396                    try {
7397                            session = openSession();
7398    
7399                            SQLQuery q = session.createSQLQuery(sql);
7400    
7401                            q.addScalar(COUNT_COLUMN_NAME,
7402                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7403    
7404                            QueryPos qPos = QueryPos.getInstance(q);
7405    
7406                            qPos.add(groupId);
7407    
7408                            qPos.add(parentCategoryId);
7409    
7410                            qPos.add(vocabularyId);
7411    
7412                            Long count = (Long)q.uniqueResult();
7413    
7414                            return count.intValue();
7415                    }
7416                    catch (Exception e) {
7417                            throw processException(e);
7418                    }
7419                    finally {
7420                            closeSession(session);
7421                    }
7422            }
7423    
7424            private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7425            private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7426            private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7427            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7428                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7429                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7430                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7431                            "findByG_LikeN_V",
7432                            new String[] {
7433                                    Long.class.getName(), String.class.getName(),
7434                                    Long.class.getName(),
7435                                    
7436                            Integer.class.getName(), Integer.class.getName(),
7437                                    OrderByComparator.class.getName()
7438                            });
7439            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7440                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7441                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7442                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7443                            new String[] {
7444                                    Long.class.getName(), String.class.getName(),
7445                                    Long.class.getName()
7446                            });
7447    
7448            /**
7449             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7450             *
7451             * @param groupId the group ID
7452             * @param name the name
7453             * @param vocabularyId the vocabulary ID
7454             * @return the matching asset categories
7455             * @throws SystemException if a system exception occurred
7456             */
7457            @Override
7458            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7459                    long vocabularyId) throws SystemException {
7460                    return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7461                            QueryUtil.ALL_POS, null);
7462            }
7463    
7464            /**
7465             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7466             *
7467             * <p>
7468             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7469             * </p>
7470             *
7471             * @param groupId the group ID
7472             * @param name the name
7473             * @param vocabularyId the vocabulary ID
7474             * @param start the lower bound of the range of asset categories
7475             * @param end the upper bound of the range of asset categories (not inclusive)
7476             * @return the range of matching asset categories
7477             * @throws SystemException if a system exception occurred
7478             */
7479            @Override
7480            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7481                    long vocabularyId, int start, int end) throws SystemException {
7482                    return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7483            }
7484    
7485            /**
7486             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7487             *
7488             * <p>
7489             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7490             * </p>
7491             *
7492             * @param groupId the group ID
7493             * @param name the name
7494             * @param vocabularyId the vocabulary ID
7495             * @param start the lower bound of the range of asset categories
7496             * @param end the upper bound of the range of asset categories (not inclusive)
7497             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7498             * @return the ordered range of matching asset categories
7499             * @throws SystemException if a system exception occurred
7500             */
7501            @Override
7502            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7503                    long vocabularyId, int start, int end,
7504                    OrderByComparator orderByComparator) throws SystemException {
7505                    boolean pagination = true;
7506                    FinderPath finderPath = null;
7507                    Object[] finderArgs = null;
7508    
7509                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7510                    finderArgs = new Object[] {
7511                                    groupId, name, vocabularyId,
7512                                    
7513                                    start, end, orderByComparator
7514                            };
7515    
7516                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7517                                    finderArgs, this);
7518    
7519                    if ((list != null) && !list.isEmpty()) {
7520                            for (AssetCategory assetCategory : list) {
7521                                    if ((groupId != assetCategory.getGroupId()) ||
7522                                                    !Validator.equals(name, assetCategory.getName()) ||
7523                                                    (vocabularyId != assetCategory.getVocabularyId())) {
7524                                            list = null;
7525    
7526                                            break;
7527                                    }
7528                            }
7529                    }
7530    
7531                    if (list == null) {
7532                            StringBundler query = null;
7533    
7534                            if (orderByComparator != null) {
7535                                    query = new StringBundler(5 +
7536                                                    (orderByComparator.getOrderByFields().length * 3));
7537                            }
7538                            else {
7539                                    query = new StringBundler(5);
7540                            }
7541    
7542                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7543    
7544                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7545    
7546                            boolean bindName = false;
7547    
7548                            if (name == null) {
7549                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7550                            }
7551                            else if (name.equals(StringPool.BLANK)) {
7552                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7553                            }
7554                            else {
7555                                    bindName = true;
7556    
7557                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7558                            }
7559    
7560                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7561    
7562                            if (orderByComparator != null) {
7563                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7564                                            orderByComparator);
7565                            }
7566                            else
7567                             if (pagination) {
7568                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7569                            }
7570    
7571                            String sql = query.toString();
7572    
7573                            Session session = null;
7574    
7575                            try {
7576                                    session = openSession();
7577    
7578                                    Query q = session.createQuery(sql);
7579    
7580                                    QueryPos qPos = QueryPos.getInstance(q);
7581    
7582                                    qPos.add(groupId);
7583    
7584                                    if (bindName) {
7585                                            qPos.add(name);
7586                                    }
7587    
7588                                    qPos.add(vocabularyId);
7589    
7590                                    if (!pagination) {
7591                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7592                                                            start, end, false);
7593    
7594                                            Collections.sort(list);
7595    
7596                                            list = new UnmodifiableList<AssetCategory>(list);
7597                                    }
7598                                    else {
7599                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7600                                                            start, end);
7601                                    }
7602    
7603                                    cacheResult(list);
7604    
7605                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7606                            }
7607                            catch (Exception e) {
7608                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7609    
7610                                    throw processException(e);
7611                            }
7612                            finally {
7613                                    closeSession(session);
7614                            }
7615                    }
7616    
7617                    return list;
7618            }
7619    
7620            /**
7621             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7622             *
7623             * @param groupId the group ID
7624             * @param name the name
7625             * @param vocabularyId the vocabulary ID
7626             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7627             * @return the first matching asset category
7628             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7629             * @throws SystemException if a system exception occurred
7630             */
7631            @Override
7632            public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7633                    long vocabularyId, OrderByComparator orderByComparator)
7634                    throws NoSuchCategoryException, SystemException {
7635                    AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7636                                    vocabularyId, orderByComparator);
7637    
7638                    if (assetCategory != null) {
7639                            return assetCategory;
7640                    }
7641    
7642                    StringBundler msg = new StringBundler(8);
7643    
7644                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7645    
7646                    msg.append("groupId=");
7647                    msg.append(groupId);
7648    
7649                    msg.append(", name=");
7650                    msg.append(name);
7651    
7652                    msg.append(", vocabularyId=");
7653                    msg.append(vocabularyId);
7654    
7655                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7656    
7657                    throw new NoSuchCategoryException(msg.toString());
7658            }
7659    
7660            /**
7661             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7662             *
7663             * @param groupId the group ID
7664             * @param name the name
7665             * @param vocabularyId the vocabulary ID
7666             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7667             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
7668             * @throws SystemException if a system exception occurred
7669             */
7670            @Override
7671            public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7672                    long vocabularyId, OrderByComparator orderByComparator)
7673                    throws SystemException {
7674                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7675                                    0, 1, orderByComparator);
7676    
7677                    if (!list.isEmpty()) {
7678                            return list.get(0);
7679                    }
7680    
7681                    return null;
7682            }
7683    
7684            /**
7685             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7686             *
7687             * @param groupId the group ID
7688             * @param name the name
7689             * @param vocabularyId the vocabulary ID
7690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7691             * @return the last matching asset category
7692             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7693             * @throws SystemException if a system exception occurred
7694             */
7695            @Override
7696            public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7697                    long vocabularyId, OrderByComparator orderByComparator)
7698                    throws NoSuchCategoryException, SystemException {
7699                    AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7700                                    vocabularyId, orderByComparator);
7701    
7702                    if (assetCategory != null) {
7703                            return assetCategory;
7704                    }
7705    
7706                    StringBundler msg = new StringBundler(8);
7707    
7708                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7709    
7710                    msg.append("groupId=");
7711                    msg.append(groupId);
7712    
7713                    msg.append(", name=");
7714                    msg.append(name);
7715    
7716                    msg.append(", vocabularyId=");
7717                    msg.append(vocabularyId);
7718    
7719                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7720    
7721                    throw new NoSuchCategoryException(msg.toString());
7722            }
7723    
7724            /**
7725             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7726             *
7727             * @param groupId the group ID
7728             * @param name the name
7729             * @param vocabularyId the vocabulary ID
7730             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7731             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
7732             * @throws SystemException if a system exception occurred
7733             */
7734            @Override
7735            public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7736                    long vocabularyId, OrderByComparator orderByComparator)
7737                    throws SystemException {
7738                    int count = countByG_LikeN_V(groupId, name, vocabularyId);
7739    
7740                    if (count == 0) {
7741                            return null;
7742                    }
7743    
7744                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7745                                    count - 1, count, orderByComparator);
7746    
7747                    if (!list.isEmpty()) {
7748                            return list.get(0);
7749                    }
7750    
7751                    return null;
7752            }
7753    
7754            /**
7755             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7756             *
7757             * @param categoryId the primary key of the current asset category
7758             * @param groupId the group ID
7759             * @param name the name
7760             * @param vocabularyId the vocabulary ID
7761             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7762             * @return the previous, current, and next asset category
7763             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7764             * @throws SystemException if a system exception occurred
7765             */
7766            @Override
7767            public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7768                    long groupId, String name, long vocabularyId,
7769                    OrderByComparator orderByComparator)
7770                    throws NoSuchCategoryException, SystemException {
7771                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7772    
7773                    Session session = null;
7774    
7775                    try {
7776                            session = openSession();
7777    
7778                            AssetCategory[] array = new AssetCategoryImpl[3];
7779    
7780                            array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7781                                            groupId, name, vocabularyId, orderByComparator, true);
7782    
7783                            array[1] = assetCategory;
7784    
7785                            array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7786                                            groupId, name, vocabularyId, orderByComparator, false);
7787    
7788                            return array;
7789                    }
7790                    catch (Exception e) {
7791                            throw processException(e);
7792                    }
7793                    finally {
7794                            closeSession(session);
7795                    }
7796            }
7797    
7798            protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7799                    AssetCategory assetCategory, long groupId, String name,
7800                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7801                    StringBundler query = null;
7802    
7803                    if (orderByComparator != null) {
7804                            query = new StringBundler(6 +
7805                                            (orderByComparator.getOrderByFields().length * 6));
7806                    }
7807                    else {
7808                            query = new StringBundler(3);
7809                    }
7810    
7811                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7812    
7813                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7814    
7815                    boolean bindName = false;
7816    
7817                    if (name == null) {
7818                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7819                    }
7820                    else if (name.equals(StringPool.BLANK)) {
7821                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7822                    }
7823                    else {
7824                            bindName = true;
7825    
7826                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7827                    }
7828    
7829                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7830    
7831                    if (orderByComparator != null) {
7832                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7833    
7834                            if (orderByConditionFields.length > 0) {
7835                                    query.append(WHERE_AND);
7836                            }
7837    
7838                            for (int i = 0; i < orderByConditionFields.length; i++) {
7839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7840                                    query.append(orderByConditionFields[i]);
7841    
7842                                    if ((i + 1) < orderByConditionFields.length) {
7843                                            if (orderByComparator.isAscending() ^ previous) {
7844                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7845                                            }
7846                                            else {
7847                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7848                                            }
7849                                    }
7850                                    else {
7851                                            if (orderByComparator.isAscending() ^ previous) {
7852                                                    query.append(WHERE_GREATER_THAN);
7853                                            }
7854                                            else {
7855                                                    query.append(WHERE_LESSER_THAN);
7856                                            }
7857                                    }
7858                            }
7859    
7860                            query.append(ORDER_BY_CLAUSE);
7861    
7862                            String[] orderByFields = orderByComparator.getOrderByFields();
7863    
7864                            for (int i = 0; i < orderByFields.length; i++) {
7865                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7866                                    query.append(orderByFields[i]);
7867    
7868                                    if ((i + 1) < orderByFields.length) {
7869                                            if (orderByComparator.isAscending() ^ previous) {
7870                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7871                                            }
7872                                            else {
7873                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7874                                            }
7875                                    }
7876                                    else {
7877                                            if (orderByComparator.isAscending() ^ previous) {
7878                                                    query.append(ORDER_BY_ASC);
7879                                            }
7880                                            else {
7881                                                    query.append(ORDER_BY_DESC);
7882                                            }
7883                                    }
7884                            }
7885                    }
7886                    else {
7887                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7888                    }
7889    
7890                    String sql = query.toString();
7891    
7892                    Query q = session.createQuery(sql);
7893    
7894                    q.setFirstResult(0);
7895                    q.setMaxResults(2);
7896    
7897                    QueryPos qPos = QueryPos.getInstance(q);
7898    
7899                    qPos.add(groupId);
7900    
7901                    if (bindName) {
7902                            qPos.add(name);
7903                    }
7904    
7905                    qPos.add(vocabularyId);
7906    
7907                    if (orderByComparator != null) {
7908                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7909    
7910                            for (Object value : values) {
7911                                    qPos.add(value);
7912                            }
7913                    }
7914    
7915                    List<AssetCategory> list = q.list();
7916    
7917                    if (list.size() == 2) {
7918                            return list.get(1);
7919                    }
7920                    else {
7921                            return null;
7922                    }
7923            }
7924    
7925            /**
7926             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7927             *
7928             * @param groupId the group ID
7929             * @param name the name
7930             * @param vocabularyId the vocabulary ID
7931             * @return the matching asset categories that the user has permission to view
7932             * @throws SystemException if a system exception occurred
7933             */
7934            @Override
7935            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7936                    long vocabularyId) throws SystemException {
7937                    return filterFindByG_LikeN_V(groupId, name, vocabularyId,
7938                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7939            }
7940    
7941            /**
7942             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7943             *
7944             * <p>
7945             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7946             * </p>
7947             *
7948             * @param groupId the group ID
7949             * @param name the name
7950             * @param vocabularyId the vocabulary ID
7951             * @param start the lower bound of the range of asset categories
7952             * @param end the upper bound of the range of asset categories (not inclusive)
7953             * @return the range of matching asset categories that the user has permission to view
7954             * @throws SystemException if a system exception occurred
7955             */
7956            @Override
7957            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7958                    long vocabularyId, int start, int end) throws SystemException {
7959                    return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
7960                            null);
7961            }
7962    
7963            /**
7964             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7965             *
7966             * <p>
7967             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
7968             * </p>
7969             *
7970             * @param groupId the group ID
7971             * @param name the name
7972             * @param vocabularyId the vocabulary ID
7973             * @param start the lower bound of the range of asset categories
7974             * @param end the upper bound of the range of asset categories (not inclusive)
7975             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7976             * @return the ordered range of matching asset categories that the user has permission to view
7977             * @throws SystemException if a system exception occurred
7978             */
7979            @Override
7980            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7981                    long vocabularyId, int start, int end,
7982                    OrderByComparator orderByComparator) throws SystemException {
7983                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7984                            return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7985                                    orderByComparator);
7986                    }
7987    
7988                    StringBundler query = null;
7989    
7990                    if (orderByComparator != null) {
7991                            query = new StringBundler(5 +
7992                                            (orderByComparator.getOrderByFields().length * 3));
7993                    }
7994                    else {
7995                            query = new StringBundler(5);
7996                    }
7997    
7998                    if (getDB().isSupportsInlineDistinct()) {
7999                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8000                    }
8001                    else {
8002                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8003                    }
8004    
8005                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8006    
8007                    boolean bindName = false;
8008    
8009                    if (name == null) {
8010                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8011                    }
8012                    else if (name.equals(StringPool.BLANK)) {
8013                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8014                    }
8015                    else {
8016                            bindName = true;
8017    
8018                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8019                    }
8020    
8021                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8022    
8023                    if (!getDB().isSupportsInlineDistinct()) {
8024                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8025                    }
8026    
8027                    if (orderByComparator != null) {
8028                            if (getDB().isSupportsInlineDistinct()) {
8029                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8030                                            orderByComparator, true);
8031                            }
8032                            else {
8033                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8034                                            orderByComparator, true);
8035                            }
8036                    }
8037                    else {
8038                            if (getDB().isSupportsInlineDistinct()) {
8039                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8040                            }
8041                            else {
8042                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8043                            }
8044                    }
8045    
8046                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8047                                    AssetCategory.class.getName(),
8048                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8049    
8050                    Session session = null;
8051    
8052                    try {
8053                            session = openSession();
8054    
8055                            SQLQuery q = session.createSQLQuery(sql);
8056    
8057                            if (getDB().isSupportsInlineDistinct()) {
8058                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8059                            }
8060                            else {
8061                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8062                            }
8063    
8064                            QueryPos qPos = QueryPos.getInstance(q);
8065    
8066                            qPos.add(groupId);
8067    
8068                            if (bindName) {
8069                                    qPos.add(name);
8070                            }
8071    
8072                            qPos.add(vocabularyId);
8073    
8074                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8075                                    end);
8076                    }
8077                    catch (Exception e) {
8078                            throw processException(e);
8079                    }
8080                    finally {
8081                            closeSession(session);
8082                    }
8083            }
8084    
8085            /**
8086             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
8087             *
8088             * @param categoryId the primary key of the current asset category
8089             * @param groupId the group ID
8090             * @param name the name
8091             * @param vocabularyId the vocabulary ID
8092             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8093             * @return the previous, current, and next asset category
8094             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
8095             * @throws SystemException if a system exception occurred
8096             */
8097            @Override
8098            public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
8099                    long groupId, String name, long vocabularyId,
8100                    OrderByComparator orderByComparator)
8101                    throws NoSuchCategoryException, SystemException {
8102                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8103                            return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
8104                                    vocabularyId, orderByComparator);
8105                    }
8106    
8107                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
8108    
8109                    Session session = null;
8110    
8111                    try {
8112                            session = openSession();
8113    
8114                            AssetCategory[] array = new AssetCategoryImpl[3];
8115    
8116                            array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8117                                            groupId, name, vocabularyId, orderByComparator, true);
8118    
8119                            array[1] = assetCategory;
8120    
8121                            array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8122                                            groupId, name, vocabularyId, orderByComparator, false);
8123    
8124                            return array;
8125                    }
8126                    catch (Exception e) {
8127                            throw processException(e);
8128                    }
8129                    finally {
8130                            closeSession(session);
8131                    }
8132            }
8133    
8134            protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
8135                    AssetCategory assetCategory, long groupId, String name,
8136                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
8137                    StringBundler query = null;
8138    
8139                    if (orderByComparator != null) {
8140                            query = new StringBundler(6 +
8141                                            (orderByComparator.getOrderByFields().length * 6));
8142                    }
8143                    else {
8144                            query = new StringBundler(3);
8145                    }
8146    
8147                    if (getDB().isSupportsInlineDistinct()) {
8148                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8149                    }
8150                    else {
8151                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8152                    }
8153    
8154                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8155    
8156                    boolean bindName = false;
8157    
8158                    if (name == null) {
8159                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8160                    }
8161                    else if (name.equals(StringPool.BLANK)) {
8162                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8163                    }
8164                    else {
8165                            bindName = true;
8166    
8167                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8168                    }
8169    
8170                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8171    
8172                    if (!getDB().isSupportsInlineDistinct()) {
8173                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8174                    }
8175    
8176                    if (orderByComparator != null) {
8177                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8178    
8179                            if (orderByConditionFields.length > 0) {
8180                                    query.append(WHERE_AND);
8181                            }
8182    
8183                            for (int i = 0; i < orderByConditionFields.length; i++) {
8184                                    if (getDB().isSupportsInlineDistinct()) {
8185                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8186                                    }
8187                                    else {
8188                                            query.append(_ORDER_BY_ENTITY_TABLE);
8189                                    }
8190    
8191                                    query.append(orderByConditionFields[i]);
8192    
8193                                    if ((i + 1) < orderByConditionFields.length) {
8194                                            if (orderByComparator.isAscending() ^ previous) {
8195                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8196                                            }
8197                                            else {
8198                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8199                                            }
8200                                    }
8201                                    else {
8202                                            if (orderByComparator.isAscending() ^ previous) {
8203                                                    query.append(WHERE_GREATER_THAN);
8204                                            }
8205                                            else {
8206                                                    query.append(WHERE_LESSER_THAN);
8207                                            }
8208                                    }
8209                            }
8210    
8211                            query.append(ORDER_BY_CLAUSE);
8212    
8213                            String[] orderByFields = orderByComparator.getOrderByFields();
8214    
8215                            for (int i = 0; i < orderByFields.length; i++) {
8216                                    if (getDB().isSupportsInlineDistinct()) {
8217                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8218                                    }
8219                                    else {
8220                                            query.append(_ORDER_BY_ENTITY_TABLE);
8221                                    }
8222    
8223                                    query.append(orderByFields[i]);
8224    
8225                                    if ((i + 1) < orderByFields.length) {
8226                                            if (orderByComparator.isAscending() ^ previous) {
8227                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8228                                            }
8229                                            else {
8230                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8231                                            }
8232                                    }
8233                                    else {
8234                                            if (orderByComparator.isAscending() ^ previous) {
8235                                                    query.append(ORDER_BY_ASC);
8236                                            }
8237                                            else {
8238                                                    query.append(ORDER_BY_DESC);
8239                                            }
8240                                    }
8241                            }
8242                    }
8243                    else {
8244                            if (getDB().isSupportsInlineDistinct()) {
8245                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8246                            }
8247                            else {
8248                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8249                            }
8250                    }
8251    
8252                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8253                                    AssetCategory.class.getName(),
8254                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8255    
8256                    SQLQuery q = session.createSQLQuery(sql);
8257    
8258                    q.setFirstResult(0);
8259                    q.setMaxResults(2);
8260    
8261                    if (getDB().isSupportsInlineDistinct()) {
8262                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8263                    }
8264                    else {
8265                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8266                    }
8267    
8268                    QueryPos qPos = QueryPos.getInstance(q);
8269    
8270                    qPos.add(groupId);
8271    
8272                    if (bindName) {
8273                            qPos.add(name);
8274                    }
8275    
8276                    qPos.add(vocabularyId);
8277    
8278                    if (orderByComparator != null) {
8279                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8280    
8281                            for (Object value : values) {
8282                                    qPos.add(value);
8283                            }
8284                    }
8285    
8286                    List<AssetCategory> list = q.list();
8287    
8288                    if (list.size() == 2) {
8289                            return list.get(1);
8290                    }
8291                    else {
8292                            return null;
8293                    }
8294            }
8295    
8296            /**
8297             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8298             *
8299             * @param groupId the group ID
8300             * @param name the name
8301             * @param vocabularyIds the vocabulary IDs
8302             * @return the matching asset categories that the user has permission to view
8303             * @throws SystemException if a system exception occurred
8304             */
8305            @Override
8306            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8307                    long[] vocabularyIds) throws SystemException {
8308                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8309                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8310            }
8311    
8312            /**
8313             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8314             *
8315             * <p>
8316             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8317             * </p>
8318             *
8319             * @param groupId the group ID
8320             * @param name the name
8321             * @param vocabularyIds the vocabulary IDs
8322             * @param start the lower bound of the range of asset categories
8323             * @param end the upper bound of the range of asset categories (not inclusive)
8324             * @return the range of matching asset categories that the user has permission to view
8325             * @throws SystemException if a system exception occurred
8326             */
8327            @Override
8328            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8329                    long[] vocabularyIds, int start, int end) throws SystemException {
8330                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8331                            null);
8332            }
8333    
8334            /**
8335             * Returns an ordered range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8336             *
8337             * <p>
8338             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8339             * </p>
8340             *
8341             * @param groupId the group ID
8342             * @param name the name
8343             * @param vocabularyIds the vocabulary IDs
8344             * @param start the lower bound of the range of asset categories
8345             * @param end the upper bound of the range of asset categories (not inclusive)
8346             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8347             * @return the ordered range of matching asset categories that the user has permission to view
8348             * @throws SystemException if a system exception occurred
8349             */
8350            @Override
8351            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8352                    long[] vocabularyIds, int start, int end,
8353                    OrderByComparator orderByComparator) throws SystemException {
8354                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8355                            return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8356                                    orderByComparator);
8357                    }
8358    
8359                    StringBundler query = new StringBundler();
8360    
8361                    if (getDB().isSupportsInlineDistinct()) {
8362                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8363                    }
8364                    else {
8365                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8366                    }
8367    
8368                    boolean conjunctionable = false;
8369    
8370                    if (conjunctionable) {
8371                            query.append(WHERE_AND);
8372                    }
8373    
8374                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8375    
8376                    conjunctionable = true;
8377    
8378                    if (conjunctionable) {
8379                            query.append(WHERE_AND);
8380                    }
8381    
8382                    if (name == null) {
8383                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8384                    }
8385                    else if (name.equals(StringPool.BLANK)) {
8386                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8387                    }
8388                    else {
8389                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8390                    }
8391    
8392                    conjunctionable = true;
8393    
8394                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8395                            if (conjunctionable) {
8396                                    query.append(WHERE_AND);
8397                            }
8398    
8399                            query.append(StringPool.OPEN_PARENTHESIS);
8400    
8401                            for (int i = 0; i < vocabularyIds.length; i++) {
8402                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8403    
8404                                    if ((i + 1) < vocabularyIds.length) {
8405                                            query.append(WHERE_OR);
8406                                    }
8407                            }
8408    
8409                            query.append(StringPool.CLOSE_PARENTHESIS);
8410    
8411                            conjunctionable = true;
8412                    }
8413    
8414                    if (!getDB().isSupportsInlineDistinct()) {
8415                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8416                    }
8417    
8418                    if (orderByComparator != null) {
8419                            if (getDB().isSupportsInlineDistinct()) {
8420                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8421                                            orderByComparator, true);
8422                            }
8423                            else {
8424                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8425                                            orderByComparator, true);
8426                            }
8427                    }
8428                    else {
8429                            if (getDB().isSupportsInlineDistinct()) {
8430                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8431                            }
8432                            else {
8433                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8434                            }
8435                    }
8436    
8437                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8438                                    AssetCategory.class.getName(),
8439                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8440    
8441                    Session session = null;
8442    
8443                    try {
8444                            session = openSession();
8445    
8446                            SQLQuery q = session.createSQLQuery(sql);
8447    
8448                            if (getDB().isSupportsInlineDistinct()) {
8449                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8450                            }
8451                            else {
8452                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8453                            }
8454    
8455                            QueryPos qPos = QueryPos.getInstance(q);
8456    
8457                            qPos.add(groupId);
8458    
8459                            if (name != null) {
8460                                    qPos.add(name);
8461                            }
8462    
8463                            if (vocabularyIds != null) {
8464                                    qPos.add(vocabularyIds);
8465                            }
8466    
8467                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8468                                    end);
8469                    }
8470                    catch (Exception e) {
8471                            throw processException(e);
8472                    }
8473                    finally {
8474                            closeSession(session);
8475                    }
8476            }
8477    
8478            /**
8479             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8480             *
8481             * <p>
8482             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8483             * </p>
8484             *
8485             * @param groupId the group ID
8486             * @param name the name
8487             * @param vocabularyIds the vocabulary IDs
8488             * @return the matching asset categories
8489             * @throws SystemException if a system exception occurred
8490             */
8491            @Override
8492            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8493                    long[] vocabularyIds) throws SystemException {
8494                    return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8495                            QueryUtil.ALL_POS, null);
8496            }
8497    
8498            /**
8499             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8500             *
8501             * <p>
8502             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8503             * </p>
8504             *
8505             * @param groupId the group ID
8506             * @param name the name
8507             * @param vocabularyIds the vocabulary IDs
8508             * @param start the lower bound of the range of asset categories
8509             * @param end the upper bound of the range of asset categories (not inclusive)
8510             * @return the range of matching asset categories
8511             * @throws SystemException if a system exception occurred
8512             */
8513            @Override
8514            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8515                    long[] vocabularyIds, int start, int end) throws SystemException {
8516                    return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8517            }
8518    
8519            /**
8520             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8521             *
8522             * <p>
8523             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
8524             * </p>
8525             *
8526             * @param groupId the group ID
8527             * @param name the name
8528             * @param vocabularyIds the vocabulary IDs
8529             * @param start the lower bound of the range of asset categories
8530             * @param end the upper bound of the range of asset categories (not inclusive)
8531             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8532             * @return the ordered range of matching asset categories
8533             * @throws SystemException if a system exception occurred
8534             */
8535            @Override
8536            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8537                    long[] vocabularyIds, int start, int end,
8538                    OrderByComparator orderByComparator) throws SystemException {
8539                    if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
8540                            return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8541                                    orderByComparator);
8542                    }
8543    
8544                    boolean pagination = true;
8545                    Object[] finderArgs = null;
8546    
8547                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8548                                    (orderByComparator == null)) {
8549                            pagination = false;
8550                            finderArgs = new Object[] {
8551                                            groupId, name, StringUtil.merge(vocabularyIds)
8552                                    };
8553                    }
8554                    else {
8555                            finderArgs = new Object[] {
8556                                            groupId, name, StringUtil.merge(vocabularyIds),
8557                                            
8558                                            start, end, orderByComparator
8559                                    };
8560                    }
8561    
8562                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8563                                    finderArgs, this);
8564    
8565                    if ((list != null) && !list.isEmpty()) {
8566                            for (AssetCategory assetCategory : list) {
8567                                    if ((groupId != assetCategory.getGroupId()) ||
8568                                                    !Validator.equals(name, assetCategory.getName()) ||
8569                                                    !ArrayUtil.contains(vocabularyIds,
8570                                                            assetCategory.getVocabularyId())) {
8571                                            list = null;
8572    
8573                                            break;
8574                                    }
8575                            }
8576                    }
8577    
8578                    if (list == null) {
8579                            StringBundler query = new StringBundler();
8580    
8581                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8582    
8583                            boolean conjunctionable = false;
8584    
8585                            if (conjunctionable) {
8586                                    query.append(WHERE_AND);
8587                            }
8588    
8589                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8590    
8591                            conjunctionable = true;
8592    
8593                            if (conjunctionable) {
8594                                    query.append(WHERE_AND);
8595                            }
8596    
8597                            if (name == null) {
8598                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8599                            }
8600                            else if (name.equals(StringPool.BLANK)) {
8601                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8602                            }
8603                            else {
8604                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8605                            }
8606    
8607                            conjunctionable = true;
8608    
8609                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8610                                    if (conjunctionable) {
8611                                            query.append(WHERE_AND);
8612                                    }
8613    
8614                                    query.append(StringPool.OPEN_PARENTHESIS);
8615    
8616                                    for (int i = 0; i < vocabularyIds.length; i++) {
8617                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8618    
8619                                            if ((i + 1) < vocabularyIds.length) {
8620                                                    query.append(WHERE_OR);
8621                                            }
8622                                    }
8623    
8624                                    query.append(StringPool.CLOSE_PARENTHESIS);
8625    
8626                                    conjunctionable = true;
8627                            }
8628    
8629                            if (orderByComparator != null) {
8630                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8631                                            orderByComparator);
8632                            }
8633                            else
8634                             if (pagination) {
8635                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8636                            }
8637    
8638                            String sql = query.toString();
8639    
8640                            Session session = null;
8641    
8642                            try {
8643                                    session = openSession();
8644    
8645                                    Query q = session.createQuery(sql);
8646    
8647                                    QueryPos qPos = QueryPos.getInstance(q);
8648    
8649                                    qPos.add(groupId);
8650    
8651                                    if (name != null) {
8652                                            qPos.add(name);
8653                                    }
8654    
8655                                    if (vocabularyIds != null) {
8656                                            qPos.add(vocabularyIds);
8657                                    }
8658    
8659                                    if (!pagination) {
8660                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8661                                                            start, end, false);
8662    
8663                                            Collections.sort(list);
8664    
8665                                            list = new UnmodifiableList<AssetCategory>(list);
8666                                    }
8667                                    else {
8668                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8669                                                            start, end);
8670                                    }
8671    
8672                                    cacheResult(list);
8673    
8674                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8675                                            finderArgs, list);
8676                            }
8677                            catch (Exception e) {
8678                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8679                                            finderArgs);
8680    
8681                                    throw processException(e);
8682                            }
8683                            finally {
8684                                    closeSession(session);
8685                            }
8686                    }
8687    
8688                    return list;
8689            }
8690    
8691            /**
8692             * Removes all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63; from the database.
8693             *
8694             * @param groupId the group ID
8695             * @param name the name
8696             * @param vocabularyId the vocabulary ID
8697             * @throws SystemException if a system exception occurred
8698             */
8699            @Override
8700            public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8701                    throws SystemException {
8702                    for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8703                                    vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8704                            remove(assetCategory);
8705                    }
8706            }
8707    
8708            /**
8709             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
8710             *
8711             * @param groupId the group ID
8712             * @param name the name
8713             * @param vocabularyId the vocabulary ID
8714             * @return the number of matching asset categories
8715             * @throws SystemException if a system exception occurred
8716             */
8717            @Override
8718            public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
8719                    throws SystemException {
8720                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8721    
8722                    Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8723    
8724                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8725                                    this);
8726    
8727                    if (count == null) {
8728                            StringBundler query = new StringBundler(4);
8729    
8730                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8731    
8732                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8733    
8734                            boolean bindName = false;
8735    
8736                            if (name == null) {
8737                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8738                            }
8739                            else if (name.equals(StringPool.BLANK)) {
8740                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8741                            }
8742                            else {
8743                                    bindName = true;
8744    
8745                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8746                            }
8747    
8748                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8749    
8750                            String sql = query.toString();
8751    
8752                            Session session = null;
8753    
8754                            try {
8755                                    session = openSession();
8756    
8757                                    Query q = session.createQuery(sql);
8758    
8759                                    QueryPos qPos = QueryPos.getInstance(q);
8760    
8761                                    qPos.add(groupId);
8762    
8763                                    if (bindName) {
8764                                            qPos.add(name);
8765                                    }
8766    
8767                                    qPos.add(vocabularyId);
8768    
8769                                    count = (Long)q.uniqueResult();
8770    
8771                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8772                            }
8773                            catch (Exception e) {
8774                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8775    
8776                                    throw processException(e);
8777                            }
8778                            finally {
8779                                    closeSession(session);
8780                            }
8781                    }
8782    
8783                    return count.intValue();
8784            }
8785    
8786            /**
8787             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8788             *
8789             * @param groupId the group ID
8790             * @param name the name
8791             * @param vocabularyIds the vocabulary IDs
8792             * @return the number of matching asset categories
8793             * @throws SystemException if a system exception occurred
8794             */
8795            @Override
8796            public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
8797                    throws SystemException {
8798                    Object[] finderArgs = new Object[] {
8799                                    groupId, name, StringUtil.merge(vocabularyIds)
8800                            };
8801    
8802                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8803                                    finderArgs, this);
8804    
8805                    if (count == null) {
8806                            StringBundler query = new StringBundler();
8807    
8808                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8809    
8810                            boolean conjunctionable = false;
8811    
8812                            if (conjunctionable) {
8813                                    query.append(WHERE_AND);
8814                            }
8815    
8816                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8817    
8818                            conjunctionable = true;
8819    
8820                            if (conjunctionable) {
8821                                    query.append(WHERE_AND);
8822                            }
8823    
8824                            if (name == null) {
8825                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8826                            }
8827                            else if (name.equals(StringPool.BLANK)) {
8828                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8829                            }
8830                            else {
8831                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8832                            }
8833    
8834                            conjunctionable = true;
8835    
8836                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8837                                    if (conjunctionable) {
8838                                            query.append(WHERE_AND);
8839                                    }
8840    
8841                                    query.append(StringPool.OPEN_PARENTHESIS);
8842    
8843                                    for (int i = 0; i < vocabularyIds.length; i++) {
8844                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8845    
8846                                            if ((i + 1) < vocabularyIds.length) {
8847                                                    query.append(WHERE_OR);
8848                                            }
8849                                    }
8850    
8851                                    query.append(StringPool.CLOSE_PARENTHESIS);
8852    
8853                                    conjunctionable = true;
8854                            }
8855    
8856                            String sql = query.toString();
8857    
8858                            Session session = null;
8859    
8860                            try {
8861                                    session = openSession();
8862    
8863                                    Query q = session.createQuery(sql);
8864    
8865                                    QueryPos qPos = QueryPos.getInstance(q);
8866    
8867                                    qPos.add(groupId);
8868    
8869                                    if (name != null) {
8870                                            qPos.add(name);
8871                                    }
8872    
8873                                    if (vocabularyIds != null) {
8874                                            qPos.add(vocabularyIds);
8875                                    }
8876    
8877                                    count = (Long)q.uniqueResult();
8878    
8879                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8880                                            finderArgs, count);
8881                            }
8882                            catch (Exception e) {
8883                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8884                                            finderArgs);
8885    
8886                                    throw processException(e);
8887                            }
8888                            finally {
8889                                    closeSession(session);
8890                            }
8891                    }
8892    
8893                    return count.intValue();
8894            }
8895    
8896            /**
8897             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
8898             *
8899             * @param groupId the group ID
8900             * @param name the name
8901             * @param vocabularyId the vocabulary ID
8902             * @return the number of matching asset categories that the user has permission to view
8903             * @throws SystemException if a system exception occurred
8904             */
8905            @Override
8906            public int filterCountByG_LikeN_V(long groupId, String name,
8907                    long vocabularyId) throws SystemException {
8908                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8909                            return countByG_LikeN_V(groupId, name, vocabularyId);
8910                    }
8911    
8912                    StringBundler query = new StringBundler(4);
8913    
8914                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8915    
8916                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8917    
8918                    boolean bindName = false;
8919    
8920                    if (name == null) {
8921                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8922                    }
8923                    else if (name.equals(StringPool.BLANK)) {
8924                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8925                    }
8926                    else {
8927                            bindName = true;
8928    
8929                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8930                    }
8931    
8932                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8933    
8934                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8935                                    AssetCategory.class.getName(),
8936                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8937    
8938                    Session session = null;
8939    
8940                    try {
8941                            session = openSession();
8942    
8943                            SQLQuery q = session.createSQLQuery(sql);
8944    
8945                            q.addScalar(COUNT_COLUMN_NAME,
8946                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8947    
8948                            QueryPos qPos = QueryPos.getInstance(q);
8949    
8950                            qPos.add(groupId);
8951    
8952                            if (bindName) {
8953                                    qPos.add(name);
8954                            }
8955    
8956                            qPos.add(vocabularyId);
8957    
8958                            Long count = (Long)q.uniqueResult();
8959    
8960                            return count.intValue();
8961                    }
8962                    catch (Exception e) {
8963                            throw processException(e);
8964                    }
8965                    finally {
8966                            closeSession(session);
8967                    }
8968            }
8969    
8970            /**
8971             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8972             *
8973             * @param groupId the group ID
8974             * @param name the name
8975             * @param vocabularyIds the vocabulary IDs
8976             * @return the number of matching asset categories that the user has permission to view
8977             * @throws SystemException if a system exception occurred
8978             */
8979            @Override
8980            public int filterCountByG_LikeN_V(long groupId, String name,
8981                    long[] vocabularyIds) throws SystemException {
8982                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8983                            return countByG_LikeN_V(groupId, name, vocabularyIds);
8984                    }
8985    
8986                    StringBundler query = new StringBundler();
8987    
8988                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8989    
8990                    boolean conjunctionable = false;
8991    
8992                    if (conjunctionable) {
8993                            query.append(WHERE_AND);
8994                    }
8995    
8996                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8997    
8998                    conjunctionable = true;
8999    
9000                    if (conjunctionable) {
9001                            query.append(WHERE_AND);
9002                    }
9003    
9004                    if (name == null) {
9005                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
9006                    }
9007                    else if (name.equals(StringPool.BLANK)) {
9008                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
9009                    }
9010                    else {
9011                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
9012                    }
9013    
9014                    conjunctionable = true;
9015    
9016                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9017                            if (conjunctionable) {
9018                                    query.append(WHERE_AND);
9019                            }
9020    
9021                            query.append(StringPool.OPEN_PARENTHESIS);
9022    
9023                            for (int i = 0; i < vocabularyIds.length; i++) {
9024                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
9025    
9026                                    if ((i + 1) < vocabularyIds.length) {
9027                                            query.append(WHERE_OR);
9028                                    }
9029                            }
9030    
9031                            query.append(StringPool.CLOSE_PARENTHESIS);
9032    
9033                            conjunctionable = true;
9034                    }
9035    
9036                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9037                                    AssetCategory.class.getName(),
9038                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9039    
9040                    Session session = null;
9041    
9042                    try {
9043                            session = openSession();
9044    
9045                            SQLQuery q = session.createSQLQuery(sql);
9046    
9047                            q.addScalar(COUNT_COLUMN_NAME,
9048                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9049    
9050                            QueryPos qPos = QueryPos.getInstance(q);
9051    
9052                            qPos.add(groupId);
9053    
9054                            if (name != null) {
9055                                    qPos.add(name);
9056                            }
9057    
9058                            if (vocabularyIds != null) {
9059                                    qPos.add(vocabularyIds);
9060                            }
9061    
9062                            Long count = (Long)q.uniqueResult();
9063    
9064                            return count.intValue();
9065                    }
9066                    catch (Exception e) {
9067                            throw processException(e);
9068                    }
9069                    finally {
9070                            closeSession(session);
9071                    }
9072            }
9073    
9074            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
9075            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
9076                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
9077            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
9078            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "assetCategory.name LIKE ? AND ";
9079            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
9080            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
9081                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
9082            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
9083                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
9084            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
9085                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
9086            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9087            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
9088                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
9089            public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9090                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9091                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
9092                            new String[] {
9093                                    Long.class.getName(), String.class.getName(),
9094                                    Long.class.getName()
9095                            },
9096                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9097                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9098                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9099            public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9100                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
9102                            new String[] {
9103                                    Long.class.getName(), String.class.getName(),
9104                                    Long.class.getName()
9105                            });
9106    
9107            /**
9108             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
9109             *
9110             * @param parentCategoryId the parent category ID
9111             * @param name the name
9112             * @param vocabularyId the vocabulary ID
9113             * @return the matching asset category
9114             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
9115             * @throws SystemException if a system exception occurred
9116             */
9117            @Override
9118            public AssetCategory findByP_N_V(long parentCategoryId, String name,
9119                    long vocabularyId) throws NoSuchCategoryException, SystemException {
9120                    AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
9121                                    vocabularyId);
9122    
9123                    if (assetCategory == null) {
9124                            StringBundler msg = new StringBundler(8);
9125    
9126                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9127    
9128                            msg.append("parentCategoryId=");
9129                            msg.append(parentCategoryId);
9130    
9131                            msg.append(", name=");
9132                            msg.append(name);
9133    
9134                            msg.append(", vocabularyId=");
9135                            msg.append(vocabularyId);
9136    
9137                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9138    
9139                            if (_log.isWarnEnabled()) {
9140                                    _log.warn(msg.toString());
9141                            }
9142    
9143                            throw new NoSuchCategoryException(msg.toString());
9144                    }
9145    
9146                    return assetCategory;
9147            }
9148    
9149            /**
9150             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
9151             *
9152             * @param parentCategoryId the parent category ID
9153             * @param name the name
9154             * @param vocabularyId the vocabulary ID
9155             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
9156             * @throws SystemException if a system exception occurred
9157             */
9158            @Override
9159            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9160                    long vocabularyId) throws SystemException {
9161                    return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
9162            }
9163    
9164            /**
9165             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
9166             *
9167             * @param parentCategoryId the parent category ID
9168             * @param name the name
9169             * @param vocabularyId the vocabulary ID
9170             * @param retrieveFromCache whether to use the finder cache
9171             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
9172             * @throws SystemException if a system exception occurred
9173             */
9174            @Override
9175            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9176                    long vocabularyId, boolean retrieveFromCache) throws SystemException {
9177                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9178    
9179                    Object result = null;
9180    
9181                    if (retrieveFromCache) {
9182                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
9183                                            finderArgs, this);
9184                    }
9185    
9186                    if (result instanceof AssetCategory) {
9187                            AssetCategory assetCategory = (AssetCategory)result;
9188    
9189                            if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
9190                                            !Validator.equals(name, assetCategory.getName()) ||
9191                                            (vocabularyId != assetCategory.getVocabularyId())) {
9192                                    result = null;
9193                            }
9194                    }
9195    
9196                    if (result == null) {
9197                            StringBundler query = new StringBundler(5);
9198    
9199                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9200    
9201                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9202    
9203                            boolean bindName = false;
9204    
9205                            if (name == null) {
9206                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9207                            }
9208                            else if (name.equals(StringPool.BLANK)) {
9209                                    query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9210                            }
9211                            else {
9212                                    bindName = true;
9213    
9214                                    query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9215                            }
9216    
9217                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9218    
9219                            String sql = query.toString();
9220    
9221                            Session session = null;
9222    
9223                            try {
9224                                    session = openSession();
9225    
9226                                    Query q = session.createQuery(sql);
9227    
9228                                    QueryPos qPos = QueryPos.getInstance(q);
9229    
9230                                    qPos.add(parentCategoryId);
9231    
9232                                    if (bindName) {
9233                                            qPos.add(name);
9234                                    }
9235    
9236                                    qPos.add(vocabularyId);
9237    
9238                                    List<AssetCategory> list = q.list();
9239    
9240                                    if (list.isEmpty()) {
9241                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9242                                                    finderArgs, list);
9243                                    }
9244                                    else {
9245                                            AssetCategory assetCategory = list.get(0);
9246    
9247                                            result = assetCategory;
9248    
9249                                            cacheResult(assetCategory);
9250    
9251                                            if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9252                                                            (assetCategory.getName() == null) ||
9253                                                            !assetCategory.getName().equals(name) ||
9254                                                            (assetCategory.getVocabularyId() != vocabularyId)) {
9255                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9256                                                            finderArgs, assetCategory);
9257                                            }
9258                                    }
9259                            }
9260                            catch (Exception e) {
9261                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9262                                            finderArgs);
9263    
9264                                    throw processException(e);
9265                            }
9266                            finally {
9267                                    closeSession(session);
9268                            }
9269                    }
9270    
9271                    if (result instanceof List<?>) {
9272                            return null;
9273                    }
9274                    else {
9275                            return (AssetCategory)result;
9276                    }
9277            }
9278    
9279            /**
9280             * Removes the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
9281             *
9282             * @param parentCategoryId the parent category ID
9283             * @param name the name
9284             * @param vocabularyId the vocabulary ID
9285             * @return the asset category that was removed
9286             * @throws SystemException if a system exception occurred
9287             */
9288            @Override
9289            public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9290                    long vocabularyId) throws NoSuchCategoryException, SystemException {
9291                    AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9292                                    vocabularyId);
9293    
9294                    return remove(assetCategory);
9295            }
9296    
9297            /**
9298             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9299             *
9300             * @param parentCategoryId the parent category ID
9301             * @param name the name
9302             * @param vocabularyId the vocabulary ID
9303             * @return the number of matching asset categories
9304             * @throws SystemException if a system exception occurred
9305             */
9306            @Override
9307            public int countByP_N_V(long parentCategoryId, String name,
9308                    long vocabularyId) throws SystemException {
9309                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9310    
9311                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9312    
9313                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9314                                    this);
9315    
9316                    if (count == null) {
9317                            StringBundler query = new StringBundler(4);
9318    
9319                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9320    
9321                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9322    
9323                            boolean bindName = false;
9324    
9325                            if (name == null) {
9326                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9327                            }
9328                            else if (name.equals(StringPool.BLANK)) {
9329                                    query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9330                            }
9331                            else {
9332                                    bindName = true;
9333    
9334                                    query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9335                            }
9336    
9337                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9338    
9339                            String sql = query.toString();
9340    
9341                            Session session = null;
9342    
9343                            try {
9344                                    session = openSession();
9345    
9346                                    Query q = session.createQuery(sql);
9347    
9348                                    QueryPos qPos = QueryPos.getInstance(q);
9349    
9350                                    qPos.add(parentCategoryId);
9351    
9352                                    if (bindName) {
9353                                            qPos.add(name);
9354                                    }
9355    
9356                                    qPos.add(vocabularyId);
9357    
9358                                    count = (Long)q.uniqueResult();
9359    
9360                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9361                            }
9362                            catch (Exception e) {
9363                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9364    
9365                                    throw processException(e);
9366                            }
9367                            finally {
9368                                    closeSession(session);
9369                            }
9370                    }
9371    
9372                    return count.intValue();
9373            }
9374    
9375            private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9376            private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9377            private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9378            private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9379            private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9380            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9381                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9382                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9383                            "findByG_P_N_V",
9384                            new String[] {
9385                                    Long.class.getName(), Long.class.getName(),
9386                                    String.class.getName(), Long.class.getName(),
9387                                    
9388                            Integer.class.getName(), Integer.class.getName(),
9389                                    OrderByComparator.class.getName()
9390                            });
9391            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9392                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9393                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9394                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9395                            "findByG_P_N_V",
9396                            new String[] {
9397                                    Long.class.getName(), Long.class.getName(),
9398                                    String.class.getName(), Long.class.getName()
9399                            },
9400                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9401                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9402                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9403                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9404            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9405                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9406                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9407                            new String[] {
9408                                    Long.class.getName(), Long.class.getName(),
9409                                    String.class.getName(), Long.class.getName()
9410                            });
9411    
9412            /**
9413             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9414             *
9415             * @param groupId the group ID
9416             * @param parentCategoryId the parent category ID
9417             * @param name the name
9418             * @param vocabularyId the vocabulary ID
9419             * @return the matching asset categories
9420             * @throws SystemException if a system exception occurred
9421             */
9422            @Override
9423            public List<AssetCategory> findByG_P_N_V(long groupId,
9424                    long parentCategoryId, String name, long vocabularyId)
9425                    throws SystemException {
9426                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9427                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9428            }
9429    
9430            /**
9431             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9432             *
9433             * <p>
9434             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9435             * </p>
9436             *
9437             * @param groupId the group ID
9438             * @param parentCategoryId the parent category ID
9439             * @param name the name
9440             * @param vocabularyId the vocabulary ID
9441             * @param start the lower bound of the range of asset categories
9442             * @param end the upper bound of the range of asset categories (not inclusive)
9443             * @return the range of matching asset categories
9444             * @throws SystemException if a system exception occurred
9445             */
9446            @Override
9447            public List<AssetCategory> findByG_P_N_V(long groupId,
9448                    long parentCategoryId, String name, long vocabularyId, int start,
9449                    int end) throws SystemException {
9450                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9451                            start, end, null);
9452            }
9453    
9454            /**
9455             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9456             *
9457             * <p>
9458             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9459             * </p>
9460             *
9461             * @param groupId the group ID
9462             * @param parentCategoryId the parent category ID
9463             * @param name the name
9464             * @param vocabularyId the vocabulary ID
9465             * @param start the lower bound of the range of asset categories
9466             * @param end the upper bound of the range of asset categories (not inclusive)
9467             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9468             * @return the ordered range of matching asset categories
9469             * @throws SystemException if a system exception occurred
9470             */
9471            @Override
9472            public List<AssetCategory> findByG_P_N_V(long groupId,
9473                    long parentCategoryId, String name, long vocabularyId, int start,
9474                    int end, OrderByComparator orderByComparator) throws SystemException {
9475                    boolean pagination = true;
9476                    FinderPath finderPath = null;
9477                    Object[] finderArgs = null;
9478    
9479                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9480                                    (orderByComparator == null)) {
9481                            pagination = false;
9482                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9483                            finderArgs = new Object[] {
9484                                            groupId, parentCategoryId, name, vocabularyId
9485                                    };
9486                    }
9487                    else {
9488                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9489                            finderArgs = new Object[] {
9490                                            groupId, parentCategoryId, name, vocabularyId,
9491                                            
9492                                            start, end, orderByComparator
9493                                    };
9494                    }
9495    
9496                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9497                                    finderArgs, this);
9498    
9499                    if ((list != null) && !list.isEmpty()) {
9500                            for (AssetCategory assetCategory : list) {
9501                                    if ((groupId != assetCategory.getGroupId()) ||
9502                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
9503                                                    !Validator.equals(name, assetCategory.getName()) ||
9504                                                    (vocabularyId != assetCategory.getVocabularyId())) {
9505                                            list = null;
9506    
9507                                            break;
9508                                    }
9509                            }
9510                    }
9511    
9512                    if (list == null) {
9513                            StringBundler query = null;
9514    
9515                            if (orderByComparator != null) {
9516                                    query = new StringBundler(6 +
9517                                                    (orderByComparator.getOrderByFields().length * 3));
9518                            }
9519                            else {
9520                                    query = new StringBundler(6);
9521                            }
9522    
9523                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9524    
9525                            query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9526    
9527                            query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9528    
9529                            boolean bindName = false;
9530    
9531                            if (name == null) {
9532                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9533                            }
9534                            else if (name.equals(StringPool.BLANK)) {
9535                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9536                            }
9537                            else {
9538                                    bindName = true;
9539    
9540                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9541                            }
9542    
9543                            query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9544    
9545                            if (orderByComparator != null) {
9546                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9547                                            orderByComparator);
9548                            }
9549                            else
9550                             if (pagination) {
9551                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9552                            }
9553    
9554                            String sql = query.toString();
9555    
9556                            Session session = null;
9557    
9558                            try {
9559                                    session = openSession();
9560    
9561                                    Query q = session.createQuery(sql);
9562    
9563                                    QueryPos qPos = QueryPos.getInstance(q);
9564    
9565                                    qPos.add(groupId);
9566    
9567                                    qPos.add(parentCategoryId);
9568    
9569                                    if (bindName) {
9570                                            qPos.add(name);
9571                                    }
9572    
9573                                    qPos.add(vocabularyId);
9574    
9575                                    if (!pagination) {
9576                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9577                                                            start, end, false);
9578    
9579                                            Collections.sort(list);
9580    
9581                                            list = new UnmodifiableList<AssetCategory>(list);
9582                                    }
9583                                    else {
9584                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9585                                                            start, end);
9586                                    }
9587    
9588                                    cacheResult(list);
9589    
9590                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
9591                            }
9592                            catch (Exception e) {
9593                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9594    
9595                                    throw processException(e);
9596                            }
9597                            finally {
9598                                    closeSession(session);
9599                            }
9600                    }
9601    
9602                    return list;
9603            }
9604    
9605            /**
9606             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9607             *
9608             * @param groupId the group ID
9609             * @param parentCategoryId the parent category ID
9610             * @param name the name
9611             * @param vocabularyId the vocabulary ID
9612             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9613             * @return the first matching asset category
9614             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
9615             * @throws SystemException if a system exception occurred
9616             */
9617            @Override
9618            public AssetCategory findByG_P_N_V_First(long groupId,
9619                    long parentCategoryId, String name, long vocabularyId,
9620                    OrderByComparator orderByComparator)
9621                    throws NoSuchCategoryException, SystemException {
9622                    AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
9623                                    parentCategoryId, name, vocabularyId, orderByComparator);
9624    
9625                    if (assetCategory != null) {
9626                            return assetCategory;
9627                    }
9628    
9629                    StringBundler msg = new StringBundler(10);
9630    
9631                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9632    
9633                    msg.append("groupId=");
9634                    msg.append(groupId);
9635    
9636                    msg.append(", parentCategoryId=");
9637                    msg.append(parentCategoryId);
9638    
9639                    msg.append(", name=");
9640                    msg.append(name);
9641    
9642                    msg.append(", vocabularyId=");
9643                    msg.append(vocabularyId);
9644    
9645                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9646    
9647                    throw new NoSuchCategoryException(msg.toString());
9648            }
9649    
9650            /**
9651             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9652             *
9653             * @param groupId the group ID
9654             * @param parentCategoryId the parent category ID
9655             * @param name the name
9656             * @param vocabularyId the vocabulary ID
9657             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9658             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
9659             * @throws SystemException if a system exception occurred
9660             */
9661            @Override
9662            public AssetCategory fetchByG_P_N_V_First(long groupId,
9663                    long parentCategoryId, String name, long vocabularyId,
9664                    OrderByComparator orderByComparator) throws SystemException {
9665                    List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9666                                    name, vocabularyId, 0, 1, orderByComparator);
9667    
9668                    if (!list.isEmpty()) {
9669                            return list.get(0);
9670                    }
9671    
9672                    return null;
9673            }
9674    
9675            /**
9676             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9677             *
9678             * @param groupId the group ID
9679             * @param parentCategoryId the parent category ID
9680             * @param name the name
9681             * @param vocabularyId the vocabulary ID
9682             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9683             * @return the last matching asset category
9684             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
9685             * @throws SystemException if a system exception occurred
9686             */
9687            @Override
9688            public AssetCategory findByG_P_N_V_Last(long groupId,
9689                    long parentCategoryId, String name, long vocabularyId,
9690                    OrderByComparator orderByComparator)
9691                    throws NoSuchCategoryException, SystemException {
9692                    AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
9693                                    parentCategoryId, name, vocabularyId, orderByComparator);
9694    
9695                    if (assetCategory != null) {
9696                            return assetCategory;
9697                    }
9698    
9699                    StringBundler msg = new StringBundler(10);
9700    
9701                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9702    
9703                    msg.append("groupId=");
9704                    msg.append(groupId);
9705    
9706                    msg.append(", parentCategoryId=");
9707                    msg.append(parentCategoryId);
9708    
9709                    msg.append(", name=");
9710                    msg.append(name);
9711    
9712                    msg.append(", vocabularyId=");
9713                    msg.append(vocabularyId);
9714    
9715                    msg.append(StringPool.CLOSE_CURLY_BRACE);
9716    
9717                    throw new NoSuchCategoryException(msg.toString());
9718            }
9719    
9720            /**
9721             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9722             *
9723             * @param groupId the group ID
9724             * @param parentCategoryId the parent category ID
9725             * @param name the name
9726             * @param vocabularyId the vocabulary ID
9727             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9728             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
9729             * @throws SystemException if a system exception occurred
9730             */
9731            @Override
9732            public AssetCategory fetchByG_P_N_V_Last(long groupId,
9733                    long parentCategoryId, String name, long vocabularyId,
9734                    OrderByComparator orderByComparator) throws SystemException {
9735                    int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
9736    
9737                    if (count == 0) {
9738                            return null;
9739                    }
9740    
9741                    List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
9742                                    name, vocabularyId, count - 1, count, orderByComparator);
9743    
9744                    if (!list.isEmpty()) {
9745                            return list.get(0);
9746                    }
9747    
9748                    return null;
9749            }
9750    
9751            /**
9752             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9753             *
9754             * @param categoryId the primary key of the current asset category
9755             * @param groupId the group ID
9756             * @param parentCategoryId the parent category ID
9757             * @param name the name
9758             * @param vocabularyId the vocabulary ID
9759             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
9760             * @return the previous, current, and next asset category
9761             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
9762             * @throws SystemException if a system exception occurred
9763             */
9764            @Override
9765            public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
9766                    long groupId, long parentCategoryId, String name, long vocabularyId,
9767                    OrderByComparator orderByComparator)
9768                    throws NoSuchCategoryException, SystemException {
9769                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
9770    
9771                    Session session = null;
9772    
9773                    try {
9774                            session = openSession();
9775    
9776                            AssetCategory[] array = new AssetCategoryImpl[3];
9777    
9778                            array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9779                                            groupId, parentCategoryId, name, vocabularyId,
9780                                            orderByComparator, true);
9781    
9782                            array[1] = assetCategory;
9783    
9784                            array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
9785                                            groupId, parentCategoryId, name, vocabularyId,
9786                                            orderByComparator, false);
9787    
9788                            return array;
9789                    }
9790                    catch (Exception e) {
9791                            throw processException(e);
9792                    }
9793                    finally {
9794                            closeSession(session);
9795                    }
9796            }
9797    
9798            protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
9799                    AssetCategory assetCategory, long groupId, long parentCategoryId,
9800                    String name, long vocabularyId, OrderByComparator orderByComparator,
9801                    boolean previous) {
9802                    StringBundler query = null;
9803    
9804                    if (orderByComparator != null) {
9805                            query = new StringBundler(6 +
9806                                            (orderByComparator.getOrderByFields().length * 6));
9807                    }
9808                    else {
9809                            query = new StringBundler(3);
9810                    }
9811    
9812                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9813    
9814                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9815    
9816                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9817    
9818                    boolean bindName = false;
9819    
9820                    if (name == null) {
9821                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9822                    }
9823                    else if (name.equals(StringPool.BLANK)) {
9824                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9825                    }
9826                    else {
9827                            bindName = true;
9828    
9829                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9830                    }
9831    
9832                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9833    
9834                    if (orderByComparator != null) {
9835                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
9836    
9837                            if (orderByConditionFields.length > 0) {
9838                                    query.append(WHERE_AND);
9839                            }
9840    
9841                            for (int i = 0; i < orderByConditionFields.length; i++) {
9842                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9843                                    query.append(orderByConditionFields[i]);
9844    
9845                                    if ((i + 1) < orderByConditionFields.length) {
9846                                            if (orderByComparator.isAscending() ^ previous) {
9847                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
9848                                            }
9849                                            else {
9850                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
9851                                            }
9852                                    }
9853                                    else {
9854                                            if (orderByComparator.isAscending() ^ previous) {
9855                                                    query.append(WHERE_GREATER_THAN);
9856                                            }
9857                                            else {
9858                                                    query.append(WHERE_LESSER_THAN);
9859                                            }
9860                                    }
9861                            }
9862    
9863                            query.append(ORDER_BY_CLAUSE);
9864    
9865                            String[] orderByFields = orderByComparator.getOrderByFields();
9866    
9867                            for (int i = 0; i < orderByFields.length; i++) {
9868                                    query.append(_ORDER_BY_ENTITY_ALIAS);
9869                                    query.append(orderByFields[i]);
9870    
9871                                    if ((i + 1) < orderByFields.length) {
9872                                            if (orderByComparator.isAscending() ^ previous) {
9873                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
9874                                            }
9875                                            else {
9876                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
9877                                            }
9878                                    }
9879                                    else {
9880                                            if (orderByComparator.isAscending() ^ previous) {
9881                                                    query.append(ORDER_BY_ASC);
9882                                            }
9883                                            else {
9884                                                    query.append(ORDER_BY_DESC);
9885                                            }
9886                                    }
9887                            }
9888                    }
9889                    else {
9890                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9891                    }
9892    
9893                    String sql = query.toString();
9894    
9895                    Query q = session.createQuery(sql);
9896    
9897                    q.setFirstResult(0);
9898                    q.setMaxResults(2);
9899    
9900                    QueryPos qPos = QueryPos.getInstance(q);
9901    
9902                    qPos.add(groupId);
9903    
9904                    qPos.add(parentCategoryId);
9905    
9906                    if (bindName) {
9907                            qPos.add(name);
9908                    }
9909    
9910                    qPos.add(vocabularyId);
9911    
9912                    if (orderByComparator != null) {
9913                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
9914    
9915                            for (Object value : values) {
9916                                    qPos.add(value);
9917                            }
9918                    }
9919    
9920                    List<AssetCategory> list = q.list();
9921    
9922                    if (list.size() == 2) {
9923                            return list.get(1);
9924                    }
9925                    else {
9926                            return null;
9927                    }
9928            }
9929    
9930            /**
9931             * Returns all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9932             *
9933             * @param groupId the group ID
9934             * @param parentCategoryId the parent category ID
9935             * @param name the name
9936             * @param vocabularyId the vocabulary ID
9937             * @return the matching asset categories that the user has permission to view
9938             * @throws SystemException if a system exception occurred
9939             */
9940            @Override
9941            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9942                    long parentCategoryId, String name, long vocabularyId)
9943                    throws SystemException {
9944                    return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9945                            vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9946            }
9947    
9948            /**
9949             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9950             *
9951             * <p>
9952             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9953             * </p>
9954             *
9955             * @param groupId the group ID
9956             * @param parentCategoryId the parent category ID
9957             * @param name the name
9958             * @param vocabularyId the vocabulary ID
9959             * @param start the lower bound of the range of asset categories
9960             * @param end the upper bound of the range of asset categories (not inclusive)
9961             * @return the range of matching asset categories that the user has permission to view
9962             * @throws SystemException if a system exception occurred
9963             */
9964            @Override
9965            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9966                    long parentCategoryId, String name, long vocabularyId, int start,
9967                    int end) throws SystemException {
9968                    return filterFindByG_P_N_V(groupId, parentCategoryId, name,
9969                            vocabularyId, start, end, null);
9970            }
9971    
9972            /**
9973             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9974             *
9975             * <p>
9976             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
9977             * </p>
9978             *
9979             * @param groupId the group ID
9980             * @param parentCategoryId the parent category ID
9981             * @param name the name
9982             * @param vocabularyId the vocabulary ID
9983             * @param start the lower bound of the range of asset categories
9984             * @param end the upper bound of the range of asset categories (not inclusive)
9985             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9986             * @return the ordered range of matching asset categories that the user has permission to view
9987             * @throws SystemException if a system exception occurred
9988             */
9989            @Override
9990            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
9991                    long parentCategoryId, String name, long vocabularyId, int start,
9992                    int end, OrderByComparator orderByComparator) throws SystemException {
9993                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9994                            return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9995                                    start, end, orderByComparator);
9996                    }
9997    
9998                    StringBundler query = null;
9999    
10000                    if (orderByComparator != null) {
10001                            query = new StringBundler(6 +
10002                                            (orderByComparator.getOrderByFields().length * 3));
10003                    }
10004                    else {
10005                            query = new StringBundler(6);
10006                    }
10007    
10008                    if (getDB().isSupportsInlineDistinct()) {
10009                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10010                    }
10011                    else {
10012                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10013                    }
10014    
10015                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10016    
10017                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10018    
10019                    boolean bindName = false;
10020    
10021                    if (name == null) {
10022                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10023                    }
10024                    else if (name.equals(StringPool.BLANK)) {
10025                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10026                    }
10027                    else {
10028                            bindName = true;
10029    
10030                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10031                    }
10032    
10033                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10034    
10035                    if (!getDB().isSupportsInlineDistinct()) {
10036                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10037                    }
10038    
10039                    if (orderByComparator != null) {
10040                            if (getDB().isSupportsInlineDistinct()) {
10041                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
10042                                            orderByComparator, true);
10043                            }
10044                            else {
10045                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
10046                                            orderByComparator, true);
10047                            }
10048                    }
10049                    else {
10050                            if (getDB().isSupportsInlineDistinct()) {
10051                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10052                            }
10053                            else {
10054                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10055                            }
10056                    }
10057    
10058                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10059                                    AssetCategory.class.getName(),
10060                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10061    
10062                    Session session = null;
10063    
10064                    try {
10065                            session = openSession();
10066    
10067                            SQLQuery q = session.createSQLQuery(sql);
10068    
10069                            if (getDB().isSupportsInlineDistinct()) {
10070                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10071                            }
10072                            else {
10073                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10074                            }
10075    
10076                            QueryPos qPos = QueryPos.getInstance(q);
10077    
10078                            qPos.add(groupId);
10079    
10080                            qPos.add(parentCategoryId);
10081    
10082                            if (bindName) {
10083                                    qPos.add(name);
10084                            }
10085    
10086                            qPos.add(vocabularyId);
10087    
10088                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
10089                                    end);
10090                    }
10091                    catch (Exception e) {
10092                            throw processException(e);
10093                    }
10094                    finally {
10095                            closeSession(session);
10096                    }
10097            }
10098    
10099            /**
10100             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10101             *
10102             * @param categoryId the primary key of the current asset category
10103             * @param groupId the group ID
10104             * @param parentCategoryId the parent category ID
10105             * @param name the name
10106             * @param vocabularyId the vocabulary ID
10107             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
10108             * @return the previous, current, and next asset category
10109             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
10110             * @throws SystemException if a system exception occurred
10111             */
10112            @Override
10113            public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
10114                    long groupId, long parentCategoryId, String name, long vocabularyId,
10115                    OrderByComparator orderByComparator)
10116                    throws NoSuchCategoryException, SystemException {
10117                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10118                            return findByG_P_N_V_PrevAndNext(categoryId, groupId,
10119                                    parentCategoryId, name, vocabularyId, orderByComparator);
10120                    }
10121    
10122                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
10123    
10124                    Session session = null;
10125    
10126                    try {
10127                            session = openSession();
10128    
10129                            AssetCategory[] array = new AssetCategoryImpl[3];
10130    
10131                            array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10132                                            groupId, parentCategoryId, name, vocabularyId,
10133                                            orderByComparator, true);
10134    
10135                            array[1] = assetCategory;
10136    
10137                            array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
10138                                            groupId, parentCategoryId, name, vocabularyId,
10139                                            orderByComparator, false);
10140    
10141                            return array;
10142                    }
10143                    catch (Exception e) {
10144                            throw processException(e);
10145                    }
10146                    finally {
10147                            closeSession(session);
10148                    }
10149            }
10150    
10151            protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
10152                    AssetCategory assetCategory, long groupId, long parentCategoryId,
10153                    String name, long vocabularyId, OrderByComparator orderByComparator,
10154                    boolean previous) {
10155                    StringBundler query = null;
10156    
10157                    if (orderByComparator != null) {
10158                            query = new StringBundler(6 +
10159                                            (orderByComparator.getOrderByFields().length * 6));
10160                    }
10161                    else {
10162                            query = new StringBundler(3);
10163                    }
10164    
10165                    if (getDB().isSupportsInlineDistinct()) {
10166                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
10167                    }
10168                    else {
10169                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
10170                    }
10171    
10172                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10173    
10174                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10175    
10176                    boolean bindName = false;
10177    
10178                    if (name == null) {
10179                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10180                    }
10181                    else if (name.equals(StringPool.BLANK)) {
10182                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10183                    }
10184                    else {
10185                            bindName = true;
10186    
10187                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10188                    }
10189    
10190                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10191    
10192                    if (!getDB().isSupportsInlineDistinct()) {
10193                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
10194                    }
10195    
10196                    if (orderByComparator != null) {
10197                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
10198    
10199                            if (orderByConditionFields.length > 0) {
10200                                    query.append(WHERE_AND);
10201                            }
10202    
10203                            for (int i = 0; i < orderByConditionFields.length; i++) {
10204                                    if (getDB().isSupportsInlineDistinct()) {
10205                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10206                                    }
10207                                    else {
10208                                            query.append(_ORDER_BY_ENTITY_TABLE);
10209                                    }
10210    
10211                                    query.append(orderByConditionFields[i]);
10212    
10213                                    if ((i + 1) < orderByConditionFields.length) {
10214                                            if (orderByComparator.isAscending() ^ previous) {
10215                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
10216                                            }
10217                                            else {
10218                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
10219                                            }
10220                                    }
10221                                    else {
10222                                            if (orderByComparator.isAscending() ^ previous) {
10223                                                    query.append(WHERE_GREATER_THAN);
10224                                            }
10225                                            else {
10226                                                    query.append(WHERE_LESSER_THAN);
10227                                            }
10228                                    }
10229                            }
10230    
10231                            query.append(ORDER_BY_CLAUSE);
10232    
10233                            String[] orderByFields = orderByComparator.getOrderByFields();
10234    
10235                            for (int i = 0; i < orderByFields.length; i++) {
10236                                    if (getDB().isSupportsInlineDistinct()) {
10237                                            query.append(_ORDER_BY_ENTITY_ALIAS);
10238                                    }
10239                                    else {
10240                                            query.append(_ORDER_BY_ENTITY_TABLE);
10241                                    }
10242    
10243                                    query.append(orderByFields[i]);
10244    
10245                                    if ((i + 1) < orderByFields.length) {
10246                                            if (orderByComparator.isAscending() ^ previous) {
10247                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
10248                                            }
10249                                            else {
10250                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
10251                                            }
10252                                    }
10253                                    else {
10254                                            if (orderByComparator.isAscending() ^ previous) {
10255                                                    query.append(ORDER_BY_ASC);
10256                                            }
10257                                            else {
10258                                                    query.append(ORDER_BY_DESC);
10259                                            }
10260                                    }
10261                            }
10262                    }
10263                    else {
10264                            if (getDB().isSupportsInlineDistinct()) {
10265                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
10266                            }
10267                            else {
10268                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
10269                            }
10270                    }
10271    
10272                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10273                                    AssetCategory.class.getName(),
10274                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10275    
10276                    SQLQuery q = session.createSQLQuery(sql);
10277    
10278                    q.setFirstResult(0);
10279                    q.setMaxResults(2);
10280    
10281                    if (getDB().isSupportsInlineDistinct()) {
10282                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
10283                    }
10284                    else {
10285                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
10286                    }
10287    
10288                    QueryPos qPos = QueryPos.getInstance(q);
10289    
10290                    qPos.add(groupId);
10291    
10292                    qPos.add(parentCategoryId);
10293    
10294                    if (bindName) {
10295                            qPos.add(name);
10296                    }
10297    
10298                    qPos.add(vocabularyId);
10299    
10300                    if (orderByComparator != null) {
10301                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
10302    
10303                            for (Object value : values) {
10304                                    qPos.add(value);
10305                            }
10306                    }
10307    
10308                    List<AssetCategory> list = q.list();
10309    
10310                    if (list.size() == 2) {
10311                            return list.get(1);
10312                    }
10313                    else {
10314                            return null;
10315                    }
10316            }
10317    
10318            /**
10319             * Removes all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
10320             *
10321             * @param groupId the group ID
10322             * @param parentCategoryId the parent category ID
10323             * @param name the name
10324             * @param vocabularyId the vocabulary ID
10325             * @throws SystemException if a system exception occurred
10326             */
10327            @Override
10328            public void removeByG_P_N_V(long groupId, long parentCategoryId,
10329                    String name, long vocabularyId) throws SystemException {
10330                    for (AssetCategory assetCategory : findByG_P_N_V(groupId,
10331                                    parentCategoryId, name, vocabularyId, QueryUtil.ALL_POS,
10332                                    QueryUtil.ALL_POS, null)) {
10333                            remove(assetCategory);
10334                    }
10335            }
10336    
10337            /**
10338             * Returns the number of asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10339             *
10340             * @param groupId the group ID
10341             * @param parentCategoryId the parent category ID
10342             * @param name the name
10343             * @param vocabularyId the vocabulary ID
10344             * @return the number of matching asset categories
10345             * @throws SystemException if a system exception occurred
10346             */
10347            @Override
10348            public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10349                    long vocabularyId) throws SystemException {
10350                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_N_V;
10351    
10352                    Object[] finderArgs = new Object[] {
10353                                    groupId, parentCategoryId, name, vocabularyId
10354                            };
10355    
10356                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
10357                                    this);
10358    
10359                    if (count == null) {
10360                            StringBundler query = new StringBundler(5);
10361    
10362                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10363    
10364                            query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10365    
10366                            query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10367    
10368                            boolean bindName = false;
10369    
10370                            if (name == null) {
10371                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10372                            }
10373                            else if (name.equals(StringPool.BLANK)) {
10374                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10375                            }
10376                            else {
10377                                    bindName = true;
10378    
10379                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10380                            }
10381    
10382                            query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10383    
10384                            String sql = query.toString();
10385    
10386                            Session session = null;
10387    
10388                            try {
10389                                    session = openSession();
10390    
10391                                    Query q = session.createQuery(sql);
10392    
10393                                    QueryPos qPos = QueryPos.getInstance(q);
10394    
10395                                    qPos.add(groupId);
10396    
10397                                    qPos.add(parentCategoryId);
10398    
10399                                    if (bindName) {
10400                                            qPos.add(name);
10401                                    }
10402    
10403                                    qPos.add(vocabularyId);
10404    
10405                                    count = (Long)q.uniqueResult();
10406    
10407                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
10408                            }
10409                            catch (Exception e) {
10410                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
10411    
10412                                    throw processException(e);
10413                            }
10414                            finally {
10415                                    closeSession(session);
10416                            }
10417                    }
10418    
10419                    return count.intValue();
10420            }
10421    
10422            /**
10423             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10424             *
10425             * @param groupId the group ID
10426             * @param parentCategoryId the parent category ID
10427             * @param name the name
10428             * @param vocabularyId the vocabulary ID
10429             * @return the number of matching asset categories that the user has permission to view
10430             * @throws SystemException if a system exception occurred
10431             */
10432            @Override
10433            public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10434                    String name, long vocabularyId) throws SystemException {
10435                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10436                            return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10437                    }
10438    
10439                    StringBundler query = new StringBundler(5);
10440    
10441                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10442    
10443                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10444    
10445                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10446    
10447                    boolean bindName = false;
10448    
10449                    if (name == null) {
10450                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10451                    }
10452                    else if (name.equals(StringPool.BLANK)) {
10453                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10454                    }
10455                    else {
10456                            bindName = true;
10457    
10458                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10459                    }
10460    
10461                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10462    
10463                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10464                                    AssetCategory.class.getName(),
10465                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10466    
10467                    Session session = null;
10468    
10469                    try {
10470                            session = openSession();
10471    
10472                            SQLQuery q = session.createSQLQuery(sql);
10473    
10474                            q.addScalar(COUNT_COLUMN_NAME,
10475                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10476    
10477                            QueryPos qPos = QueryPos.getInstance(q);
10478    
10479                            qPos.add(groupId);
10480    
10481                            qPos.add(parentCategoryId);
10482    
10483                            if (bindName) {
10484                                    qPos.add(name);
10485                            }
10486    
10487                            qPos.add(vocabularyId);
10488    
10489                            Long count = (Long)q.uniqueResult();
10490    
10491                            return count.intValue();
10492                    }
10493                    catch (Exception e) {
10494                            throw processException(e);
10495                    }
10496                    finally {
10497                            closeSession(session);
10498                    }
10499            }
10500    
10501            private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
10502            private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
10503            private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
10504            private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
10505            private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
10506            private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
10507    
10508            /**
10509             * Caches the asset category in the entity cache if it is enabled.
10510             *
10511             * @param assetCategory the asset category
10512             */
10513            @Override
10514            public void cacheResult(AssetCategory assetCategory) {
10515                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10516                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
10517                            assetCategory);
10518    
10519                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
10520                            new Object[] { assetCategory.getUuid(), assetCategory.getGroupId() },
10521                            assetCategory);
10522    
10523                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
10524                            new Object[] {
10525                                    assetCategory.getParentCategoryId(), assetCategory.getName(),
10526                                    assetCategory.getVocabularyId()
10527                            }, assetCategory);
10528    
10529                    assetCategory.resetOriginalValues();
10530            }
10531    
10532            /**
10533             * Caches the asset categories in the entity cache if it is enabled.
10534             *
10535             * @param assetCategories the asset categories
10536             */
10537            @Override
10538            public void cacheResult(List<AssetCategory> assetCategories) {
10539                    for (AssetCategory assetCategory : assetCategories) {
10540                            if (EntityCacheUtil.getResult(
10541                                                    AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10542                                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
10543                                    cacheResult(assetCategory);
10544                            }
10545                            else {
10546                                    assetCategory.resetOriginalValues();
10547                            }
10548                    }
10549            }
10550    
10551            /**
10552             * Clears the cache for all asset categories.
10553             *
10554             * <p>
10555             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10556             * </p>
10557             */
10558            @Override
10559            public void clearCache() {
10560                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
10561                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10562                    }
10563    
10564                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10565    
10566                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10567                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10568                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10569            }
10570    
10571            /**
10572             * Clears the cache for the asset category.
10573             *
10574             * <p>
10575             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
10576             * </p>
10577             */
10578            @Override
10579            public void clearCache(AssetCategory assetCategory) {
10580                    EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10581                            AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10582    
10583                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10584                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10585    
10586                    clearUniqueFindersCache(assetCategory);
10587            }
10588    
10589            @Override
10590            public void clearCache(List<AssetCategory> assetCategories) {
10591                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10592                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10593    
10594                    for (AssetCategory assetCategory : assetCategories) {
10595                            EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
10596                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey());
10597    
10598                            clearUniqueFindersCache(assetCategory);
10599                    }
10600            }
10601    
10602            protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
10603                    if (assetCategory.isNew()) {
10604                            Object[] args = new Object[] {
10605                                            assetCategory.getUuid(), assetCategory.getGroupId()
10606                                    };
10607    
10608                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10609                                    Long.valueOf(1));
10610                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10611                                    assetCategory);
10612    
10613                            args = new Object[] {
10614                                            assetCategory.getParentCategoryId(), assetCategory.getName(),
10615                                            assetCategory.getVocabularyId()
10616                                    };
10617    
10618                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10619                                    Long.valueOf(1));
10620                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10621                                    assetCategory);
10622                    }
10623                    else {
10624                            AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10625    
10626                            if ((assetCategoryModelImpl.getColumnBitmask() &
10627                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10628                                    Object[] args = new Object[] {
10629                                                    assetCategory.getUuid(), assetCategory.getGroupId()
10630                                            };
10631    
10632                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
10633                                            Long.valueOf(1));
10634                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
10635                                            assetCategory);
10636                            }
10637    
10638                            if ((assetCategoryModelImpl.getColumnBitmask() &
10639                                            FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10640                                    Object[] args = new Object[] {
10641                                                    assetCategory.getParentCategoryId(),
10642                                                    assetCategory.getName(), assetCategory.getVocabularyId()
10643                                            };
10644    
10645                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
10646                                            Long.valueOf(1));
10647                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
10648                                            assetCategory);
10649                            }
10650                    }
10651            }
10652    
10653            protected void clearUniqueFindersCache(AssetCategory assetCategory) {
10654                    AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10655    
10656                    Object[] args = new Object[] {
10657                                    assetCategory.getUuid(), assetCategory.getGroupId()
10658                            };
10659    
10660                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10661                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10662    
10663                    if ((assetCategoryModelImpl.getColumnBitmask() &
10664                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
10665                            args = new Object[] {
10666                                            assetCategoryModelImpl.getOriginalUuid(),
10667                                            assetCategoryModelImpl.getOriginalGroupId()
10668                                    };
10669    
10670                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
10671                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
10672                    }
10673    
10674                    args = new Object[] {
10675                                    assetCategory.getParentCategoryId(), assetCategory.getName(),
10676                                    assetCategory.getVocabularyId()
10677                            };
10678    
10679                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10680                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10681    
10682                    if ((assetCategoryModelImpl.getColumnBitmask() &
10683                                    FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
10684                            args = new Object[] {
10685                                            assetCategoryModelImpl.getOriginalParentCategoryId(),
10686                                            assetCategoryModelImpl.getOriginalName(),
10687                                            assetCategoryModelImpl.getOriginalVocabularyId()
10688                                    };
10689    
10690                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
10691                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
10692                    }
10693            }
10694    
10695            /**
10696             * Creates a new asset category with the primary key. Does not add the asset category to the database.
10697             *
10698             * @param categoryId the primary key for the new asset category
10699             * @return the new asset category
10700             */
10701            @Override
10702            public AssetCategory create(long categoryId) {
10703                    AssetCategory assetCategory = new AssetCategoryImpl();
10704    
10705                    assetCategory.setNew(true);
10706                    assetCategory.setPrimaryKey(categoryId);
10707    
10708                    String uuid = PortalUUIDUtil.generate();
10709    
10710                    assetCategory.setUuid(uuid);
10711    
10712                    return assetCategory;
10713            }
10714    
10715            /**
10716             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
10717             *
10718             * @param categoryId the primary key of the asset category
10719             * @return the asset category that was removed
10720             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
10721             * @throws SystemException if a system exception occurred
10722             */
10723            @Override
10724            public AssetCategory remove(long categoryId)
10725                    throws NoSuchCategoryException, SystemException {
10726                    return remove((Serializable)categoryId);
10727            }
10728    
10729            /**
10730             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
10731             *
10732             * @param primaryKey the primary key of the asset category
10733             * @return the asset category that was removed
10734             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
10735             * @throws SystemException if a system exception occurred
10736             */
10737            @Override
10738            public AssetCategory remove(Serializable primaryKey)
10739                    throws NoSuchCategoryException, SystemException {
10740                    Session session = null;
10741    
10742                    try {
10743                            session = openSession();
10744    
10745                            AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10746                                            primaryKey);
10747    
10748                            if (assetCategory == null) {
10749                                    if (_log.isWarnEnabled()) {
10750                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
10751                                    }
10752    
10753                                    throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
10754                                            primaryKey);
10755                            }
10756    
10757                            return remove(assetCategory);
10758                    }
10759                    catch (NoSuchCategoryException nsee) {
10760                            throw nsee;
10761                    }
10762                    catch (Exception e) {
10763                            throw processException(e);
10764                    }
10765                    finally {
10766                            closeSession(session);
10767                    }
10768            }
10769    
10770            @Override
10771            protected AssetCategory removeImpl(AssetCategory assetCategory)
10772                    throws SystemException {
10773                    assetCategory = toUnwrappedModel(assetCategory);
10774    
10775                    try {
10776                            clearAssetEntries.clear(assetCategory.getPrimaryKey());
10777                    }
10778                    catch (Exception e) {
10779                            throw processException(e);
10780                    }
10781                    finally {
10782                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10783                    }
10784    
10785                    shrinkTree(assetCategory);
10786    
10787                    Session session = null;
10788    
10789                    try {
10790                            session = openSession();
10791    
10792                            if (!session.contains(assetCategory)) {
10793                                    assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
10794                                                    assetCategory.getPrimaryKeyObj());
10795                            }
10796    
10797                            if (assetCategory != null) {
10798                                    session.delete(assetCategory);
10799                            }
10800                    }
10801                    catch (Exception e) {
10802                            throw processException(e);
10803                    }
10804                    finally {
10805                            closeSession(session);
10806                    }
10807    
10808                    if (assetCategory != null) {
10809                            clearCache(assetCategory);
10810                    }
10811    
10812                    return assetCategory;
10813            }
10814    
10815            @Override
10816            public AssetCategory updateImpl(
10817                    com.liferay.portlet.asset.model.AssetCategory assetCategory)
10818                    throws SystemException {
10819                    assetCategory = toUnwrappedModel(assetCategory);
10820    
10821                    boolean isNew = assetCategory.isNew();
10822    
10823                    AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
10824    
10825                    if (Validator.isNull(assetCategory.getUuid())) {
10826                            String uuid = PortalUUIDUtil.generate();
10827    
10828                            assetCategory.setUuid(uuid);
10829                    }
10830    
10831                    if (isNew) {
10832                            expandTree(assetCategory, null);
10833                    }
10834                    else {
10835                            if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
10836                                    List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
10837    
10838                                    shrinkTree(assetCategory);
10839                                    expandTree(assetCategory, childrenCategoryIds);
10840                            }
10841                    }
10842    
10843                    Session session = null;
10844    
10845                    try {
10846                            session = openSession();
10847    
10848                            if (assetCategory.isNew()) {
10849                                    session.save(assetCategory);
10850    
10851                                    assetCategory.setNew(false);
10852                            }
10853                            else {
10854                                    session.merge(assetCategory);
10855                            }
10856                    }
10857                    catch (Exception e) {
10858                            throw processException(e);
10859                    }
10860                    finally {
10861                            closeSession(session);
10862                    }
10863    
10864                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
10865    
10866                    if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
10867                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10868                    }
10869    
10870                    else {
10871                            if ((assetCategoryModelImpl.getColumnBitmask() &
10872                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
10873                                    Object[] args = new Object[] {
10874                                                    assetCategoryModelImpl.getOriginalUuid()
10875                                            };
10876    
10877                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10878                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10879                                            args);
10880    
10881                                    args = new Object[] { assetCategoryModelImpl.getUuid() };
10882    
10883                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
10884                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
10885                                            args);
10886                            }
10887    
10888                            if ((assetCategoryModelImpl.getColumnBitmask() &
10889                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
10890                                    Object[] args = new Object[] {
10891                                                    assetCategoryModelImpl.getOriginalUuid(),
10892                                                    assetCategoryModelImpl.getOriginalCompanyId()
10893                                            };
10894    
10895                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10896                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10897                                            args);
10898    
10899                                    args = new Object[] {
10900                                                    assetCategoryModelImpl.getUuid(),
10901                                                    assetCategoryModelImpl.getCompanyId()
10902                                            };
10903    
10904                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
10905                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
10906                                            args);
10907                            }
10908    
10909                            if ((assetCategoryModelImpl.getColumnBitmask() &
10910                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
10911                                    Object[] args = new Object[] {
10912                                                    assetCategoryModelImpl.getOriginalGroupId()
10913                                            };
10914    
10915                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10916                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10917                                            args);
10918    
10919                                    args = new Object[] { assetCategoryModelImpl.getGroupId() };
10920    
10921                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
10922                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
10923                                            args);
10924                            }
10925    
10926                            if ((assetCategoryModelImpl.getColumnBitmask() &
10927                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
10928                                    Object[] args = new Object[] {
10929                                                    assetCategoryModelImpl.getOriginalParentCategoryId()
10930                                            };
10931    
10932                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10933                                            args);
10934                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10935                                            args);
10936    
10937                                    args = new Object[] { assetCategoryModelImpl.getParentCategoryId() };
10938    
10939                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
10940                                            args);
10941                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
10942                                            args);
10943                            }
10944    
10945                            if ((assetCategoryModelImpl.getColumnBitmask() &
10946                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
10947                                    Object[] args = new Object[] {
10948                                                    assetCategoryModelImpl.getOriginalVocabularyId()
10949                                            };
10950    
10951                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10952                                            args);
10953                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10954                                            args);
10955    
10956                                    args = new Object[] { assetCategoryModelImpl.getVocabularyId() };
10957    
10958                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
10959                                            args);
10960                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
10961                                            args);
10962                            }
10963    
10964                            if ((assetCategoryModelImpl.getColumnBitmask() &
10965                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
10966                                    Object[] args = new Object[] {
10967                                                    assetCategoryModelImpl.getOriginalGroupId(),
10968                                                    assetCategoryModelImpl.getOriginalVocabularyId()
10969                                            };
10970    
10971                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10972                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10973                                            args);
10974    
10975                                    args = new Object[] {
10976                                                    assetCategoryModelImpl.getGroupId(),
10977                                                    assetCategoryModelImpl.getVocabularyId()
10978                                            };
10979    
10980                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
10981                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
10982                                            args);
10983                            }
10984    
10985                            if ((assetCategoryModelImpl.getColumnBitmask() &
10986                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
10987                                    Object[] args = new Object[] {
10988                                                    assetCategoryModelImpl.getOriginalParentCategoryId(),
10989                                                    assetCategoryModelImpl.getOriginalName()
10990                                            };
10991    
10992                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
10993                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
10994                                            args);
10995    
10996                                    args = new Object[] {
10997                                                    assetCategoryModelImpl.getParentCategoryId(),
10998                                                    assetCategoryModelImpl.getName()
10999                                            };
11000    
11001                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
11002                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
11003                                            args);
11004                            }
11005    
11006                            if ((assetCategoryModelImpl.getColumnBitmask() &
11007                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
11008                                    Object[] args = new Object[] {
11009                                                    assetCategoryModelImpl.getOriginalParentCategoryId(),
11010                                                    assetCategoryModelImpl.getOriginalVocabularyId()
11011                                            };
11012    
11013                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11014                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11015                                            args);
11016    
11017                                    args = new Object[] {
11018                                                    assetCategoryModelImpl.getParentCategoryId(),
11019                                                    assetCategoryModelImpl.getVocabularyId()
11020                                            };
11021    
11022                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
11023                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
11024                                            args);
11025                            }
11026    
11027                            if ((assetCategoryModelImpl.getColumnBitmask() &
11028                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
11029                                    Object[] args = new Object[] {
11030                                                    assetCategoryModelImpl.getOriginalName(),
11031                                                    assetCategoryModelImpl.getOriginalVocabularyId()
11032                                            };
11033    
11034                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11035                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11036                                            args);
11037    
11038                                    args = new Object[] {
11039                                                    assetCategoryModelImpl.getName(),
11040                                                    assetCategoryModelImpl.getVocabularyId()
11041                                            };
11042    
11043                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
11044                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
11045                                            args);
11046                            }
11047    
11048                            if ((assetCategoryModelImpl.getColumnBitmask() &
11049                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
11050                                    Object[] args = new Object[] {
11051                                                    assetCategoryModelImpl.getOriginalGroupId(),
11052                                                    assetCategoryModelImpl.getOriginalParentCategoryId(),
11053                                                    assetCategoryModelImpl.getOriginalVocabularyId()
11054                                            };
11055    
11056                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11057                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11058                                            args);
11059    
11060                                    args = new Object[] {
11061                                                    assetCategoryModelImpl.getGroupId(),
11062                                                    assetCategoryModelImpl.getParentCategoryId(),
11063                                                    assetCategoryModelImpl.getVocabularyId()
11064                                            };
11065    
11066                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
11067                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
11068                                            args);
11069                            }
11070    
11071                            if ((assetCategoryModelImpl.getColumnBitmask() &
11072                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
11073                                    Object[] args = new Object[] {
11074                                                    assetCategoryModelImpl.getOriginalGroupId(),
11075                                                    assetCategoryModelImpl.getOriginalParentCategoryId(),
11076                                                    assetCategoryModelImpl.getOriginalName(),
11077                                                    assetCategoryModelImpl.getOriginalVocabularyId()
11078                                            };
11079    
11080                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11081                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11082                                            args);
11083    
11084                                    args = new Object[] {
11085                                                    assetCategoryModelImpl.getGroupId(),
11086                                                    assetCategoryModelImpl.getParentCategoryId(),
11087                                                    assetCategoryModelImpl.getName(),
11088                                                    assetCategoryModelImpl.getVocabularyId()
11089                                            };
11090    
11091                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
11092                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
11093                                            args);
11094                            }
11095                    }
11096    
11097                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11098                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
11099                            assetCategory);
11100    
11101                    clearUniqueFindersCache(assetCategory);
11102                    cacheUniqueFindersCache(assetCategory);
11103    
11104                    return assetCategory;
11105            }
11106    
11107            protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
11108                    if (assetCategory instanceof AssetCategoryImpl) {
11109                            return assetCategory;
11110                    }
11111    
11112                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
11113    
11114                    assetCategoryImpl.setNew(assetCategory.isNew());
11115                    assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
11116    
11117                    assetCategoryImpl.setUuid(assetCategory.getUuid());
11118                    assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
11119                    assetCategoryImpl.setGroupId(assetCategory.getGroupId());
11120                    assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
11121                    assetCategoryImpl.setUserId(assetCategory.getUserId());
11122                    assetCategoryImpl.setUserName(assetCategory.getUserName());
11123                    assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
11124                    assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
11125                    assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
11126                    assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
11127                    assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
11128                    assetCategoryImpl.setName(assetCategory.getName());
11129                    assetCategoryImpl.setTitle(assetCategory.getTitle());
11130                    assetCategoryImpl.setDescription(assetCategory.getDescription());
11131                    assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
11132    
11133                    return assetCategoryImpl;
11134            }
11135    
11136            /**
11137             * Returns the asset category with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
11138             *
11139             * @param primaryKey the primary key of the asset category
11140             * @return the asset category
11141             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
11142             * @throws SystemException if a system exception occurred
11143             */
11144            @Override
11145            public AssetCategory findByPrimaryKey(Serializable primaryKey)
11146                    throws NoSuchCategoryException, SystemException {
11147                    AssetCategory assetCategory = fetchByPrimaryKey(primaryKey);
11148    
11149                    if (assetCategory == null) {
11150                            if (_log.isWarnEnabled()) {
11151                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
11152                            }
11153    
11154                            throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
11155                                    primaryKey);
11156                    }
11157    
11158                    return assetCategory;
11159            }
11160    
11161            /**
11162             * Returns the asset category with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
11163             *
11164             * @param categoryId the primary key of the asset category
11165             * @return the asset category
11166             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
11167             * @throws SystemException if a system exception occurred
11168             */
11169            @Override
11170            public AssetCategory findByPrimaryKey(long categoryId)
11171                    throws NoSuchCategoryException, SystemException {
11172                    return findByPrimaryKey((Serializable)categoryId);
11173            }
11174    
11175            /**
11176             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
11177             *
11178             * @param primaryKey the primary key of the asset category
11179             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
11180             * @throws SystemException if a system exception occurred
11181             */
11182            @Override
11183            public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
11184                    throws SystemException {
11185                    AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11186                                    AssetCategoryImpl.class, primaryKey);
11187    
11188                    if (assetCategory == _nullAssetCategory) {
11189                            return null;
11190                    }
11191    
11192                    if (assetCategory == null) {
11193                            Session session = null;
11194    
11195                            try {
11196                                    session = openSession();
11197    
11198                                    assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
11199                                                    primaryKey);
11200    
11201                                    if (assetCategory != null) {
11202                                            cacheResult(assetCategory);
11203                                    }
11204                                    else {
11205                                            EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11206                                                    AssetCategoryImpl.class, primaryKey, _nullAssetCategory);
11207                                    }
11208                            }
11209                            catch (Exception e) {
11210                                    EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
11211                                            AssetCategoryImpl.class, primaryKey);
11212    
11213                                    throw processException(e);
11214                            }
11215                            finally {
11216                                    closeSession(session);
11217                            }
11218                    }
11219    
11220                    return assetCategory;
11221            }
11222    
11223            /**
11224             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
11225             *
11226             * @param categoryId the primary key of the asset category
11227             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
11228             * @throws SystemException if a system exception occurred
11229             */
11230            @Override
11231            public AssetCategory fetchByPrimaryKey(long categoryId)
11232                    throws SystemException {
11233                    return fetchByPrimaryKey((Serializable)categoryId);
11234            }
11235    
11236            /**
11237             * Returns all the asset categories.
11238             *
11239             * @return the asset categories
11240             * @throws SystemException if a system exception occurred
11241             */
11242            @Override
11243            public List<AssetCategory> findAll() throws SystemException {
11244                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
11245            }
11246    
11247            /**
11248             * Returns a range of all the asset categories.
11249             *
11250             * <p>
11251             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11252             * </p>
11253             *
11254             * @param start the lower bound of the range of asset categories
11255             * @param end the upper bound of the range of asset categories (not inclusive)
11256             * @return the range of asset categories
11257             * @throws SystemException if a system exception occurred
11258             */
11259            @Override
11260            public List<AssetCategory> findAll(int start, int end)
11261                    throws SystemException {
11262                    return findAll(start, end, null);
11263            }
11264    
11265            /**
11266             * Returns an ordered range of all the asset categories.
11267             *
11268             * <p>
11269             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11270             * </p>
11271             *
11272             * @param start the lower bound of the range of asset categories
11273             * @param end the upper bound of the range of asset categories (not inclusive)
11274             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11275             * @return the ordered range of asset categories
11276             * @throws SystemException if a system exception occurred
11277             */
11278            @Override
11279            public List<AssetCategory> findAll(int start, int end,
11280                    OrderByComparator orderByComparator) throws SystemException {
11281                    boolean pagination = true;
11282                    FinderPath finderPath = null;
11283                    Object[] finderArgs = null;
11284    
11285                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11286                                    (orderByComparator == null)) {
11287                            pagination = false;
11288                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
11289                            finderArgs = FINDER_ARGS_EMPTY;
11290                    }
11291                    else {
11292                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
11293                            finderArgs = new Object[] { start, end, orderByComparator };
11294                    }
11295    
11296                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
11297                                    finderArgs, this);
11298    
11299                    if (list == null) {
11300                            StringBundler query = null;
11301                            String sql = null;
11302    
11303                            if (orderByComparator != null) {
11304                                    query = new StringBundler(2 +
11305                                                    (orderByComparator.getOrderByFields().length * 3));
11306    
11307                                    query.append(_SQL_SELECT_ASSETCATEGORY);
11308    
11309                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
11310                                            orderByComparator);
11311    
11312                                    sql = query.toString();
11313                            }
11314                            else {
11315                                    sql = _SQL_SELECT_ASSETCATEGORY;
11316    
11317                                    if (pagination) {
11318                                            sql = sql.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
11319                                    }
11320                            }
11321    
11322                            Session session = null;
11323    
11324                            try {
11325                                    session = openSession();
11326    
11327                                    Query q = session.createQuery(sql);
11328    
11329                                    if (!pagination) {
11330                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11331                                                            start, end, false);
11332    
11333                                            Collections.sort(list);
11334    
11335                                            list = new UnmodifiableList<AssetCategory>(list);
11336                                    }
11337                                    else {
11338                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
11339                                                            start, end);
11340                                    }
11341    
11342                                    cacheResult(list);
11343    
11344                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
11345                            }
11346                            catch (Exception e) {
11347                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
11348    
11349                                    throw processException(e);
11350                            }
11351                            finally {
11352                                    closeSession(session);
11353                            }
11354                    }
11355    
11356                    return list;
11357            }
11358    
11359            /**
11360             * Removes all the asset categories from the database.
11361             *
11362             * @throws SystemException if a system exception occurred
11363             */
11364            @Override
11365            public void removeAll() throws SystemException {
11366                    for (AssetCategory assetCategory : findAll()) {
11367                            remove(assetCategory);
11368                    }
11369            }
11370    
11371            /**
11372             * Returns the number of asset categories.
11373             *
11374             * @return the number of asset categories
11375             * @throws SystemException if a system exception occurred
11376             */
11377            @Override
11378            public int countAll() throws SystemException {
11379                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
11380                                    FINDER_ARGS_EMPTY, this);
11381    
11382                    if (count == null) {
11383                            Session session = null;
11384    
11385                            try {
11386                                    session = openSession();
11387    
11388                                    Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
11389    
11390                                    count = (Long)q.uniqueResult();
11391    
11392                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
11393                                            FINDER_ARGS_EMPTY, count);
11394                            }
11395                            catch (Exception e) {
11396                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
11397                                            FINDER_ARGS_EMPTY);
11398    
11399                                    throw processException(e);
11400                            }
11401                            finally {
11402                                    closeSession(session);
11403                            }
11404                    }
11405    
11406                    return count.intValue();
11407            }
11408    
11409            /**
11410             * Returns all the asset entries associated with the asset category.
11411             *
11412             * @param pk the primary key of the asset category
11413             * @return the asset entries associated with the asset category
11414             * @throws SystemException if a system exception occurred
11415             */
11416            @Override
11417            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11418                    long pk) throws SystemException {
11419                    return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
11420            }
11421    
11422            /**
11423             * Returns a range of all the asset entries associated with the asset category.
11424             *
11425             * <p>
11426             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11427             * </p>
11428             *
11429             * @param pk the primary key of the asset category
11430             * @param start the lower bound of the range of asset categories
11431             * @param end the upper bound of the range of asset categories (not inclusive)
11432             * @return the range of asset entries associated with the asset category
11433             * @throws SystemException if a system exception occurred
11434             */
11435            @Override
11436            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11437                    long pk, int start, int end) throws SystemException {
11438                    return getAssetEntries(pk, start, end, null);
11439            }
11440    
11441            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11442                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11443                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
11444                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11445                            "getAssetEntries",
11446                            new String[] {
11447                                    Long.class.getName(), Integer.class.getName(),
11448                                    Integer.class.getName(), OrderByComparator.class.getName()
11449                            });
11450    
11451            static {
11452                    FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
11453            }
11454    
11455            /**
11456             * Returns an ordered range of all the asset entries associated with the asset category.
11457             *
11458             * <p>
11459             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
11460             * </p>
11461             *
11462             * @param pk the primary key of the asset category
11463             * @param start the lower bound of the range of asset categories
11464             * @param end the upper bound of the range of asset categories (not inclusive)
11465             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
11466             * @return the ordered range of asset entries associated with the asset category
11467             * @throws SystemException if a system exception occurred
11468             */
11469            @Override
11470            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
11471                    long pk, int start, int end, OrderByComparator orderByComparator)
11472                    throws SystemException {
11473                    boolean pagination = true;
11474                    Object[] finderArgs = null;
11475    
11476                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
11477                                    (orderByComparator == null)) {
11478                            pagination = false;
11479                            finderArgs = new Object[] { pk };
11480                    }
11481                    else {
11482                            finderArgs = new Object[] { pk, start, end, orderByComparator };
11483                    }
11484    
11485                    List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
11486                                    finderArgs, this);
11487    
11488                    if (list == null) {
11489                            Session session = null;
11490    
11491                            try {
11492                                    session = openSession();
11493    
11494                                    String sql = null;
11495    
11496                                    if (orderByComparator != null) {
11497                                            sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
11498                                                                                              .concat(orderByComparator.getOrderBy());
11499                                    }
11500                                    else {
11501                                            sql = _SQL_GETASSETENTRIES;
11502    
11503                                            if (pagination) {
11504                                                    sql = sql.concat(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ORDER_BY_SQL);
11505                                            }
11506                                    }
11507    
11508                                    SQLQuery q = session.createSQLQuery(sql);
11509    
11510                                    q.addEntity("AssetEntry",
11511                                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
11512    
11513                                    QueryPos qPos = QueryPos.getInstance(q);
11514    
11515                                    qPos.add(pk);
11516    
11517                                    if (!pagination) {
11518                                            list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
11519                                                            getDialect(), start, end, false);
11520    
11521                                            Collections.sort(list);
11522    
11523                                            list = new UnmodifiableList<com.liferay.portlet.asset.model.AssetEntry>(list);
11524                                    }
11525                                    else {
11526                                            list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
11527                                                            getDialect(), start, end);
11528                                    }
11529    
11530                                    assetEntryPersistence.cacheResult(list);
11531    
11532                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
11533                                            finderArgs, list);
11534                            }
11535                            catch (Exception e) {
11536                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
11537                                            finderArgs);
11538    
11539                                    throw processException(e);
11540                            }
11541                            finally {
11542                                    closeSession(session);
11543                            }
11544                    }
11545    
11546                    return list;
11547            }
11548    
11549            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11550                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11551                            Long.class,
11552                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11553                            "getAssetEntriesSize", new String[] { Long.class.getName() });
11554    
11555            static {
11556                    FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
11557            }
11558    
11559            /**
11560             * Returns the number of asset entries associated with the asset category.
11561             *
11562             * @param pk the primary key of the asset category
11563             * @return the number of asset entries associated with the asset category
11564             * @throws SystemException if a system exception occurred
11565             */
11566            @Override
11567            public int getAssetEntriesSize(long pk) throws SystemException {
11568                    Object[] finderArgs = new Object[] { pk };
11569    
11570                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11571                                    finderArgs, this);
11572    
11573                    if (count == null) {
11574                            Session session = null;
11575    
11576                            try {
11577                                    session = openSession();
11578    
11579                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
11580    
11581                                    q.addScalar(COUNT_COLUMN_NAME,
11582                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
11583    
11584                                    QueryPos qPos = QueryPos.getInstance(q);
11585    
11586                                    qPos.add(pk);
11587    
11588                                    count = (Long)q.uniqueResult();
11589    
11590                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11591                                            finderArgs, count);
11592                            }
11593                            catch (Exception e) {
11594                                    FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
11595                                            finderArgs);
11596    
11597                                    throw processException(e);
11598                            }
11599                            finally {
11600                                    closeSession(session);
11601                            }
11602                    }
11603    
11604                    return count.intValue();
11605            }
11606    
11607            public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
11608                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
11609                            Boolean.class,
11610                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
11611                            "containsAssetEntry",
11612                            new String[] { Long.class.getName(), Long.class.getName() });
11613    
11614            /**
11615             * Returns <code>true</code> if the asset entry is associated with the asset category.
11616             *
11617             * @param pk the primary key of the asset category
11618             * @param assetEntryPK the primary key of the asset entry
11619             * @return <code>true</code> if the asset entry is associated with the asset category; <code>false</code> otherwise
11620             * @throws SystemException if a system exception occurred
11621             */
11622            @Override
11623            public boolean containsAssetEntry(long pk, long assetEntryPK)
11624                    throws SystemException {
11625                    Object[] finderArgs = new Object[] { pk, assetEntryPK };
11626    
11627                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11628                                    finderArgs, this);
11629    
11630                    if (value == null) {
11631                            try {
11632                                    value = Boolean.valueOf(containsAssetEntry.contains(pk,
11633                                                            assetEntryPK));
11634    
11635                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11636                                            finderArgs, value);
11637                            }
11638                            catch (Exception e) {
11639                                    FinderCacheUtil.removeResult(FINDER_PATH_CONTAINS_ASSETENTRY,
11640                                            finderArgs);
11641    
11642                                    throw processException(e);
11643                            }
11644                    }
11645    
11646                    return value.booleanValue();
11647            }
11648    
11649            /**
11650             * Returns <code>true</code> if the asset category has any asset entries associated with it.
11651             *
11652             * @param pk the primary key of the asset category to check for associations with asset entries
11653             * @return <code>true</code> if the asset category has any asset entries associated with it; <code>false</code> otherwise
11654             * @throws SystemException if a system exception occurred
11655             */
11656            @Override
11657            public boolean containsAssetEntries(long pk) throws SystemException {
11658                    if (getAssetEntriesSize(pk) > 0) {
11659                            return true;
11660                    }
11661                    else {
11662                            return false;
11663                    }
11664            }
11665    
11666            /**
11667             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11668             *
11669             * @param pk the primary key of the asset category
11670             * @param assetEntryPK the primary key of the asset entry
11671             * @throws SystemException if a system exception occurred
11672             */
11673            @Override
11674            public void addAssetEntry(long pk, long assetEntryPK)
11675                    throws SystemException {
11676                    try {
11677                            addAssetEntry.add(pk, assetEntryPK);
11678                    }
11679                    catch (Exception e) {
11680                            throw processException(e);
11681                    }
11682                    finally {
11683                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11684                    }
11685            }
11686    
11687            /**
11688             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11689             *
11690             * @param pk the primary key of the asset category
11691             * @param assetEntry the asset entry
11692             * @throws SystemException if a system exception occurred
11693             */
11694            @Override
11695            public void addAssetEntry(long pk,
11696                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
11697                    throws SystemException {
11698                    try {
11699                            addAssetEntry.add(pk, assetEntry.getPrimaryKey());
11700                    }
11701                    catch (Exception e) {
11702                            throw processException(e);
11703                    }
11704                    finally {
11705                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11706                    }
11707            }
11708    
11709            /**
11710             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11711             *
11712             * @param pk the primary key of the asset category
11713             * @param assetEntryPKs the primary keys of the asset entries
11714             * @throws SystemException if a system exception occurred
11715             */
11716            @Override
11717            public void addAssetEntries(long pk, long[] assetEntryPKs)
11718                    throws SystemException {
11719                    try {
11720                            for (long assetEntryPK : assetEntryPKs) {
11721                                    addAssetEntry.add(pk, assetEntryPK);
11722                            }
11723                    }
11724                    catch (Exception e) {
11725                            throw processException(e);
11726                    }
11727                    finally {
11728                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11729                    }
11730            }
11731    
11732            /**
11733             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11734             *
11735             * @param pk the primary key of the asset category
11736             * @param assetEntries the asset entries
11737             * @throws SystemException if a system exception occurred
11738             */
11739            @Override
11740            public void addAssetEntries(long pk,
11741                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11742                    throws SystemException {
11743                    try {
11744                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11745                                    addAssetEntry.add(pk, assetEntry.getPrimaryKey());
11746                            }
11747                    }
11748                    catch (Exception e) {
11749                            throw processException(e);
11750                    }
11751                    finally {
11752                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11753                    }
11754            }
11755    
11756            /**
11757             * Clears all associations between the asset category and its asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11758             *
11759             * @param pk the primary key of the asset category to clear the associated asset entries from
11760             * @throws SystemException if a system exception occurred
11761             */
11762            @Override
11763            public void clearAssetEntries(long pk) throws SystemException {
11764                    try {
11765                            clearAssetEntries.clear(pk);
11766                    }
11767                    catch (Exception e) {
11768                            throw processException(e);
11769                    }
11770                    finally {
11771                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11772                    }
11773            }
11774    
11775            /**
11776             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11777             *
11778             * @param pk the primary key of the asset category
11779             * @param assetEntryPK the primary key of the asset entry
11780             * @throws SystemException if a system exception occurred
11781             */
11782            @Override
11783            public void removeAssetEntry(long pk, long assetEntryPK)
11784                    throws SystemException {
11785                    try {
11786                            removeAssetEntry.remove(pk, assetEntryPK);
11787                    }
11788                    catch (Exception e) {
11789                            throw processException(e);
11790                    }
11791                    finally {
11792                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11793                    }
11794            }
11795    
11796            /**
11797             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11798             *
11799             * @param pk the primary key of the asset category
11800             * @param assetEntry the asset entry
11801             * @throws SystemException if a system exception occurred
11802             */
11803            @Override
11804            public void removeAssetEntry(long pk,
11805                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
11806                    throws SystemException {
11807                    try {
11808                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11809                    }
11810                    catch (Exception e) {
11811                            throw processException(e);
11812                    }
11813                    finally {
11814                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11815                    }
11816            }
11817    
11818            /**
11819             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11820             *
11821             * @param pk the primary key of the asset category
11822             * @param assetEntryPKs the primary keys of the asset entries
11823             * @throws SystemException if a system exception occurred
11824             */
11825            @Override
11826            public void removeAssetEntries(long pk, long[] assetEntryPKs)
11827                    throws SystemException {
11828                    try {
11829                            for (long assetEntryPK : assetEntryPKs) {
11830                                    removeAssetEntry.remove(pk, assetEntryPK);
11831                            }
11832                    }
11833                    catch (Exception e) {
11834                            throw processException(e);
11835                    }
11836                    finally {
11837                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11838                    }
11839            }
11840    
11841            /**
11842             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11843             *
11844             * @param pk the primary key of the asset category
11845             * @param assetEntries the asset entries
11846             * @throws SystemException if a system exception occurred
11847             */
11848            @Override
11849            public void removeAssetEntries(long pk,
11850                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11851                    throws SystemException {
11852                    try {
11853                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11854                                    removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11855                            }
11856                    }
11857                    catch (Exception e) {
11858                            throw processException(e);
11859                    }
11860                    finally {
11861                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11862                    }
11863            }
11864    
11865            /**
11866             * Sets the asset entries associated with the asset category, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11867             *
11868             * @param pk the primary key of the asset category
11869             * @param assetEntryPKs the primary keys of the asset entries to be associated with the asset category
11870             * @throws SystemException if a system exception occurred
11871             */
11872            @Override
11873            public void setAssetEntries(long pk, long[] assetEntryPKs)
11874                    throws SystemException {
11875                    try {
11876                            Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
11877    
11878                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
11879    
11880                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11881                                    if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
11882                                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
11883                                    }
11884                            }
11885    
11886                            for (Long assetEntryPK : assetEntryPKSet) {
11887                                    addAssetEntry.add(pk, assetEntryPK);
11888                            }
11889                    }
11890                    catch (Exception e) {
11891                            throw processException(e);
11892                    }
11893                    finally {
11894                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11895                    }
11896            }
11897    
11898            /**
11899             * Sets the asset entries associated with the asset category, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
11900             *
11901             * @param pk the primary key of the asset category
11902             * @param assetEntries the asset entries to be associated with the asset category
11903             * @throws SystemException if a system exception occurred
11904             */
11905            @Override
11906            public void setAssetEntries(long pk,
11907                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
11908                    throws SystemException {
11909                    try {
11910                            long[] assetEntryPKs = new long[assetEntries.size()];
11911    
11912                            for (int i = 0; i < assetEntries.size(); i++) {
11913                                    com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
11914    
11915                                    assetEntryPKs[i] = assetEntry.getPrimaryKey();
11916                            }
11917    
11918                            setAssetEntries(pk, assetEntryPKs);
11919                    }
11920                    catch (Exception e) {
11921                            throw processException(e);
11922                    }
11923                    finally {
11924                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
11925                    }
11926            }
11927    
11928            @Override
11929            protected Set<String> getBadColumnNames() {
11930                    return _badColumnNames;
11931            }
11932    
11933            /**
11934             * Rebuilds the asset categories tree for the scope using the modified pre-order tree traversal algorithm.
11935             *
11936             * <p>
11937             * Only call this method if the tree has become stale through operations other than normal CRUD. Under normal circumstances the tree is automatically rebuilt whenver necessary.
11938             * </p>
11939             *
11940             * @param groupId the ID of the scope
11941             * @param force whether to force the rebuild even if the tree is not stale
11942             */
11943            @Override
11944            public void rebuildTree(long groupId, boolean force)
11945                    throws SystemException {
11946                    if (!rebuildTreeEnabled) {
11947                            return;
11948                    }
11949    
11950                    if (force || (countOrphanTreeNodes(groupId) > 0)) {
11951                            rebuildTree(groupId, 0, 1);
11952    
11953                            if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
11954                                    CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11955                            }
11956    
11957                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11958                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11959                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11960                    }
11961            }
11962    
11963            @Override
11964            public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
11965                    this.rebuildTreeEnabled = rebuildTreeEnabled;
11966            }
11967    
11968            protected long countOrphanTreeNodes(long groupId) throws SystemException {
11969                    Session session = null;
11970    
11971                    try {
11972                            session = openSession();
11973    
11974                            SQLQuery q = session.createSQLQuery(
11975                                            "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
11976    
11977                            q.addScalar(COUNT_COLUMN_NAME,
11978                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11979    
11980                            QueryPos qPos = QueryPos.getInstance(q);
11981    
11982                            qPos.add(groupId);
11983    
11984                            return (Long)q.uniqueResult();
11985                    }
11986                    catch (Exception e) {
11987                            throw processException(e);
11988                    }
11989                    finally {
11990                            closeSession(session);
11991                    }
11992            }
11993    
11994            protected void expandNoChildrenLeftCategoryId(long groupId,
11995                    long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
11996                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
11997                            StringUtil.merge(childrenCategoryIds) + "))";
11998    
11999                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12000                                    sql,
12001                                    new int[] {
12002                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12003                                            java.sql.Types.BIGINT
12004                                    });
12005    
12006                    _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
12007            }
12008    
12009            protected void expandNoChildrenRightCategoryId(long groupId,
12010                    long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
12011                    String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
12012                            StringUtil.merge(childrenCategoryIds) + "))";
12013    
12014                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12015                                    sql,
12016                                    new int[] {
12017                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12018                                            java.sql.Types.BIGINT
12019                                    });
12020    
12021                    _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12022            }
12023    
12024            protected void expandTree(AssetCategory assetCategory,
12025                    List<Long> childrenCategoryIds) throws SystemException {
12026                    if (!rebuildTreeEnabled) {
12027                            return;
12028                    }
12029    
12030                    long groupId = assetCategory.getGroupId();
12031    
12032                    long lastRightCategoryId = getLastRightCategoryId(groupId,
12033                                    assetCategory.getParentCategoryId());
12034    
12035                    long leftCategoryId = 2;
12036                    long rightCategoryId = 3;
12037    
12038                    if (lastRightCategoryId > 0) {
12039                            leftCategoryId = lastRightCategoryId + 1;
12040    
12041                            long childrenDistance = assetCategory.getRightCategoryId() -
12042                                    assetCategory.getLeftCategoryId();
12043    
12044                            if (childrenDistance > 1) {
12045                                    rightCategoryId = leftCategoryId + childrenDistance;
12046    
12047                                    updateChildrenTree(groupId, childrenCategoryIds,
12048                                            leftCategoryId - assetCategory.getLeftCategoryId());
12049    
12050                                    expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
12051                                            childrenCategoryIds, childrenDistance + 1);
12052                                    expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
12053                                            childrenCategoryIds, childrenDistance + 1);
12054                            }
12055                            else {
12056                                    rightCategoryId = lastRightCategoryId + 2;
12057    
12058                                    expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
12059                                    expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
12060                            }
12061    
12062                            if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
12063                                    CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
12064                            }
12065    
12066                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
12067                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
12068                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12069                    }
12070    
12071                    assetCategory.setLeftCategoryId(leftCategoryId);
12072                    assetCategory.setRightCategoryId(rightCategoryId);
12073            }
12074    
12075            protected List<Long> getChildrenTreeCategoryIds(
12076                    AssetCategory parentAssetCategory) throws SystemException {
12077                    Session session = null;
12078    
12079                    try {
12080                            session = openSession();
12081    
12082                            SQLQuery q = session.createSQLQuery(
12083                                            "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
12084    
12085                            q.addScalar("CategoryId",
12086                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12087    
12088                            QueryPos qPos = QueryPos.getInstance(q);
12089    
12090                            qPos.add(parentAssetCategory.getGroupId());
12091                            qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
12092                            qPos.add(parentAssetCategory.getRightCategoryId());
12093    
12094                            return q.list();
12095                    }
12096                    catch (Exception e) {
12097                            throw processException(e);
12098                    }
12099                    finally {
12100                            closeSession(session);
12101                    }
12102            }
12103    
12104            protected long getLastRightCategoryId(long groupId, long parentCategoryId)
12105                    throws SystemException {
12106                    Session session = null;
12107    
12108                    try {
12109                            session = openSession();
12110    
12111                            SQLQuery q = session.createSQLQuery(
12112                                            "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
12113    
12114                            q.addScalar("rightCategoryId",
12115                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12116    
12117                            QueryPos qPos = QueryPos.getInstance(q);
12118    
12119                            qPos.add(groupId);
12120                            qPos.add(parentCategoryId);
12121    
12122                            List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
12123    
12124                            if (list.isEmpty()) {
12125                                    if (parentCategoryId > 0) {
12126                                            session.clear();
12127    
12128                                            AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
12129    
12130                                            return parentAssetCategory.getLeftCategoryId();
12131                                    }
12132    
12133                                    return 0;
12134                            }
12135                            else {
12136                                    return list.get(0);
12137                            }
12138                    }
12139                    catch (Exception e) {
12140                            throw processException(e);
12141                    }
12142                    finally {
12143                            closeSession(session);
12144                    }
12145            }
12146    
12147            protected long rebuildTree(long groupId, long parentCategoryId,
12148                    long leftCategoryId) throws SystemException {
12149                    if (!rebuildTreeEnabled) {
12150                            return 0;
12151                    }
12152    
12153                    List<Long> categoryIds = null;
12154    
12155                    Session session = null;
12156    
12157                    try {
12158                            session = openSession();
12159    
12160                            SQLQuery q = session.createSQLQuery(
12161                                            "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
12162    
12163                            q.addScalar("categoryId",
12164                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
12165    
12166                            QueryPos qPos = QueryPos.getInstance(q);
12167    
12168                            qPos.add(groupId);
12169                            qPos.add(parentCategoryId);
12170    
12171                            categoryIds = q.list();
12172                    }
12173                    catch (Exception e) {
12174                            throw processException(e);
12175                    }
12176                    finally {
12177                            closeSession(session);
12178                    }
12179    
12180                    long rightCategoryId = leftCategoryId + 1;
12181    
12182                    for (long categoryId : categoryIds) {
12183                            rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
12184                    }
12185    
12186                    if (parentCategoryId > 0) {
12187                            updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
12188                    }
12189    
12190                    return rightCategoryId + 1;
12191            }
12192    
12193            protected void shrinkTree(AssetCategory assetCategory) {
12194                    if (!rebuildTreeEnabled) {
12195                            return;
12196                    }
12197    
12198                    long groupId = assetCategory.getGroupId();
12199    
12200                    long leftCategoryId = assetCategory.getLeftCategoryId();
12201                    long rightCategoryId = assetCategory.getRightCategoryId();
12202    
12203                    long delta = (rightCategoryId - leftCategoryId) + 1;
12204    
12205                    shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
12206                    shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
12207    
12208                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
12209                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
12210                    }
12211    
12212                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
12213                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
12214                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12215            }
12216    
12217            protected void updateChildrenTree(long groupId,
12218                    List<Long> childrenCategoryIds, long delta) {
12219                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
12220                            StringUtil.merge(childrenCategoryIds) + "))";
12221    
12222                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12223                                    sql,
12224                                    new int[] {
12225                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12226                                            java.sql.Types.BIGINT
12227                                    });
12228    
12229                    _sqlUpdate.update(new Object[] { delta, delta, groupId });
12230            }
12231    
12232            /**
12233             * Initializes the asset category persistence.
12234             */
12235            public void afterPropertiesSet() {
12236                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
12237                                            com.liferay.portal.util.PropsUtil.get(
12238                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
12239    
12240                    if (listenerClassNames.length > 0) {
12241                            try {
12242                                    List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
12243    
12244                                    for (String listenerClassName : listenerClassNames) {
12245                                            listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
12246                                                            getClassLoader(), listenerClassName));
12247                                    }
12248    
12249                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
12250                            }
12251                            catch (Exception e) {
12252                                    _log.error(e);
12253                            }
12254                    }
12255    
12256                    containsAssetEntry = new ContainsAssetEntry();
12257    
12258                    addAssetEntry = new AddAssetEntry();
12259                    clearAssetEntries = new ClearAssetEntries();
12260                    removeAssetEntry = new RemoveAssetEntry();
12261    
12262                    expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
12263                    expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
12264                    shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
12265                    shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
12266                    updateTree = new UpdateTree();
12267            }
12268    
12269            public void destroy() {
12270                    EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
12271                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
12272                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
12273                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
12274            }
12275    
12276            @BeanReference(type = AssetEntryPersistence.class)
12277            protected AssetEntryPersistence assetEntryPersistence;
12278            protected ContainsAssetEntry containsAssetEntry;
12279            protected AddAssetEntry addAssetEntry;
12280            protected ClearAssetEntries clearAssetEntries;
12281            protected RemoveAssetEntry removeAssetEntry;
12282    
12283            protected class ContainsAssetEntry {
12284                    protected ContainsAssetEntry() {
12285                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
12286                                            "SELECT 1 FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
12287                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
12288                                            RowMapper.COUNT);
12289                    }
12290    
12291                    protected boolean contains(long categoryId, long entryId) {
12292                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
12293                                                    new Long(categoryId), new Long(entryId)
12294                                            });
12295    
12296                            if (results.isEmpty()) {
12297                                    return false;
12298                            }
12299    
12300                            return true;
12301                    }
12302    
12303                    private MappingSqlQuery<Integer> _mappingSqlQuery;
12304            }
12305    
12306            protected class AddAssetEntry {
12307                    protected AddAssetEntry() {
12308                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12309                                            "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
12310                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12311                    }
12312    
12313                    protected void add(long categoryId, long entryId)
12314                            throws SystemException {
12315                            if (!containsAssetEntry.contains(categoryId, entryId)) {
12316                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12317                                            assetEntryPersistence.getListeners();
12318    
12319                                    for (ModelListener<AssetCategory> listener : listeners) {
12320                                            listener.onBeforeAddAssociation(categoryId,
12321                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12322                                                    entryId);
12323                                    }
12324    
12325                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12326                                            listener.onBeforeAddAssociation(entryId,
12327                                                    AssetCategory.class.getName(), categoryId);
12328                                    }
12329    
12330                                    _sqlUpdate.update(new Object[] {
12331                                                    new Long(categoryId), new Long(entryId)
12332                                            });
12333    
12334                                    for (ModelListener<AssetCategory> listener : listeners) {
12335                                            listener.onAfterAddAssociation(categoryId,
12336                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12337                                                    entryId);
12338                                    }
12339    
12340                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12341                                            listener.onAfterAddAssociation(entryId,
12342                                                    AssetCategory.class.getName(), categoryId);
12343                                    }
12344                            }
12345                    }
12346    
12347                    private SqlUpdate _sqlUpdate;
12348            }
12349    
12350            protected class ClearAssetEntries {
12351                    protected ClearAssetEntries() {
12352                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12353                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
12354                                            new int[] { java.sql.Types.BIGINT });
12355                    }
12356    
12357                    protected void clear(long categoryId) throws SystemException {
12358                            ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12359                                    assetEntryPersistence.getListeners();
12360    
12361                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
12362    
12363                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
12364                                    assetEntries = getAssetEntries(categoryId);
12365    
12366                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
12367                                            for (ModelListener<AssetCategory> listener : listeners) {
12368                                                    listener.onBeforeRemoveAssociation(categoryId,
12369                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12370                                                            assetEntry.getPrimaryKey());
12371                                            }
12372    
12373                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12374                                                    listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
12375                                                            AssetCategory.class.getName(), categoryId);
12376                                            }
12377                                    }
12378                            }
12379    
12380                            _sqlUpdate.update(new Object[] { new Long(categoryId) });
12381    
12382                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
12383                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
12384                                            for (ModelListener<AssetCategory> listener : listeners) {
12385                                                    listener.onAfterRemoveAssociation(categoryId,
12386                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12387                                                            assetEntry.getPrimaryKey());
12388                                            }
12389    
12390                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12391                                                    listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
12392                                                            AssetCategory.class.getName(), categoryId);
12393                                            }
12394                                    }
12395                            }
12396                    }
12397    
12398                    private SqlUpdate _sqlUpdate;
12399            }
12400    
12401            protected class RemoveAssetEntry {
12402                    protected RemoveAssetEntry() {
12403                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12404                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
12405                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12406                    }
12407    
12408                    protected void remove(long categoryId, long entryId)
12409                            throws SystemException {
12410                            if (containsAssetEntry.contains(categoryId, entryId)) {
12411                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
12412                                            assetEntryPersistence.getListeners();
12413    
12414                                    for (ModelListener<AssetCategory> listener : listeners) {
12415                                            listener.onBeforeRemoveAssociation(categoryId,
12416                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12417                                                    entryId);
12418                                    }
12419    
12420                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12421                                            listener.onBeforeRemoveAssociation(entryId,
12422                                                    AssetCategory.class.getName(), categoryId);
12423                                    }
12424    
12425                                    _sqlUpdate.update(new Object[] {
12426                                                    new Long(categoryId), new Long(entryId)
12427                                            });
12428    
12429                                    for (ModelListener<AssetCategory> listener : listeners) {
12430                                            listener.onAfterRemoveAssociation(categoryId,
12431                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
12432                                                    entryId);
12433                                    }
12434    
12435                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
12436                                            listener.onAfterRemoveAssociation(entryId,
12437                                                    AssetCategory.class.getName(), categoryId);
12438                                    }
12439                            }
12440                    }
12441    
12442                    private SqlUpdate _sqlUpdate;
12443            }
12444    
12445            protected boolean rebuildTreeEnabled = true;
12446            protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
12447            protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
12448            protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
12449            protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
12450            protected UpdateTree updateTree;
12451    
12452            protected class ExpandTreeLeftCategoryId {
12453                    protected ExpandTreeLeftCategoryId() {
12454                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12455                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12456                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12457                    }
12458    
12459                    protected void expand(long groupId, long leftCategoryId) {
12460                            _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
12461                    }
12462    
12463                    private SqlUpdate _sqlUpdate;
12464            }
12465    
12466            protected class ExpandTreeRightCategoryId {
12467                    protected ExpandTreeRightCategoryId() {
12468                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12469                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12470                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
12471                    }
12472    
12473                    protected void expand(long groupId, long rightCategoryId) {
12474                            _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
12475                    }
12476    
12477                    private SqlUpdate _sqlUpdate;
12478            }
12479    
12480            protected class ShrinkTreeLeftCategoryId {
12481                    protected ShrinkTreeLeftCategoryId() {
12482                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12483                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
12484                                            new int[] {
12485                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12486                                                    java.sql.Types.BIGINT
12487                                            });
12488                    }
12489    
12490                    protected void shrink(long groupId, long rightCategoryId, long delta) {
12491                            _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12492                    }
12493    
12494                    private SqlUpdate _sqlUpdate;
12495            }
12496    
12497            protected class ShrinkTreeRightCategoryId {
12498                    protected ShrinkTreeRightCategoryId() {
12499                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12500                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
12501                                            new int[] {
12502                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12503                                                    java.sql.Types.BIGINT
12504                                            });
12505                    }
12506    
12507                    protected void shrink(long groupId, long rightCategoryId, long delta) {
12508                            _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
12509                    }
12510    
12511                    private SqlUpdate _sqlUpdate;
12512            }
12513    
12514            protected class UpdateTree {
12515                    protected UpdateTree() {
12516                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
12517                                            "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
12518                                            new int[] {
12519                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
12520                                                    java.sql.Types.BIGINT
12521                                            });
12522                    }
12523    
12524                    protected void update(long categoryId, long leftCategoryId,
12525                            long rightCategoryId) {
12526                            _sqlUpdate.update(new Object[] {
12527                                            leftCategoryId, rightCategoryId, categoryId
12528                                    });
12529                    }
12530    
12531                    private SqlUpdate _sqlUpdate;
12532            }
12533    
12534            private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
12535            private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
12536            private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
12537            private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
12538            private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
12539            private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
12540            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
12541            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
12542            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
12543                    "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
12544            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
12545                    ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
12546            private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
12547            private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
12548            private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
12549            private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
12550            private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
12551            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
12552            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
12553            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
12554            private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
12555            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
12556                                    "uuid"
12557                            });
12558            private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
12559                            @Override
12560                            public Object clone() {
12561                                    return this;
12562                            }
12563    
12564                            @Override
12565                            public CacheModel<AssetCategory> toCacheModel() {
12566                                    return _nullAssetCategoryCacheModel;
12567                            }
12568                    };
12569    
12570            private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
12571                            @Override
12572                            public AssetCategory toEntityModel() {
12573                                    return _nullAssetCategory;
12574                            }
12575                    };
12576    }