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.SqlUpdate;
020    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.SQLQuery;
028    import com.liferay.portal.kernel.dao.orm.Session;
029    import com.liferay.portal.kernel.exception.SystemException;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.ArrayUtil;
033    import com.liferay.portal.kernel.util.CharPool;
034    import com.liferay.portal.kernel.util.GetterUtil;
035    import com.liferay.portal.kernel.util.InstanceFactory;
036    import com.liferay.portal.kernel.util.OrderByComparator;
037    import com.liferay.portal.kernel.util.SetUtil;
038    import com.liferay.portal.kernel.util.StringBundler;
039    import com.liferay.portal.kernel.util.StringPool;
040    import com.liferay.portal.kernel.util.StringUtil;
041    import com.liferay.portal.kernel.util.UnmodifiableList;
042    import com.liferay.portal.kernel.util.Validator;
043    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
044    import com.liferay.portal.model.CacheModel;
045    import com.liferay.portal.model.ModelListener;
046    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
047    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048    import com.liferay.portal.service.persistence.impl.TableMapper;
049    import com.liferay.portal.service.persistence.impl.TableMapperFactory;
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.HashSet;
061    import java.util.List;
062    import java.util.Set;
063    
064    /**
065     * The persistence implementation for the asset category service.
066     *
067     * <p>
068     * Caching information and settings can be found in <code>portal.properties</code>
069     * </p>
070     *
071     * @author Brian Wing Shun Chan
072     * @see AssetCategoryPersistence
073     * @see AssetCategoryUtil
074     * @generated
075     */
076    public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
077            implements AssetCategoryPersistence {
078            /*
079             * NOTE FOR DEVELOPERS:
080             *
081             * 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.
082             */
083            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
084            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
085                    ".List1";
086            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087                    ".List2";
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
089                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
090                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091                            "findAll", new String[0]);
092            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
093                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
094                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
095                            "findAll", new String[0]);
096            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
097                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
098                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
099            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
100                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
101                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
102                            "findByUuid",
103                            new String[] {
104                                    String.class.getName(),
105                                    
106                            Integer.class.getName(), Integer.class.getName(),
107                                    OrderByComparator.class.getName()
108                            });
109            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
110                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
111                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
112                            "findByUuid", new String[] { String.class.getName() },
113                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
114                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
116                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
118                            new String[] { String.class.getName() });
119    
120            /**
121             * Returns all the asset categories where uuid = &#63;.
122             *
123             * @param uuid the uuid
124             * @return the matching asset categories
125             * @throws SystemException if a system exception occurred
126             */
127            @Override
128            public List<AssetCategory> findByUuid(String uuid)
129                    throws SystemException {
130                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
131            }
132    
133            /**
134             * Returns a range of all the asset categories where uuid = &#63;.
135             *
136             * <p>
137             * 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.
138             * </p>
139             *
140             * @param uuid the uuid
141             * @param start the lower bound of the range of asset categories
142             * @param end the upper bound of the range of asset categories (not inclusive)
143             * @return the range of matching asset categories
144             * @throws SystemException if a system exception occurred
145             */
146            @Override
147            public List<AssetCategory> findByUuid(String uuid, int start, int end)
148                    throws SystemException {
149                    return findByUuid(uuid, start, end, null);
150            }
151    
152            /**
153             * Returns an ordered range of all the asset categories where uuid = &#63;.
154             *
155             * <p>
156             * 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.
157             * </p>
158             *
159             * @param uuid the uuid
160             * @param start the lower bound of the range of asset categories
161             * @param end the upper bound of the range of asset categories (not inclusive)
162             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
163             * @return the ordered range of matching asset categories
164             * @throws SystemException if a system exception occurred
165             */
166            @Override
167            public List<AssetCategory> findByUuid(String uuid, int start, int end,
168                    OrderByComparator orderByComparator) throws SystemException {
169                    boolean pagination = true;
170                    FinderPath finderPath = null;
171                    Object[] finderArgs = null;
172    
173                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
174                                    (orderByComparator == null)) {
175                            pagination = false;
176                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
177                            finderArgs = new Object[] { uuid };
178                    }
179                    else {
180                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
181                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
182                    }
183    
184                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
185                                    finderArgs, this);
186    
187                    if ((list != null) && !list.isEmpty()) {
188                            for (AssetCategory assetCategory : list) {
189                                    if (!Validator.equals(uuid, assetCategory.getUuid())) {
190                                            list = null;
191    
192                                            break;
193                                    }
194                            }
195                    }
196    
197                    if (list == null) {
198                            StringBundler query = null;
199    
200                            if (orderByComparator != null) {
201                                    query = new StringBundler(3 +
202                                                    (orderByComparator.getOrderByFields().length * 3));
203                            }
204                            else {
205                                    query = new StringBundler(3);
206                            }
207    
208                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
209    
210                            boolean bindUuid = false;
211    
212                            if (uuid == null) {
213                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
214                            }
215                            else if (uuid.equals(StringPool.BLANK)) {
216                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
217                            }
218                            else {
219                                    bindUuid = true;
220    
221                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
222                            }
223    
224                            if (orderByComparator != null) {
225                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
226                                            orderByComparator);
227                            }
228                            else
229                             if (pagination) {
230                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
231                            }
232    
233                            String sql = query.toString();
234    
235                            Session session = null;
236    
237                            try {
238                                    session = openSession();
239    
240                                    Query q = session.createQuery(sql);
241    
242                                    QueryPos qPos = QueryPos.getInstance(q);
243    
244                                    if (bindUuid) {
245                                            qPos.add(uuid);
246                                    }
247    
248                                    if (!pagination) {
249                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
250                                                            start, end, false);
251    
252                                            Collections.sort(list);
253    
254                                            list = new UnmodifiableList<AssetCategory>(list);
255                                    }
256                                    else {
257                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
258                                                            start, end);
259                                    }
260    
261                                    cacheResult(list);
262    
263                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
264                            }
265                            catch (Exception e) {
266                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
267    
268                                    throw processException(e);
269                            }
270                            finally {
271                                    closeSession(session);
272                            }
273                    }
274    
275                    return list;
276            }
277    
278            /**
279             * Returns the first asset category in the ordered set where uuid = &#63;.
280             *
281             * @param uuid the uuid
282             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
283             * @return the first matching asset category
284             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
285             * @throws SystemException if a system exception occurred
286             */
287            @Override
288            public AssetCategory findByUuid_First(String uuid,
289                    OrderByComparator orderByComparator)
290                    throws NoSuchCategoryException, SystemException {
291                    AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
292    
293                    if (assetCategory != null) {
294                            return assetCategory;
295                    }
296    
297                    StringBundler msg = new StringBundler(4);
298    
299                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
300    
301                    msg.append("uuid=");
302                    msg.append(uuid);
303    
304                    msg.append(StringPool.CLOSE_CURLY_BRACE);
305    
306                    throw new NoSuchCategoryException(msg.toString());
307            }
308    
309            /**
310             * Returns the first asset category in the ordered set where uuid = &#63;.
311             *
312             * @param uuid the uuid
313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
314             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
315             * @throws SystemException if a system exception occurred
316             */
317            @Override
318            public AssetCategory fetchByUuid_First(String uuid,
319                    OrderByComparator orderByComparator) throws SystemException {
320                    List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
321    
322                    if (!list.isEmpty()) {
323                            return list.get(0);
324                    }
325    
326                    return null;
327            }
328    
329            /**
330             * Returns the last asset category in the ordered set where uuid = &#63;.
331             *
332             * @param uuid the uuid
333             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
334             * @return the last matching asset category
335             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
336             * @throws SystemException if a system exception occurred
337             */
338            @Override
339            public AssetCategory findByUuid_Last(String uuid,
340                    OrderByComparator orderByComparator)
341                    throws NoSuchCategoryException, SystemException {
342                    AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
343    
344                    if (assetCategory != null) {
345                            return assetCategory;
346                    }
347    
348                    StringBundler msg = new StringBundler(4);
349    
350                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
351    
352                    msg.append("uuid=");
353                    msg.append(uuid);
354    
355                    msg.append(StringPool.CLOSE_CURLY_BRACE);
356    
357                    throw new NoSuchCategoryException(msg.toString());
358            }
359    
360            /**
361             * Returns the last asset category in the ordered set where uuid = &#63;.
362             *
363             * @param uuid the uuid
364             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
365             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
366             * @throws SystemException if a system exception occurred
367             */
368            @Override
369            public AssetCategory fetchByUuid_Last(String uuid,
370                    OrderByComparator orderByComparator) throws SystemException {
371                    int count = countByUuid(uuid);
372    
373                    if (count == 0) {
374                            return null;
375                    }
376    
377                    List<AssetCategory> list = findByUuid(uuid, count - 1, count,
378                                    orderByComparator);
379    
380                    if (!list.isEmpty()) {
381                            return list.get(0);
382                    }
383    
384                    return null;
385            }
386    
387            /**
388             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63;.
389             *
390             * @param categoryId the primary key of the current asset category
391             * @param uuid the uuid
392             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
393             * @return the previous, current, and next asset category
394             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
395             * @throws SystemException if a system exception occurred
396             */
397            @Override
398            public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
399                    OrderByComparator orderByComparator)
400                    throws NoSuchCategoryException, SystemException {
401                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
402    
403                    Session session = null;
404    
405                    try {
406                            session = openSession();
407    
408                            AssetCategory[] array = new AssetCategoryImpl[3];
409    
410                            array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
411                                            orderByComparator, true);
412    
413                            array[1] = assetCategory;
414    
415                            array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
416                                            orderByComparator, false);
417    
418                            return array;
419                    }
420                    catch (Exception e) {
421                            throw processException(e);
422                    }
423                    finally {
424                            closeSession(session);
425                    }
426            }
427    
428            protected AssetCategory getByUuid_PrevAndNext(Session session,
429                    AssetCategory assetCategory, String uuid,
430                    OrderByComparator orderByComparator, boolean previous) {
431                    StringBundler query = null;
432    
433                    if (orderByComparator != null) {
434                            query = new StringBundler(6 +
435                                            (orderByComparator.getOrderByFields().length * 6));
436                    }
437                    else {
438                            query = new StringBundler(3);
439                    }
440    
441                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
442    
443                    boolean bindUuid = false;
444    
445                    if (uuid == null) {
446                            query.append(_FINDER_COLUMN_UUID_UUID_1);
447                    }
448                    else if (uuid.equals(StringPool.BLANK)) {
449                            query.append(_FINDER_COLUMN_UUID_UUID_3);
450                    }
451                    else {
452                            bindUuid = true;
453    
454                            query.append(_FINDER_COLUMN_UUID_UUID_2);
455                    }
456    
457                    if (orderByComparator != null) {
458                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
459    
460                            if (orderByConditionFields.length > 0) {
461                                    query.append(WHERE_AND);
462                            }
463    
464                            for (int i = 0; i < orderByConditionFields.length; i++) {
465                                    query.append(_ORDER_BY_ENTITY_ALIAS);
466                                    query.append(orderByConditionFields[i]);
467    
468                                    if ((i + 1) < orderByConditionFields.length) {
469                                            if (orderByComparator.isAscending() ^ previous) {
470                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
471                                            }
472                                            else {
473                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
474                                            }
475                                    }
476                                    else {
477                                            if (orderByComparator.isAscending() ^ previous) {
478                                                    query.append(WHERE_GREATER_THAN);
479                                            }
480                                            else {
481                                                    query.append(WHERE_LESSER_THAN);
482                                            }
483                                    }
484                            }
485    
486                            query.append(ORDER_BY_CLAUSE);
487    
488                            String[] orderByFields = orderByComparator.getOrderByFields();
489    
490                            for (int i = 0; i < orderByFields.length; i++) {
491                                    query.append(_ORDER_BY_ENTITY_ALIAS);
492                                    query.append(orderByFields[i]);
493    
494                                    if ((i + 1) < orderByFields.length) {
495                                            if (orderByComparator.isAscending() ^ previous) {
496                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
497                                            }
498                                            else {
499                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
500                                            }
501                                    }
502                                    else {
503                                            if (orderByComparator.isAscending() ^ previous) {
504                                                    query.append(ORDER_BY_ASC);
505                                            }
506                                            else {
507                                                    query.append(ORDER_BY_DESC);
508                                            }
509                                    }
510                            }
511                    }
512                    else {
513                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
514                    }
515    
516                    String sql = query.toString();
517    
518                    Query q = session.createQuery(sql);
519    
520                    q.setFirstResult(0);
521                    q.setMaxResults(2);
522    
523                    QueryPos qPos = QueryPos.getInstance(q);
524    
525                    if (bindUuid) {
526                            qPos.add(uuid);
527                    }
528    
529                    if (orderByComparator != null) {
530                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
531    
532                            for (Object value : values) {
533                                    qPos.add(value);
534                            }
535                    }
536    
537                    List<AssetCategory> list = q.list();
538    
539                    if (list.size() == 2) {
540                            return list.get(1);
541                    }
542                    else {
543                            return null;
544                    }
545            }
546    
547            /**
548             * Removes all the asset categories where uuid = &#63; from the database.
549             *
550             * @param uuid the uuid
551             * @throws SystemException if a system exception occurred
552             */
553            @Override
554            public void removeByUuid(String uuid) throws SystemException {
555                    for (AssetCategory assetCategory : findByUuid(uuid, QueryUtil.ALL_POS,
556                                    QueryUtil.ALL_POS, null)) {
557                            remove(assetCategory);
558                    }
559            }
560    
561            /**
562             * Returns the number of asset categories where uuid = &#63;.
563             *
564             * @param uuid the uuid
565             * @return the number of matching asset categories
566             * @throws SystemException if a system exception occurred
567             */
568            @Override
569            public int countByUuid(String uuid) throws SystemException {
570                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
571    
572                    Object[] finderArgs = new Object[] { uuid };
573    
574                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
575                                    this);
576    
577                    if (count == null) {
578                            StringBundler query = new StringBundler(2);
579    
580                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
581    
582                            boolean bindUuid = false;
583    
584                            if (uuid == null) {
585                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
586                            }
587                            else if (uuid.equals(StringPool.BLANK)) {
588                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
589                            }
590                            else {
591                                    bindUuid = true;
592    
593                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
594                            }
595    
596                            String sql = query.toString();
597    
598                            Session session = null;
599    
600                            try {
601                                    session = openSession();
602    
603                                    Query q = session.createQuery(sql);
604    
605                                    QueryPos qPos = QueryPos.getInstance(q);
606    
607                                    if (bindUuid) {
608                                            qPos.add(uuid);
609                                    }
610    
611                                    count = (Long)q.uniqueResult();
612    
613                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
614                            }
615                            catch (Exception e) {
616                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
617    
618                                    throw processException(e);
619                            }
620                            finally {
621                                    closeSession(session);
622                            }
623                    }
624    
625                    return count.intValue();
626            }
627    
628            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
629            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
630            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '')";
631            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
632                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
633                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
634                            new String[] { String.class.getName(), Long.class.getName() },
635                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
636                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
637            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
638                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
639                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
640                            new String[] { String.class.getName(), Long.class.getName() });
641    
642            /**
643             * 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.
644             *
645             * @param uuid the uuid
646             * @param groupId the group ID
647             * @return the matching asset category
648             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
649             * @throws SystemException if a system exception occurred
650             */
651            @Override
652            public AssetCategory findByUUID_G(String uuid, long groupId)
653                    throws NoSuchCategoryException, SystemException {
654                    AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
655    
656                    if (assetCategory == null) {
657                            StringBundler msg = new StringBundler(6);
658    
659                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
660    
661                            msg.append("uuid=");
662                            msg.append(uuid);
663    
664                            msg.append(", groupId=");
665                            msg.append(groupId);
666    
667                            msg.append(StringPool.CLOSE_CURLY_BRACE);
668    
669                            if (_log.isWarnEnabled()) {
670                                    _log.warn(msg.toString());
671                            }
672    
673                            throw new NoSuchCategoryException(msg.toString());
674                    }
675    
676                    return assetCategory;
677            }
678    
679            /**
680             * 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.
681             *
682             * @param uuid the uuid
683             * @param groupId the group ID
684             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
685             * @throws SystemException if a system exception occurred
686             */
687            @Override
688            public AssetCategory fetchByUUID_G(String uuid, long groupId)
689                    throws SystemException {
690                    return fetchByUUID_G(uuid, groupId, true);
691            }
692    
693            /**
694             * 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.
695             *
696             * @param uuid the uuid
697             * @param groupId the group ID
698             * @param retrieveFromCache whether to use the finder cache
699             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
700             * @throws SystemException if a system exception occurred
701             */
702            @Override
703            public AssetCategory fetchByUUID_G(String uuid, long groupId,
704                    boolean retrieveFromCache) throws SystemException {
705                    Object[] finderArgs = new Object[] { uuid, groupId };
706    
707                    Object result = null;
708    
709                    if (retrieveFromCache) {
710                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
711                                            finderArgs, this);
712                    }
713    
714                    if (result instanceof AssetCategory) {
715                            AssetCategory assetCategory = (AssetCategory)result;
716    
717                            if (!Validator.equals(uuid, assetCategory.getUuid()) ||
718                                            (groupId != assetCategory.getGroupId())) {
719                                    result = null;
720                            }
721                    }
722    
723                    if (result == null) {
724                            StringBundler query = new StringBundler(4);
725    
726                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
727    
728                            boolean bindUuid = false;
729    
730                            if (uuid == null) {
731                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
732                            }
733                            else if (uuid.equals(StringPool.BLANK)) {
734                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
735                            }
736                            else {
737                                    bindUuid = true;
738    
739                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
740                            }
741    
742                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
743    
744                            String sql = query.toString();
745    
746                            Session session = null;
747    
748                            try {
749                                    session = openSession();
750    
751                                    Query q = session.createQuery(sql);
752    
753                                    QueryPos qPos = QueryPos.getInstance(q);
754    
755                                    if (bindUuid) {
756                                            qPos.add(uuid);
757                                    }
758    
759                                    qPos.add(groupId);
760    
761                                    List<AssetCategory> list = q.list();
762    
763                                    if (list.isEmpty()) {
764                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
765                                                    finderArgs, list);
766                                    }
767                                    else {
768                                            AssetCategory assetCategory = list.get(0);
769    
770                                            result = assetCategory;
771    
772                                            cacheResult(assetCategory);
773    
774                                            if ((assetCategory.getUuid() == null) ||
775                                                            !assetCategory.getUuid().equals(uuid) ||
776                                                            (assetCategory.getGroupId() != groupId)) {
777                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
778                                                            finderArgs, assetCategory);
779                                            }
780                                    }
781                            }
782                            catch (Exception e) {
783                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
784                                            finderArgs);
785    
786                                    throw processException(e);
787                            }
788                            finally {
789                                    closeSession(session);
790                            }
791                    }
792    
793                    if (result instanceof List<?>) {
794                            return null;
795                    }
796                    else {
797                            return (AssetCategory)result;
798                    }
799            }
800    
801            /**
802             * Removes the asset category where uuid = &#63; and groupId = &#63; from the database.
803             *
804             * @param uuid the uuid
805             * @param groupId the group ID
806             * @return the asset category that was removed
807             * @throws SystemException if a system exception occurred
808             */
809            @Override
810            public AssetCategory removeByUUID_G(String uuid, long groupId)
811                    throws NoSuchCategoryException, SystemException {
812                    AssetCategory assetCategory = findByUUID_G(uuid, groupId);
813    
814                    return remove(assetCategory);
815            }
816    
817            /**
818             * Returns the number of asset categories where uuid = &#63; and groupId = &#63;.
819             *
820             * @param uuid the uuid
821             * @param groupId the group ID
822             * @return the number of matching asset categories
823             * @throws SystemException if a system exception occurred
824             */
825            @Override
826            public int countByUUID_G(String uuid, long groupId)
827                    throws SystemException {
828                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
829    
830                    Object[] finderArgs = new Object[] { uuid, groupId };
831    
832                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
833                                    this);
834    
835                    if (count == null) {
836                            StringBundler query = new StringBundler(3);
837    
838                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
839    
840                            boolean bindUuid = false;
841    
842                            if (uuid == null) {
843                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
844                            }
845                            else if (uuid.equals(StringPool.BLANK)) {
846                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
847                            }
848                            else {
849                                    bindUuid = true;
850    
851                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
852                            }
853    
854                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
855    
856                            String sql = query.toString();
857    
858                            Session session = null;
859    
860                            try {
861                                    session = openSession();
862    
863                                    Query q = session.createQuery(sql);
864    
865                                    QueryPos qPos = QueryPos.getInstance(q);
866    
867                                    if (bindUuid) {
868                                            qPos.add(uuid);
869                                    }
870    
871                                    qPos.add(groupId);
872    
873                                    count = (Long)q.uniqueResult();
874    
875                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
876                            }
877                            catch (Exception e) {
878                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
879    
880                                    throw processException(e);
881                            }
882                            finally {
883                                    closeSession(session);
884                            }
885                    }
886    
887                    return count.intValue();
888            }
889    
890            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
891            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
892            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
893            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
894            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
895                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
896                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
897                            "findByUuid_C",
898                            new String[] {
899                                    String.class.getName(), Long.class.getName(),
900                                    
901                            Integer.class.getName(), Integer.class.getName(),
902                                    OrderByComparator.class.getName()
903                            });
904            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
905                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
906                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
907                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
908                            "findByUuid_C",
909                            new String[] { String.class.getName(), Long.class.getName() },
910                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
911                            AssetCategoryModelImpl.COMPANYID_COLUMN_BITMASK |
912                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
913            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
914                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
915                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
916                            new String[] { String.class.getName(), Long.class.getName() });
917    
918            /**
919             * Returns all the asset categories where uuid = &#63; and companyId = &#63;.
920             *
921             * @param uuid the uuid
922             * @param companyId the company ID
923             * @return the matching asset categories
924             * @throws SystemException if a system exception occurred
925             */
926            @Override
927            public List<AssetCategory> findByUuid_C(String uuid, long companyId)
928                    throws SystemException {
929                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
930                            QueryUtil.ALL_POS, null);
931            }
932    
933            /**
934             * Returns a range of all the asset categories where uuid = &#63; and companyId = &#63;.
935             *
936             * <p>
937             * 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.
938             * </p>
939             *
940             * @param uuid the uuid
941             * @param companyId the company ID
942             * @param start the lower bound of the range of asset categories
943             * @param end the upper bound of the range of asset categories (not inclusive)
944             * @return the range of matching asset categories
945             * @throws SystemException if a system exception occurred
946             */
947            @Override
948            public List<AssetCategory> findByUuid_C(String uuid, long companyId,
949                    int start, int end) throws SystemException {
950                    return findByUuid_C(uuid, companyId, start, end, null);
951            }
952    
953            /**
954             * Returns an ordered range of all the asset categories where uuid = &#63; and companyId = &#63;.
955             *
956             * <p>
957             * 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.
958             * </p>
959             *
960             * @param uuid the uuid
961             * @param companyId the company ID
962             * @param start the lower bound of the range of asset categories
963             * @param end the upper bound of the range of asset categories (not inclusive)
964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
965             * @return the ordered range of matching asset categories
966             * @throws SystemException if a system exception occurred
967             */
968            @Override
969            public List<AssetCategory> findByUuid_C(String uuid, long companyId,
970                    int start, int end, OrderByComparator orderByComparator)
971                    throws SystemException {
972                    boolean pagination = true;
973                    FinderPath finderPath = null;
974                    Object[] finderArgs = null;
975    
976                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
977                                    (orderByComparator == null)) {
978                            pagination = false;
979                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
980                            finderArgs = new Object[] { uuid, companyId };
981                    }
982                    else {
983                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
984                            finderArgs = new Object[] {
985                                            uuid, companyId,
986                                            
987                                            start, end, orderByComparator
988                                    };
989                    }
990    
991                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
992                                    finderArgs, this);
993    
994                    if ((list != null) && !list.isEmpty()) {
995                            for (AssetCategory assetCategory : list) {
996                                    if (!Validator.equals(uuid, assetCategory.getUuid()) ||
997                                                    (companyId != assetCategory.getCompanyId())) {
998                                            list = null;
999    
1000                                            break;
1001                                    }
1002                            }
1003                    }
1004    
1005                    if (list == null) {
1006                            StringBundler query = null;
1007    
1008                            if (orderByComparator != null) {
1009                                    query = new StringBundler(4 +
1010                                                    (orderByComparator.getOrderByFields().length * 3));
1011                            }
1012                            else {
1013                                    query = new StringBundler(4);
1014                            }
1015    
1016                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1017    
1018                            boolean bindUuid = false;
1019    
1020                            if (uuid == null) {
1021                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1022                            }
1023                            else if (uuid.equals(StringPool.BLANK)) {
1024                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1025                            }
1026                            else {
1027                                    bindUuid = true;
1028    
1029                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1030                            }
1031    
1032                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1033    
1034                            if (orderByComparator != null) {
1035                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1036                                            orderByComparator);
1037                            }
1038                            else
1039                             if (pagination) {
1040                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1041                            }
1042    
1043                            String sql = query.toString();
1044    
1045                            Session session = null;
1046    
1047                            try {
1048                                    session = openSession();
1049    
1050                                    Query q = session.createQuery(sql);
1051    
1052                                    QueryPos qPos = QueryPos.getInstance(q);
1053    
1054                                    if (bindUuid) {
1055                                            qPos.add(uuid);
1056                                    }
1057    
1058                                    qPos.add(companyId);
1059    
1060                                    if (!pagination) {
1061                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1062                                                            start, end, false);
1063    
1064                                            Collections.sort(list);
1065    
1066                                            list = new UnmodifiableList<AssetCategory>(list);
1067                                    }
1068                                    else {
1069                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1070                                                            start, end);
1071                                    }
1072    
1073                                    cacheResult(list);
1074    
1075                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1076                            }
1077                            catch (Exception e) {
1078                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1079    
1080                                    throw processException(e);
1081                            }
1082                            finally {
1083                                    closeSession(session);
1084                            }
1085                    }
1086    
1087                    return list;
1088            }
1089    
1090            /**
1091             * Returns the first asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1092             *
1093             * @param uuid the uuid
1094             * @param companyId the company ID
1095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1096             * @return the first matching asset category
1097             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1098             * @throws SystemException if a system exception occurred
1099             */
1100            @Override
1101            public AssetCategory findByUuid_C_First(String uuid, long companyId,
1102                    OrderByComparator orderByComparator)
1103                    throws NoSuchCategoryException, SystemException {
1104                    AssetCategory assetCategory = fetchByUuid_C_First(uuid, companyId,
1105                                    orderByComparator);
1106    
1107                    if (assetCategory != null) {
1108                            return assetCategory;
1109                    }
1110    
1111                    StringBundler msg = new StringBundler(6);
1112    
1113                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1114    
1115                    msg.append("uuid=");
1116                    msg.append(uuid);
1117    
1118                    msg.append(", companyId=");
1119                    msg.append(companyId);
1120    
1121                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1122    
1123                    throw new NoSuchCategoryException(msg.toString());
1124            }
1125    
1126            /**
1127             * Returns the first asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1128             *
1129             * @param uuid the uuid
1130             * @param companyId the company ID
1131             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1132             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1133             * @throws SystemException if a system exception occurred
1134             */
1135            @Override
1136            public AssetCategory fetchByUuid_C_First(String uuid, long companyId,
1137                    OrderByComparator orderByComparator) throws SystemException {
1138                    List<AssetCategory> list = findByUuid_C(uuid, companyId, 0, 1,
1139                                    orderByComparator);
1140    
1141                    if (!list.isEmpty()) {
1142                            return list.get(0);
1143                    }
1144    
1145                    return null;
1146            }
1147    
1148            /**
1149             * Returns the last asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1150             *
1151             * @param uuid the uuid
1152             * @param companyId the company ID
1153             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1154             * @return the last matching asset category
1155             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1156             * @throws SystemException if a system exception occurred
1157             */
1158            @Override
1159            public AssetCategory findByUuid_C_Last(String uuid, long companyId,
1160                    OrderByComparator orderByComparator)
1161                    throws NoSuchCategoryException, SystemException {
1162                    AssetCategory assetCategory = fetchByUuid_C_Last(uuid, companyId,
1163                                    orderByComparator);
1164    
1165                    if (assetCategory != null) {
1166                            return assetCategory;
1167                    }
1168    
1169                    StringBundler msg = new StringBundler(6);
1170    
1171                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1172    
1173                    msg.append("uuid=");
1174                    msg.append(uuid);
1175    
1176                    msg.append(", companyId=");
1177                    msg.append(companyId);
1178    
1179                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1180    
1181                    throw new NoSuchCategoryException(msg.toString());
1182            }
1183    
1184            /**
1185             * Returns the last asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1186             *
1187             * @param uuid the uuid
1188             * @param companyId the company ID
1189             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1190             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1191             * @throws SystemException if a system exception occurred
1192             */
1193            @Override
1194            public AssetCategory fetchByUuid_C_Last(String uuid, long companyId,
1195                    OrderByComparator orderByComparator) throws SystemException {
1196                    int count = countByUuid_C(uuid, companyId);
1197    
1198                    if (count == 0) {
1199                            return null;
1200                    }
1201    
1202                    List<AssetCategory> list = findByUuid_C(uuid, companyId, count - 1,
1203                                    count, orderByComparator);
1204    
1205                    if (!list.isEmpty()) {
1206                            return list.get(0);
1207                    }
1208    
1209                    return null;
1210            }
1211    
1212            /**
1213             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63; and companyId = &#63;.
1214             *
1215             * @param categoryId the primary key of the current asset category
1216             * @param uuid the uuid
1217             * @param companyId the company ID
1218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1219             * @return the previous, current, and next asset category
1220             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1221             * @throws SystemException if a system exception occurred
1222             */
1223            @Override
1224            public AssetCategory[] findByUuid_C_PrevAndNext(long categoryId,
1225                    String uuid, long companyId, OrderByComparator orderByComparator)
1226                    throws NoSuchCategoryException, SystemException {
1227                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1228    
1229                    Session session = null;
1230    
1231                    try {
1232                            session = openSession();
1233    
1234                            AssetCategory[] array = new AssetCategoryImpl[3];
1235    
1236                            array[0] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1237                                            companyId, orderByComparator, true);
1238    
1239                            array[1] = assetCategory;
1240    
1241                            array[2] = getByUuid_C_PrevAndNext(session, assetCategory, uuid,
1242                                            companyId, orderByComparator, false);
1243    
1244                            return array;
1245                    }
1246                    catch (Exception e) {
1247                            throw processException(e);
1248                    }
1249                    finally {
1250                            closeSession(session);
1251                    }
1252            }
1253    
1254            protected AssetCategory getByUuid_C_PrevAndNext(Session session,
1255                    AssetCategory assetCategory, String uuid, long companyId,
1256                    OrderByComparator orderByComparator, boolean previous) {
1257                    StringBundler query = null;
1258    
1259                    if (orderByComparator != null) {
1260                            query = new StringBundler(6 +
1261                                            (orderByComparator.getOrderByFields().length * 6));
1262                    }
1263                    else {
1264                            query = new StringBundler(3);
1265                    }
1266    
1267                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1268    
1269                    boolean bindUuid = false;
1270    
1271                    if (uuid == null) {
1272                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1273                    }
1274                    else if (uuid.equals(StringPool.BLANK)) {
1275                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1276                    }
1277                    else {
1278                            bindUuid = true;
1279    
1280                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1281                    }
1282    
1283                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1284    
1285                    if (orderByComparator != null) {
1286                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1287    
1288                            if (orderByConditionFields.length > 0) {
1289                                    query.append(WHERE_AND);
1290                            }
1291    
1292                            for (int i = 0; i < orderByConditionFields.length; i++) {
1293                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1294                                    query.append(orderByConditionFields[i]);
1295    
1296                                    if ((i + 1) < orderByConditionFields.length) {
1297                                            if (orderByComparator.isAscending() ^ previous) {
1298                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1299                                            }
1300                                            else {
1301                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1302                                            }
1303                                    }
1304                                    else {
1305                                            if (orderByComparator.isAscending() ^ previous) {
1306                                                    query.append(WHERE_GREATER_THAN);
1307                                            }
1308                                            else {
1309                                                    query.append(WHERE_LESSER_THAN);
1310                                            }
1311                                    }
1312                            }
1313    
1314                            query.append(ORDER_BY_CLAUSE);
1315    
1316                            String[] orderByFields = orderByComparator.getOrderByFields();
1317    
1318                            for (int i = 0; i < orderByFields.length; i++) {
1319                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1320                                    query.append(orderByFields[i]);
1321    
1322                                    if ((i + 1) < orderByFields.length) {
1323                                            if (orderByComparator.isAscending() ^ previous) {
1324                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1325                                            }
1326                                            else {
1327                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1328                                            }
1329                                    }
1330                                    else {
1331                                            if (orderByComparator.isAscending() ^ previous) {
1332                                                    query.append(ORDER_BY_ASC);
1333                                            }
1334                                            else {
1335                                                    query.append(ORDER_BY_DESC);
1336                                            }
1337                                    }
1338                            }
1339                    }
1340                    else {
1341                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1342                    }
1343    
1344                    String sql = query.toString();
1345    
1346                    Query q = session.createQuery(sql);
1347    
1348                    q.setFirstResult(0);
1349                    q.setMaxResults(2);
1350    
1351                    QueryPos qPos = QueryPos.getInstance(q);
1352    
1353                    if (bindUuid) {
1354                            qPos.add(uuid);
1355                    }
1356    
1357                    qPos.add(companyId);
1358    
1359                    if (orderByComparator != null) {
1360                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1361    
1362                            for (Object value : values) {
1363                                    qPos.add(value);
1364                            }
1365                    }
1366    
1367                    List<AssetCategory> list = q.list();
1368    
1369                    if (list.size() == 2) {
1370                            return list.get(1);
1371                    }
1372                    else {
1373                            return null;
1374                    }
1375            }
1376    
1377            /**
1378             * Removes all the asset categories where uuid = &#63; and companyId = &#63; from the database.
1379             *
1380             * @param uuid the uuid
1381             * @param companyId the company ID
1382             * @throws SystemException if a system exception occurred
1383             */
1384            @Override
1385            public void removeByUuid_C(String uuid, long companyId)
1386                    throws SystemException {
1387                    for (AssetCategory assetCategory : findByUuid_C(uuid, companyId,
1388                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1389                            remove(assetCategory);
1390                    }
1391            }
1392    
1393            /**
1394             * Returns the number of asset categories where uuid = &#63; and companyId = &#63;.
1395             *
1396             * @param uuid the uuid
1397             * @param companyId the company ID
1398             * @return the number of matching asset categories
1399             * @throws SystemException if a system exception occurred
1400             */
1401            @Override
1402            public int countByUuid_C(String uuid, long companyId)
1403                    throws SystemException {
1404                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1405    
1406                    Object[] finderArgs = new Object[] { uuid, companyId };
1407    
1408                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1409                                    this);
1410    
1411                    if (count == null) {
1412                            StringBundler query = new StringBundler(3);
1413    
1414                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
1415    
1416                            boolean bindUuid = false;
1417    
1418                            if (uuid == null) {
1419                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1420                            }
1421                            else if (uuid.equals(StringPool.BLANK)) {
1422                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1423                            }
1424                            else {
1425                                    bindUuid = true;
1426    
1427                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1428                            }
1429    
1430                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1431    
1432                            String sql = query.toString();
1433    
1434                            Session session = null;
1435    
1436                            try {
1437                                    session = openSession();
1438    
1439                                    Query q = session.createQuery(sql);
1440    
1441                                    QueryPos qPos = QueryPos.getInstance(q);
1442    
1443                                    if (bindUuid) {
1444                                            qPos.add(uuid);
1445                                    }
1446    
1447                                    qPos.add(companyId);
1448    
1449                                    count = (Long)q.uniqueResult();
1450    
1451                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1452                            }
1453                            catch (Exception e) {
1454                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1455    
1456                                    throw processException(e);
1457                            }
1458                            finally {
1459                                    closeSession(session);
1460                            }
1461                    }
1462    
1463                    return count.intValue();
1464            }
1465    
1466            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetCategory.uuid IS NULL AND ";
1467            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetCategory.uuid = ? AND ";
1468            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = '') AND ";
1469            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetCategory.companyId = ?";
1470            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1471                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1472                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1473                            "findByGroupId",
1474                            new String[] {
1475                                    Long.class.getName(),
1476                                    
1477                            Integer.class.getName(), Integer.class.getName(),
1478                                    OrderByComparator.class.getName()
1479                            });
1480            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1481                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1482                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
1483                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
1484                            "findByGroupId", new String[] { Long.class.getName() },
1485                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
1486                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
1487            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1488                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1489                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1490                            new String[] { Long.class.getName() });
1491    
1492            /**
1493             * Returns all the asset categories where groupId = &#63;.
1494             *
1495             * @param groupId the group ID
1496             * @return the matching asset categories
1497             * @throws SystemException if a system exception occurred
1498             */
1499            @Override
1500            public List<AssetCategory> findByGroupId(long groupId)
1501                    throws SystemException {
1502                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1503            }
1504    
1505            /**
1506             * Returns a range of all the asset categories where groupId = &#63;.
1507             *
1508             * <p>
1509             * 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.
1510             * </p>
1511             *
1512             * @param groupId the group ID
1513             * @param start the lower bound of the range of asset categories
1514             * @param end the upper bound of the range of asset categories (not inclusive)
1515             * @return the range of matching asset categories
1516             * @throws SystemException if a system exception occurred
1517             */
1518            @Override
1519            public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1520                    throws SystemException {
1521                    return findByGroupId(groupId, start, end, null);
1522            }
1523    
1524            /**
1525             * Returns an ordered range of all the asset categories where groupId = &#63;.
1526             *
1527             * <p>
1528             * 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.
1529             * </p>
1530             *
1531             * @param groupId the group ID
1532             * @param start the lower bound of the range of asset categories
1533             * @param end the upper bound of the range of asset categories (not inclusive)
1534             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1535             * @return the ordered range of matching asset categories
1536             * @throws SystemException if a system exception occurred
1537             */
1538            @Override
1539            public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1540                    OrderByComparator orderByComparator) throws SystemException {
1541                    boolean pagination = true;
1542                    FinderPath finderPath = null;
1543                    Object[] finderArgs = null;
1544    
1545                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1546                                    (orderByComparator == null)) {
1547                            pagination = false;
1548                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1549                            finderArgs = new Object[] { groupId };
1550                    }
1551                    else {
1552                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1553                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1554                    }
1555    
1556                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1557                                    finderArgs, this);
1558    
1559                    if ((list != null) && !list.isEmpty()) {
1560                            for (AssetCategory assetCategory : list) {
1561                                    if ((groupId != assetCategory.getGroupId())) {
1562                                            list = null;
1563    
1564                                            break;
1565                                    }
1566                            }
1567                    }
1568    
1569                    if (list == null) {
1570                            StringBundler query = null;
1571    
1572                            if (orderByComparator != null) {
1573                                    query = new StringBundler(3 +
1574                                                    (orderByComparator.getOrderByFields().length * 3));
1575                            }
1576                            else {
1577                                    query = new StringBundler(3);
1578                            }
1579    
1580                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1581    
1582                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1583    
1584                            if (orderByComparator != null) {
1585                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1586                                            orderByComparator);
1587                            }
1588                            else
1589                             if (pagination) {
1590                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1591                            }
1592    
1593                            String sql = query.toString();
1594    
1595                            Session session = null;
1596    
1597                            try {
1598                                    session = openSession();
1599    
1600                                    Query q = session.createQuery(sql);
1601    
1602                                    QueryPos qPos = QueryPos.getInstance(q);
1603    
1604                                    qPos.add(groupId);
1605    
1606                                    if (!pagination) {
1607                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1608                                                            start, end, false);
1609    
1610                                            Collections.sort(list);
1611    
1612                                            list = new UnmodifiableList<AssetCategory>(list);
1613                                    }
1614                                    else {
1615                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1616                                                            start, end);
1617                                    }
1618    
1619                                    cacheResult(list);
1620    
1621                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1622                            }
1623                            catch (Exception e) {
1624                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1625    
1626                                    throw processException(e);
1627                            }
1628                            finally {
1629                                    closeSession(session);
1630                            }
1631                    }
1632    
1633                    return list;
1634            }
1635    
1636            /**
1637             * Returns the first asset category in the ordered set where groupId = &#63;.
1638             *
1639             * @param groupId the group ID
1640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1641             * @return the first matching asset category
1642             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1643             * @throws SystemException if a system exception occurred
1644             */
1645            @Override
1646            public AssetCategory findByGroupId_First(long groupId,
1647                    OrderByComparator orderByComparator)
1648                    throws NoSuchCategoryException, SystemException {
1649                    AssetCategory assetCategory = fetchByGroupId_First(groupId,
1650                                    orderByComparator);
1651    
1652                    if (assetCategory != null) {
1653                            return assetCategory;
1654                    }
1655    
1656                    StringBundler msg = new StringBundler(4);
1657    
1658                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1659    
1660                    msg.append("groupId=");
1661                    msg.append(groupId);
1662    
1663                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1664    
1665                    throw new NoSuchCategoryException(msg.toString());
1666            }
1667    
1668            /**
1669             * Returns the first asset category in the ordered set where groupId = &#63;.
1670             *
1671             * @param groupId the group ID
1672             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1673             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1674             * @throws SystemException if a system exception occurred
1675             */
1676            @Override
1677            public AssetCategory fetchByGroupId_First(long groupId,
1678                    OrderByComparator orderByComparator) throws SystemException {
1679                    List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1680                                    orderByComparator);
1681    
1682                    if (!list.isEmpty()) {
1683                            return list.get(0);
1684                    }
1685    
1686                    return null;
1687            }
1688    
1689            /**
1690             * Returns the last asset category in the ordered set where groupId = &#63;.
1691             *
1692             * @param groupId the group ID
1693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1694             * @return the last matching asset category
1695             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1696             * @throws SystemException if a system exception occurred
1697             */
1698            @Override
1699            public AssetCategory findByGroupId_Last(long groupId,
1700                    OrderByComparator orderByComparator)
1701                    throws NoSuchCategoryException, SystemException {
1702                    AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1703                                    orderByComparator);
1704    
1705                    if (assetCategory != null) {
1706                            return assetCategory;
1707                    }
1708    
1709                    StringBundler msg = new StringBundler(4);
1710    
1711                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1712    
1713                    msg.append("groupId=");
1714                    msg.append(groupId);
1715    
1716                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1717    
1718                    throw new NoSuchCategoryException(msg.toString());
1719            }
1720    
1721            /**
1722             * Returns the last asset category in the ordered set where groupId = &#63;.
1723             *
1724             * @param groupId the group ID
1725             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1726             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1727             * @throws SystemException if a system exception occurred
1728             */
1729            @Override
1730            public AssetCategory fetchByGroupId_Last(long groupId,
1731                    OrderByComparator orderByComparator) throws SystemException {
1732                    int count = countByGroupId(groupId);
1733    
1734                    if (count == 0) {
1735                            return null;
1736                    }
1737    
1738                    List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1739                                    orderByComparator);
1740    
1741                    if (!list.isEmpty()) {
1742                            return list.get(0);
1743                    }
1744    
1745                    return null;
1746            }
1747    
1748            /**
1749             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63;.
1750             *
1751             * @param categoryId the primary key of the current asset category
1752             * @param groupId the group ID
1753             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1754             * @return the previous, current, and next asset category
1755             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1756             * @throws SystemException if a system exception occurred
1757             */
1758            @Override
1759            public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1760                    long groupId, OrderByComparator orderByComparator)
1761                    throws NoSuchCategoryException, SystemException {
1762                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1763    
1764                    Session session = null;
1765    
1766                    try {
1767                            session = openSession();
1768    
1769                            AssetCategory[] array = new AssetCategoryImpl[3];
1770    
1771                            array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1772                                            groupId, orderByComparator, true);
1773    
1774                            array[1] = assetCategory;
1775    
1776                            array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1777                                            groupId, orderByComparator, false);
1778    
1779                            return array;
1780                    }
1781                    catch (Exception e) {
1782                            throw processException(e);
1783                    }
1784                    finally {
1785                            closeSession(session);
1786                    }
1787            }
1788    
1789            protected AssetCategory getByGroupId_PrevAndNext(Session session,
1790                    AssetCategory assetCategory, long groupId,
1791                    OrderByComparator orderByComparator, boolean previous) {
1792                    StringBundler query = null;
1793    
1794                    if (orderByComparator != null) {
1795                            query = new StringBundler(6 +
1796                                            (orderByComparator.getOrderByFields().length * 6));
1797                    }
1798                    else {
1799                            query = new StringBundler(3);
1800                    }
1801    
1802                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1803    
1804                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1805    
1806                    if (orderByComparator != null) {
1807                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1808    
1809                            if (orderByConditionFields.length > 0) {
1810                                    query.append(WHERE_AND);
1811                            }
1812    
1813                            for (int i = 0; i < orderByConditionFields.length; i++) {
1814                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1815                                    query.append(orderByConditionFields[i]);
1816    
1817                                    if ((i + 1) < orderByConditionFields.length) {
1818                                            if (orderByComparator.isAscending() ^ previous) {
1819                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1820                                            }
1821                                            else {
1822                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1823                                            }
1824                                    }
1825                                    else {
1826                                            if (orderByComparator.isAscending() ^ previous) {
1827                                                    query.append(WHERE_GREATER_THAN);
1828                                            }
1829                                            else {
1830                                                    query.append(WHERE_LESSER_THAN);
1831                                            }
1832                                    }
1833                            }
1834    
1835                            query.append(ORDER_BY_CLAUSE);
1836    
1837                            String[] orderByFields = orderByComparator.getOrderByFields();
1838    
1839                            for (int i = 0; i < orderByFields.length; i++) {
1840                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1841                                    query.append(orderByFields[i]);
1842    
1843                                    if ((i + 1) < orderByFields.length) {
1844                                            if (orderByComparator.isAscending() ^ previous) {
1845                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1846                                            }
1847                                            else {
1848                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1849                                            }
1850                                    }
1851                                    else {
1852                                            if (orderByComparator.isAscending() ^ previous) {
1853                                                    query.append(ORDER_BY_ASC);
1854                                            }
1855                                            else {
1856                                                    query.append(ORDER_BY_DESC);
1857                                            }
1858                                    }
1859                            }
1860                    }
1861                    else {
1862                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1863                    }
1864    
1865                    String sql = query.toString();
1866    
1867                    Query q = session.createQuery(sql);
1868    
1869                    q.setFirstResult(0);
1870                    q.setMaxResults(2);
1871    
1872                    QueryPos qPos = QueryPos.getInstance(q);
1873    
1874                    qPos.add(groupId);
1875    
1876                    if (orderByComparator != null) {
1877                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1878    
1879                            for (Object value : values) {
1880                                    qPos.add(value);
1881                            }
1882                    }
1883    
1884                    List<AssetCategory> list = q.list();
1885    
1886                    if (list.size() == 2) {
1887                            return list.get(1);
1888                    }
1889                    else {
1890                            return null;
1891                    }
1892            }
1893    
1894            /**
1895             * Returns all the asset categories that the user has permission to view where groupId = &#63;.
1896             *
1897             * @param groupId the group ID
1898             * @return the matching asset categories that the user has permission to view
1899             * @throws SystemException if a system exception occurred
1900             */
1901            @Override
1902            public List<AssetCategory> filterFindByGroupId(long groupId)
1903                    throws SystemException {
1904                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1905                            QueryUtil.ALL_POS, null);
1906            }
1907    
1908            /**
1909             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63;.
1910             *
1911             * <p>
1912             * 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.
1913             * </p>
1914             *
1915             * @param groupId the group ID
1916             * @param start the lower bound of the range of asset categories
1917             * @param end the upper bound of the range of asset categories (not inclusive)
1918             * @return the range of matching asset categories that the user has permission to view
1919             * @throws SystemException if a system exception occurred
1920             */
1921            @Override
1922            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1923                    int end) throws SystemException {
1924                    return filterFindByGroupId(groupId, start, end, null);
1925            }
1926    
1927            /**
1928             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63;.
1929             *
1930             * <p>
1931             * 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.
1932             * </p>
1933             *
1934             * @param groupId the group ID
1935             * @param start the lower bound of the range of asset categories
1936             * @param end the upper bound of the range of asset categories (not inclusive)
1937             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1938             * @return the ordered range of matching asset categories that the user has permission to view
1939             * @throws SystemException if a system exception occurred
1940             */
1941            @Override
1942            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1943                    int end, OrderByComparator orderByComparator) throws SystemException {
1944                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1945                            return findByGroupId(groupId, start, end, orderByComparator);
1946                    }
1947    
1948                    StringBundler query = null;
1949    
1950                    if (orderByComparator != null) {
1951                            query = new StringBundler(3 +
1952                                            (orderByComparator.getOrderByFields().length * 3));
1953                    }
1954                    else {
1955                            query = new StringBundler(3);
1956                    }
1957    
1958                    if (getDB().isSupportsInlineDistinct()) {
1959                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1960                    }
1961                    else {
1962                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1963                    }
1964    
1965                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1966    
1967                    if (!getDB().isSupportsInlineDistinct()) {
1968                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1969                    }
1970    
1971                    if (orderByComparator != null) {
1972                            if (getDB().isSupportsInlineDistinct()) {
1973                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1974                                            orderByComparator, true);
1975                            }
1976                            else {
1977                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1978                                            orderByComparator, true);
1979                            }
1980                    }
1981                    else {
1982                            if (getDB().isSupportsInlineDistinct()) {
1983                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1984                            }
1985                            else {
1986                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1987                            }
1988                    }
1989    
1990                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1991                                    AssetCategory.class.getName(),
1992                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1993    
1994                    Session session = null;
1995    
1996                    try {
1997                            session = openSession();
1998    
1999                            SQLQuery q = session.createSQLQuery(sql);
2000    
2001                            if (getDB().isSupportsInlineDistinct()) {
2002                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2003                            }
2004                            else {
2005                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2006                            }
2007    
2008                            QueryPos qPos = QueryPos.getInstance(q);
2009    
2010                            qPos.add(groupId);
2011    
2012                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2013                                    end);
2014                    }
2015                    catch (Exception e) {
2016                            throw processException(e);
2017                    }
2018                    finally {
2019                            closeSession(session);
2020                    }
2021            }
2022    
2023            /**
2024             * 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;.
2025             *
2026             * @param categoryId the primary key of the current asset category
2027             * @param groupId the group ID
2028             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2029             * @return the previous, current, and next asset category
2030             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2031             * @throws SystemException if a system exception occurred
2032             */
2033            @Override
2034            public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2035                    long groupId, OrderByComparator orderByComparator)
2036                    throws NoSuchCategoryException, SystemException {
2037                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2038                            return findByGroupId_PrevAndNext(categoryId, groupId,
2039                                    orderByComparator);
2040                    }
2041    
2042                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2043    
2044                    Session session = null;
2045    
2046                    try {
2047                            session = openSession();
2048    
2049                            AssetCategory[] array = new AssetCategoryImpl[3];
2050    
2051                            array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2052                                            groupId, orderByComparator, true);
2053    
2054                            array[1] = assetCategory;
2055    
2056                            array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2057                                            groupId, orderByComparator, false);
2058    
2059                            return array;
2060                    }
2061                    catch (Exception e) {
2062                            throw processException(e);
2063                    }
2064                    finally {
2065                            closeSession(session);
2066                    }
2067            }
2068    
2069            protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2070                    AssetCategory assetCategory, long groupId,
2071                    OrderByComparator orderByComparator, boolean previous) {
2072                    StringBundler query = null;
2073    
2074                    if (orderByComparator != null) {
2075                            query = new StringBundler(6 +
2076                                            (orderByComparator.getOrderByFields().length * 6));
2077                    }
2078                    else {
2079                            query = new StringBundler(3);
2080                    }
2081    
2082                    if (getDB().isSupportsInlineDistinct()) {
2083                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2084                    }
2085                    else {
2086                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2087                    }
2088    
2089                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2090    
2091                    if (!getDB().isSupportsInlineDistinct()) {
2092                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2093                    }
2094    
2095                    if (orderByComparator != null) {
2096                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2097    
2098                            if (orderByConditionFields.length > 0) {
2099                                    query.append(WHERE_AND);
2100                            }
2101    
2102                            for (int i = 0; i < orderByConditionFields.length; i++) {
2103                                    if (getDB().isSupportsInlineDistinct()) {
2104                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2105                                    }
2106                                    else {
2107                                            query.append(_ORDER_BY_ENTITY_TABLE);
2108                                    }
2109    
2110                                    query.append(orderByConditionFields[i]);
2111    
2112                                    if ((i + 1) < orderByConditionFields.length) {
2113                                            if (orderByComparator.isAscending() ^ previous) {
2114                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2115                                            }
2116                                            else {
2117                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2118                                            }
2119                                    }
2120                                    else {
2121                                            if (orderByComparator.isAscending() ^ previous) {
2122                                                    query.append(WHERE_GREATER_THAN);
2123                                            }
2124                                            else {
2125                                                    query.append(WHERE_LESSER_THAN);
2126                                            }
2127                                    }
2128                            }
2129    
2130                            query.append(ORDER_BY_CLAUSE);
2131    
2132                            String[] orderByFields = orderByComparator.getOrderByFields();
2133    
2134                            for (int i = 0; i < orderByFields.length; i++) {
2135                                    if (getDB().isSupportsInlineDistinct()) {
2136                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2137                                    }
2138                                    else {
2139                                            query.append(_ORDER_BY_ENTITY_TABLE);
2140                                    }
2141    
2142                                    query.append(orderByFields[i]);
2143    
2144                                    if ((i + 1) < orderByFields.length) {
2145                                            if (orderByComparator.isAscending() ^ previous) {
2146                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2147                                            }
2148                                            else {
2149                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2150                                            }
2151                                    }
2152                                    else {
2153                                            if (orderByComparator.isAscending() ^ previous) {
2154                                                    query.append(ORDER_BY_ASC);
2155                                            }
2156                                            else {
2157                                                    query.append(ORDER_BY_DESC);
2158                                            }
2159                                    }
2160                            }
2161                    }
2162                    else {
2163                            if (getDB().isSupportsInlineDistinct()) {
2164                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2165                            }
2166                            else {
2167                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2168                            }
2169                    }
2170    
2171                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2172                                    AssetCategory.class.getName(),
2173                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2174    
2175                    SQLQuery q = session.createSQLQuery(sql);
2176    
2177                    q.setFirstResult(0);
2178                    q.setMaxResults(2);
2179    
2180                    if (getDB().isSupportsInlineDistinct()) {
2181                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2182                    }
2183                    else {
2184                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2185                    }
2186    
2187                    QueryPos qPos = QueryPos.getInstance(q);
2188    
2189                    qPos.add(groupId);
2190    
2191                    if (orderByComparator != null) {
2192                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2193    
2194                            for (Object value : values) {
2195                                    qPos.add(value);
2196                            }
2197                    }
2198    
2199                    List<AssetCategory> list = q.list();
2200    
2201                    if (list.size() == 2) {
2202                            return list.get(1);
2203                    }
2204                    else {
2205                            return null;
2206                    }
2207            }
2208    
2209            /**
2210             * Removes all the asset categories where groupId = &#63; from the database.
2211             *
2212             * @param groupId the group ID
2213             * @throws SystemException if a system exception occurred
2214             */
2215            @Override
2216            public void removeByGroupId(long groupId) throws SystemException {
2217                    for (AssetCategory assetCategory : findByGroupId(groupId,
2218                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2219                            remove(assetCategory);
2220                    }
2221            }
2222    
2223            /**
2224             * Returns the number of asset categories where groupId = &#63;.
2225             *
2226             * @param groupId the group ID
2227             * @return the number of matching asset categories
2228             * @throws SystemException if a system exception occurred
2229             */
2230            @Override
2231            public int countByGroupId(long groupId) throws SystemException {
2232                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2233    
2234                    Object[] finderArgs = new Object[] { groupId };
2235    
2236                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2237                                    this);
2238    
2239                    if (count == null) {
2240                            StringBundler query = new StringBundler(2);
2241    
2242                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2243    
2244                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2245    
2246                            String sql = query.toString();
2247    
2248                            Session session = null;
2249    
2250                            try {
2251                                    session = openSession();
2252    
2253                                    Query q = session.createQuery(sql);
2254    
2255                                    QueryPos qPos = QueryPos.getInstance(q);
2256    
2257                                    qPos.add(groupId);
2258    
2259                                    count = (Long)q.uniqueResult();
2260    
2261                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2262                            }
2263                            catch (Exception e) {
2264                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2265    
2266                                    throw processException(e);
2267                            }
2268                            finally {
2269                                    closeSession(session);
2270                            }
2271                    }
2272    
2273                    return count.intValue();
2274            }
2275    
2276            /**
2277             * Returns the number of asset categories that the user has permission to view where groupId = &#63;.
2278             *
2279             * @param groupId the group ID
2280             * @return the number of matching asset categories that the user has permission to view
2281             * @throws SystemException if a system exception occurred
2282             */
2283            @Override
2284            public int filterCountByGroupId(long groupId) throws SystemException {
2285                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2286                            return countByGroupId(groupId);
2287                    }
2288    
2289                    StringBundler query = new StringBundler(2);
2290    
2291                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
2292    
2293                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2294    
2295                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2296                                    AssetCategory.class.getName(),
2297                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2298    
2299                    Session session = null;
2300    
2301                    try {
2302                            session = openSession();
2303    
2304                            SQLQuery q = session.createSQLQuery(sql);
2305    
2306                            q.addScalar(COUNT_COLUMN_NAME,
2307                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2308    
2309                            QueryPos qPos = QueryPos.getInstance(q);
2310    
2311                            qPos.add(groupId);
2312    
2313                            Long count = (Long)q.uniqueResult();
2314    
2315                            return count.intValue();
2316                    }
2317                    catch (Exception e) {
2318                            throw processException(e);
2319                    }
2320                    finally {
2321                            closeSession(session);
2322                    }
2323            }
2324    
2325            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
2326            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
2327                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2328                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2329                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2330                            "findByParentCategoryId",
2331                            new String[] {
2332                                    Long.class.getName(),
2333                                    
2334                            Integer.class.getName(), Integer.class.getName(),
2335                                    OrderByComparator.class.getName()
2336                            });
2337            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
2338                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2339                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2340                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2341                            "findByParentCategoryId", new String[] { Long.class.getName() },
2342                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
2343                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2344            public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2345                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2346                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2347                            "countByParentCategoryId", new String[] { Long.class.getName() });
2348    
2349            /**
2350             * Returns all the asset categories where parentCategoryId = &#63;.
2351             *
2352             * @param parentCategoryId the parent category ID
2353             * @return the matching asset categories
2354             * @throws SystemException if a system exception occurred
2355             */
2356            @Override
2357            public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2358                    throws SystemException {
2359                    return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2360                            QueryUtil.ALL_POS, null);
2361            }
2362    
2363            /**
2364             * Returns a range of all the asset categories where parentCategoryId = &#63;.
2365             *
2366             * <p>
2367             * 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.
2368             * </p>
2369             *
2370             * @param parentCategoryId the parent category ID
2371             * @param start the lower bound of the range of asset categories
2372             * @param end the upper bound of the range of asset categories (not inclusive)
2373             * @return the range of matching asset categories
2374             * @throws SystemException if a system exception occurred
2375             */
2376            @Override
2377            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2378                    int start, int end) throws SystemException {
2379                    return findByParentCategoryId(parentCategoryId, start, end, null);
2380            }
2381    
2382            /**
2383             * Returns an ordered range of all the asset categories where parentCategoryId = &#63;.
2384             *
2385             * <p>
2386             * 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.
2387             * </p>
2388             *
2389             * @param parentCategoryId the parent category ID
2390             * @param start the lower bound of the range of asset categories
2391             * @param end the upper bound of the range of asset categories (not inclusive)
2392             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2393             * @return the ordered range of matching asset categories
2394             * @throws SystemException if a system exception occurred
2395             */
2396            @Override
2397            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2398                    int start, int end, OrderByComparator orderByComparator)
2399                    throws SystemException {
2400                    boolean pagination = true;
2401                    FinderPath finderPath = null;
2402                    Object[] finderArgs = null;
2403    
2404                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2405                                    (orderByComparator == null)) {
2406                            pagination = false;
2407                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2408                            finderArgs = new Object[] { parentCategoryId };
2409                    }
2410                    else {
2411                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2412                            finderArgs = new Object[] {
2413                                            parentCategoryId,
2414                                            
2415                                            start, end, orderByComparator
2416                                    };
2417                    }
2418    
2419                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2420                                    finderArgs, this);
2421    
2422                    if ((list != null) && !list.isEmpty()) {
2423                            for (AssetCategory assetCategory : list) {
2424                                    if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2425                                            list = null;
2426    
2427                                            break;
2428                                    }
2429                            }
2430                    }
2431    
2432                    if (list == null) {
2433                            StringBundler query = null;
2434    
2435                            if (orderByComparator != null) {
2436                                    query = new StringBundler(3 +
2437                                                    (orderByComparator.getOrderByFields().length * 3));
2438                            }
2439                            else {
2440                                    query = new StringBundler(3);
2441                            }
2442    
2443                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2444    
2445                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2446    
2447                            if (orderByComparator != null) {
2448                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2449                                            orderByComparator);
2450                            }
2451                            else
2452                             if (pagination) {
2453                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2454                            }
2455    
2456                            String sql = query.toString();
2457    
2458                            Session session = null;
2459    
2460                            try {
2461                                    session = openSession();
2462    
2463                                    Query q = session.createQuery(sql);
2464    
2465                                    QueryPos qPos = QueryPos.getInstance(q);
2466    
2467                                    qPos.add(parentCategoryId);
2468    
2469                                    if (!pagination) {
2470                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2471                                                            start, end, false);
2472    
2473                                            Collections.sort(list);
2474    
2475                                            list = new UnmodifiableList<AssetCategory>(list);
2476                                    }
2477                                    else {
2478                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2479                                                            start, end);
2480                                    }
2481    
2482                                    cacheResult(list);
2483    
2484                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2485                            }
2486                            catch (Exception e) {
2487                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2488    
2489                                    throw processException(e);
2490                            }
2491                            finally {
2492                                    closeSession(session);
2493                            }
2494                    }
2495    
2496                    return list;
2497            }
2498    
2499            /**
2500             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2501             *
2502             * @param parentCategoryId the parent category ID
2503             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2504             * @return the first matching asset category
2505             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2506             * @throws SystemException if a system exception occurred
2507             */
2508            @Override
2509            public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2510                    OrderByComparator orderByComparator)
2511                    throws NoSuchCategoryException, SystemException {
2512                    AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2513                                    orderByComparator);
2514    
2515                    if (assetCategory != null) {
2516                            return assetCategory;
2517                    }
2518    
2519                    StringBundler msg = new StringBundler(4);
2520    
2521                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2522    
2523                    msg.append("parentCategoryId=");
2524                    msg.append(parentCategoryId);
2525    
2526                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2527    
2528                    throw new NoSuchCategoryException(msg.toString());
2529            }
2530    
2531            /**
2532             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2533             *
2534             * @param parentCategoryId the parent category ID
2535             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2536             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
2537             * @throws SystemException if a system exception occurred
2538             */
2539            @Override
2540            public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2541                    OrderByComparator orderByComparator) throws SystemException {
2542                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2543                                    1, orderByComparator);
2544    
2545                    if (!list.isEmpty()) {
2546                            return list.get(0);
2547                    }
2548    
2549                    return null;
2550            }
2551    
2552            /**
2553             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2554             *
2555             * @param parentCategoryId the parent category ID
2556             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2557             * @return the last matching asset category
2558             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2559             * @throws SystemException if a system exception occurred
2560             */
2561            @Override
2562            public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2563                    OrderByComparator orderByComparator)
2564                    throws NoSuchCategoryException, SystemException {
2565                    AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2566                                    orderByComparator);
2567    
2568                    if (assetCategory != null) {
2569                            return assetCategory;
2570                    }
2571    
2572                    StringBundler msg = new StringBundler(4);
2573    
2574                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2575    
2576                    msg.append("parentCategoryId=");
2577                    msg.append(parentCategoryId);
2578    
2579                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2580    
2581                    throw new NoSuchCategoryException(msg.toString());
2582            }
2583    
2584            /**
2585             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2586             *
2587             * @param parentCategoryId the parent category ID
2588             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2589             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
2590             * @throws SystemException if a system exception occurred
2591             */
2592            @Override
2593            public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2594                    OrderByComparator orderByComparator) throws SystemException {
2595                    int count = countByParentCategoryId(parentCategoryId);
2596    
2597                    if (count == 0) {
2598                            return null;
2599                    }
2600    
2601                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2602                                    count - 1, count, orderByComparator);
2603    
2604                    if (!list.isEmpty()) {
2605                            return list.get(0);
2606                    }
2607    
2608                    return null;
2609            }
2610    
2611            /**
2612             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63;.
2613             *
2614             * @param categoryId the primary key of the current asset category
2615             * @param parentCategoryId the parent category ID
2616             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2617             * @return the previous, current, and next asset category
2618             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2619             * @throws SystemException if a system exception occurred
2620             */
2621            @Override
2622            public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2623                    long parentCategoryId, OrderByComparator orderByComparator)
2624                    throws NoSuchCategoryException, SystemException {
2625                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2626    
2627                    Session session = null;
2628    
2629                    try {
2630                            session = openSession();
2631    
2632                            AssetCategory[] array = new AssetCategoryImpl[3];
2633    
2634                            array[0] = getByParentCategoryId_PrevAndNext(session,
2635                                            assetCategory, parentCategoryId, orderByComparator, true);
2636    
2637                            array[1] = assetCategory;
2638    
2639                            array[2] = getByParentCategoryId_PrevAndNext(session,
2640                                            assetCategory, parentCategoryId, orderByComparator, false);
2641    
2642                            return array;
2643                    }
2644                    catch (Exception e) {
2645                            throw processException(e);
2646                    }
2647                    finally {
2648                            closeSession(session);
2649                    }
2650            }
2651    
2652            protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2653                    AssetCategory assetCategory, long parentCategoryId,
2654                    OrderByComparator orderByComparator, boolean previous) {
2655                    StringBundler query = null;
2656    
2657                    if (orderByComparator != null) {
2658                            query = new StringBundler(6 +
2659                                            (orderByComparator.getOrderByFields().length * 6));
2660                    }
2661                    else {
2662                            query = new StringBundler(3);
2663                    }
2664    
2665                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2666    
2667                    query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2668    
2669                    if (orderByComparator != null) {
2670                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2671    
2672                            if (orderByConditionFields.length > 0) {
2673                                    query.append(WHERE_AND);
2674                            }
2675    
2676                            for (int i = 0; i < orderByConditionFields.length; i++) {
2677                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2678                                    query.append(orderByConditionFields[i]);
2679    
2680                                    if ((i + 1) < orderByConditionFields.length) {
2681                                            if (orderByComparator.isAscending() ^ previous) {
2682                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2683                                            }
2684                                            else {
2685                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2686                                            }
2687                                    }
2688                                    else {
2689                                            if (orderByComparator.isAscending() ^ previous) {
2690                                                    query.append(WHERE_GREATER_THAN);
2691                                            }
2692                                            else {
2693                                                    query.append(WHERE_LESSER_THAN);
2694                                            }
2695                                    }
2696                            }
2697    
2698                            query.append(ORDER_BY_CLAUSE);
2699    
2700                            String[] orderByFields = orderByComparator.getOrderByFields();
2701    
2702                            for (int i = 0; i < orderByFields.length; i++) {
2703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2704                                    query.append(orderByFields[i]);
2705    
2706                                    if ((i + 1) < orderByFields.length) {
2707                                            if (orderByComparator.isAscending() ^ previous) {
2708                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2709                                            }
2710                                            else {
2711                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2712                                            }
2713                                    }
2714                                    else {
2715                                            if (orderByComparator.isAscending() ^ previous) {
2716                                                    query.append(ORDER_BY_ASC);
2717                                            }
2718                                            else {
2719                                                    query.append(ORDER_BY_DESC);
2720                                            }
2721                                    }
2722                            }
2723                    }
2724                    else {
2725                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2726                    }
2727    
2728                    String sql = query.toString();
2729    
2730                    Query q = session.createQuery(sql);
2731    
2732                    q.setFirstResult(0);
2733                    q.setMaxResults(2);
2734    
2735                    QueryPos qPos = QueryPos.getInstance(q);
2736    
2737                    qPos.add(parentCategoryId);
2738    
2739                    if (orderByComparator != null) {
2740                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2741    
2742                            for (Object value : values) {
2743                                    qPos.add(value);
2744                            }
2745                    }
2746    
2747                    List<AssetCategory> list = q.list();
2748    
2749                    if (list.size() == 2) {
2750                            return list.get(1);
2751                    }
2752                    else {
2753                            return null;
2754                    }
2755            }
2756    
2757            /**
2758             * Removes all the asset categories where parentCategoryId = &#63; from the database.
2759             *
2760             * @param parentCategoryId the parent category ID
2761             * @throws SystemException if a system exception occurred
2762             */
2763            @Override
2764            public void removeByParentCategoryId(long parentCategoryId)
2765                    throws SystemException {
2766                    for (AssetCategory assetCategory : findByParentCategoryId(
2767                                    parentCategoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2768                            remove(assetCategory);
2769                    }
2770            }
2771    
2772            /**
2773             * Returns the number of asset categories where parentCategoryId = &#63;.
2774             *
2775             * @param parentCategoryId the parent category ID
2776             * @return the number of matching asset categories
2777             * @throws SystemException if a system exception occurred
2778             */
2779            @Override
2780            public int countByParentCategoryId(long parentCategoryId)
2781                    throws SystemException {
2782                    FinderPath finderPath = FINDER_PATH_COUNT_BY_PARENTCATEGORYID;
2783    
2784                    Object[] finderArgs = new Object[] { parentCategoryId };
2785    
2786                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2787                                    this);
2788    
2789                    if (count == null) {
2790                            StringBundler query = new StringBundler(2);
2791    
2792                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
2793    
2794                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2795    
2796                            String sql = query.toString();
2797    
2798                            Session session = null;
2799    
2800                            try {
2801                                    session = openSession();
2802    
2803                                    Query q = session.createQuery(sql);
2804    
2805                                    QueryPos qPos = QueryPos.getInstance(q);
2806    
2807                                    qPos.add(parentCategoryId);
2808    
2809                                    count = (Long)q.uniqueResult();
2810    
2811                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2812                            }
2813                            catch (Exception e) {
2814                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2815    
2816                                    throw processException(e);
2817                            }
2818                            finally {
2819                                    closeSession(session);
2820                            }
2821                    }
2822    
2823                    return count.intValue();
2824            }
2825    
2826            private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
2827                    "assetCategory.parentCategoryId = ?";
2828            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
2829                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2830                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2831                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2832                            "findByVocabularyId",
2833                            new String[] {
2834                                    Long.class.getName(),
2835                                    
2836                            Integer.class.getName(), Integer.class.getName(),
2837                                    OrderByComparator.class.getName()
2838                            });
2839            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
2840                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2841                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
2842                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
2843                            "findByVocabularyId", new String[] { Long.class.getName() },
2844                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
2845                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
2846            public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
2847                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
2848                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
2849                            new String[] { Long.class.getName() });
2850    
2851            /**
2852             * Returns all the asset categories where vocabularyId = &#63;.
2853             *
2854             * @param vocabularyId the vocabulary ID
2855             * @return the matching asset categories
2856             * @throws SystemException if a system exception occurred
2857             */
2858            @Override
2859            public List<AssetCategory> findByVocabularyId(long vocabularyId)
2860                    throws SystemException {
2861                    return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2862                            QueryUtil.ALL_POS, null);
2863            }
2864    
2865            /**
2866             * Returns a range of all the asset categories where vocabularyId = &#63;.
2867             *
2868             * <p>
2869             * 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.
2870             * </p>
2871             *
2872             * @param vocabularyId the vocabulary ID
2873             * @param start the lower bound of the range of asset categories
2874             * @param end the upper bound of the range of asset categories (not inclusive)
2875             * @return the range of matching asset categories
2876             * @throws SystemException if a system exception occurred
2877             */
2878            @Override
2879            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2880                    int end) throws SystemException {
2881                    return findByVocabularyId(vocabularyId, start, end, null);
2882            }
2883    
2884            /**
2885             * Returns an ordered range of all the asset categories where vocabularyId = &#63;.
2886             *
2887             * <p>
2888             * 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.
2889             * </p>
2890             *
2891             * @param vocabularyId the vocabulary ID
2892             * @param start the lower bound of the range of asset categories
2893             * @param end the upper bound of the range of asset categories (not inclusive)
2894             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2895             * @return the ordered range of matching asset categories
2896             * @throws SystemException if a system exception occurred
2897             */
2898            @Override
2899            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2900                    int end, OrderByComparator orderByComparator) throws SystemException {
2901                    boolean pagination = true;
2902                    FinderPath finderPath = null;
2903                    Object[] finderArgs = null;
2904    
2905                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2906                                    (orderByComparator == null)) {
2907                            pagination = false;
2908                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2909                            finderArgs = new Object[] { vocabularyId };
2910                    }
2911                    else {
2912                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2913                            finderArgs = new Object[] {
2914                                            vocabularyId,
2915                                            
2916                                            start, end, orderByComparator
2917                                    };
2918                    }
2919    
2920                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2921                                    finderArgs, this);
2922    
2923                    if ((list != null) && !list.isEmpty()) {
2924                            for (AssetCategory assetCategory : list) {
2925                                    if ((vocabularyId != assetCategory.getVocabularyId())) {
2926                                            list = null;
2927    
2928                                            break;
2929                                    }
2930                            }
2931                    }
2932    
2933                    if (list == null) {
2934                            StringBundler query = null;
2935    
2936                            if (orderByComparator != null) {
2937                                    query = new StringBundler(3 +
2938                                                    (orderByComparator.getOrderByFields().length * 3));
2939                            }
2940                            else {
2941                                    query = new StringBundler(3);
2942                            }
2943    
2944                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2945    
2946                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2947    
2948                            if (orderByComparator != null) {
2949                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2950                                            orderByComparator);
2951                            }
2952                            else
2953                             if (pagination) {
2954                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2955                            }
2956    
2957                            String sql = query.toString();
2958    
2959                            Session session = null;
2960    
2961                            try {
2962                                    session = openSession();
2963    
2964                                    Query q = session.createQuery(sql);
2965    
2966                                    QueryPos qPos = QueryPos.getInstance(q);
2967    
2968                                    qPos.add(vocabularyId);
2969    
2970                                    if (!pagination) {
2971                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2972                                                            start, end, false);
2973    
2974                                            Collections.sort(list);
2975    
2976                                            list = new UnmodifiableList<AssetCategory>(list);
2977                                    }
2978                                    else {
2979                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2980                                                            start, end);
2981                                    }
2982    
2983                                    cacheResult(list);
2984    
2985                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2986                            }
2987                            catch (Exception e) {
2988                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2989    
2990                                    throw processException(e);
2991                            }
2992                            finally {
2993                                    closeSession(session);
2994                            }
2995                    }
2996    
2997                    return list;
2998            }
2999    
3000            /**
3001             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
3002             *
3003             * @param vocabularyId the vocabulary ID
3004             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3005             * @return the first matching asset category
3006             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3007             * @throws SystemException if a system exception occurred
3008             */
3009            @Override
3010            public AssetCategory findByVocabularyId_First(long vocabularyId,
3011                    OrderByComparator orderByComparator)
3012                    throws NoSuchCategoryException, SystemException {
3013                    AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
3014                                    orderByComparator);
3015    
3016                    if (assetCategory != null) {
3017                            return assetCategory;
3018                    }
3019    
3020                    StringBundler msg = new StringBundler(4);
3021    
3022                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3023    
3024                    msg.append("vocabularyId=");
3025                    msg.append(vocabularyId);
3026    
3027                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3028    
3029                    throw new NoSuchCategoryException(msg.toString());
3030            }
3031    
3032            /**
3033             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
3034             *
3035             * @param vocabularyId the vocabulary ID
3036             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3037             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
3038             * @throws SystemException if a system exception occurred
3039             */
3040            @Override
3041            public AssetCategory fetchByVocabularyId_First(long vocabularyId,
3042                    OrderByComparator orderByComparator) throws SystemException {
3043                    List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
3044                                    orderByComparator);
3045    
3046                    if (!list.isEmpty()) {
3047                            return list.get(0);
3048                    }
3049    
3050                    return null;
3051            }
3052    
3053            /**
3054             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
3055             *
3056             * @param vocabularyId the vocabulary ID
3057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3058             * @return the last matching asset category
3059             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3060             * @throws SystemException if a system exception occurred
3061             */
3062            @Override
3063            public AssetCategory findByVocabularyId_Last(long vocabularyId,
3064                    OrderByComparator orderByComparator)
3065                    throws NoSuchCategoryException, SystemException {
3066                    AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
3067                                    orderByComparator);
3068    
3069                    if (assetCategory != null) {
3070                            return assetCategory;
3071                    }
3072    
3073                    StringBundler msg = new StringBundler(4);
3074    
3075                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3076    
3077                    msg.append("vocabularyId=");
3078                    msg.append(vocabularyId);
3079    
3080                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3081    
3082                    throw new NoSuchCategoryException(msg.toString());
3083            }
3084    
3085            /**
3086             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
3087             *
3088             * @param vocabularyId the vocabulary ID
3089             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3090             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
3091             * @throws SystemException if a system exception occurred
3092             */
3093            @Override
3094            public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
3095                    OrderByComparator orderByComparator) throws SystemException {
3096                    int count = countByVocabularyId(vocabularyId);
3097    
3098                    if (count == 0) {
3099                            return null;
3100                    }
3101    
3102                    List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
3103                                    count, orderByComparator);
3104    
3105                    if (!list.isEmpty()) {
3106                            return list.get(0);
3107                    }
3108    
3109                    return null;
3110            }
3111    
3112            /**
3113             * Returns the asset categories before and after the current asset category in the ordered set where vocabularyId = &#63;.
3114             *
3115             * @param categoryId the primary key of the current asset category
3116             * @param vocabularyId the vocabulary ID
3117             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3118             * @return the previous, current, and next asset category
3119             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3120             * @throws SystemException if a system exception occurred
3121             */
3122            @Override
3123            public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
3124                    long vocabularyId, OrderByComparator orderByComparator)
3125                    throws NoSuchCategoryException, SystemException {
3126                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3127    
3128                    Session session = null;
3129    
3130                    try {
3131                            session = openSession();
3132    
3133                            AssetCategory[] array = new AssetCategoryImpl[3];
3134    
3135                            array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3136                                            vocabularyId, orderByComparator, true);
3137    
3138                            array[1] = assetCategory;
3139    
3140                            array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3141                                            vocabularyId, orderByComparator, false);
3142    
3143                            return array;
3144                    }
3145                    catch (Exception e) {
3146                            throw processException(e);
3147                    }
3148                    finally {
3149                            closeSession(session);
3150                    }
3151            }
3152    
3153            protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3154                    AssetCategory assetCategory, long vocabularyId,
3155                    OrderByComparator orderByComparator, boolean previous) {
3156                    StringBundler query = null;
3157    
3158                    if (orderByComparator != null) {
3159                            query = new StringBundler(6 +
3160                                            (orderByComparator.getOrderByFields().length * 6));
3161                    }
3162                    else {
3163                            query = new StringBundler(3);
3164                    }
3165    
3166                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3167    
3168                    query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3169    
3170                    if (orderByComparator != null) {
3171                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3172    
3173                            if (orderByConditionFields.length > 0) {
3174                                    query.append(WHERE_AND);
3175                            }
3176    
3177                            for (int i = 0; i < orderByConditionFields.length; i++) {
3178                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3179                                    query.append(orderByConditionFields[i]);
3180    
3181                                    if ((i + 1) < orderByConditionFields.length) {
3182                                            if (orderByComparator.isAscending() ^ previous) {
3183                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3184                                            }
3185                                            else {
3186                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3187                                            }
3188                                    }
3189                                    else {
3190                                            if (orderByComparator.isAscending() ^ previous) {
3191                                                    query.append(WHERE_GREATER_THAN);
3192                                            }
3193                                            else {
3194                                                    query.append(WHERE_LESSER_THAN);
3195                                            }
3196                                    }
3197                            }
3198    
3199                            query.append(ORDER_BY_CLAUSE);
3200    
3201                            String[] orderByFields = orderByComparator.getOrderByFields();
3202    
3203                            for (int i = 0; i < orderByFields.length; i++) {
3204                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3205                                    query.append(orderByFields[i]);
3206    
3207                                    if ((i + 1) < orderByFields.length) {
3208                                            if (orderByComparator.isAscending() ^ previous) {
3209                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3210                                            }
3211                                            else {
3212                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3213                                            }
3214                                    }
3215                                    else {
3216                                            if (orderByComparator.isAscending() ^ previous) {
3217                                                    query.append(ORDER_BY_ASC);
3218                                            }
3219                                            else {
3220                                                    query.append(ORDER_BY_DESC);
3221                                            }
3222                                    }
3223                            }
3224                    }
3225                    else {
3226                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3227                    }
3228    
3229                    String sql = query.toString();
3230    
3231                    Query q = session.createQuery(sql);
3232    
3233                    q.setFirstResult(0);
3234                    q.setMaxResults(2);
3235    
3236                    QueryPos qPos = QueryPos.getInstance(q);
3237    
3238                    qPos.add(vocabularyId);
3239    
3240                    if (orderByComparator != null) {
3241                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3242    
3243                            for (Object value : values) {
3244                                    qPos.add(value);
3245                            }
3246                    }
3247    
3248                    List<AssetCategory> list = q.list();
3249    
3250                    if (list.size() == 2) {
3251                            return list.get(1);
3252                    }
3253                    else {
3254                            return null;
3255                    }
3256            }
3257    
3258            /**
3259             * Removes all the asset categories where vocabularyId = &#63; from the database.
3260             *
3261             * @param vocabularyId the vocabulary ID
3262             * @throws SystemException if a system exception occurred
3263             */
3264            @Override
3265            public void removeByVocabularyId(long vocabularyId)
3266                    throws SystemException {
3267                    for (AssetCategory assetCategory : findByVocabularyId(vocabularyId,
3268                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3269                            remove(assetCategory);
3270                    }
3271            }
3272    
3273            /**
3274             * Returns the number of asset categories where vocabularyId = &#63;.
3275             *
3276             * @param vocabularyId the vocabulary ID
3277             * @return the number of matching asset categories
3278             * @throws SystemException if a system exception occurred
3279             */
3280            @Override
3281            public int countByVocabularyId(long vocabularyId) throws SystemException {
3282                    FinderPath finderPath = FINDER_PATH_COUNT_BY_VOCABULARYID;
3283    
3284                    Object[] finderArgs = new Object[] { vocabularyId };
3285    
3286                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
3287                                    this);
3288    
3289                    if (count == null) {
3290                            StringBundler query = new StringBundler(2);
3291    
3292                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
3293    
3294                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3295    
3296                            String sql = query.toString();
3297    
3298                            Session session = null;
3299    
3300                            try {
3301                                    session = openSession();
3302    
3303                                    Query q = session.createQuery(sql);
3304    
3305                                    QueryPos qPos = QueryPos.getInstance(q);
3306    
3307                                    qPos.add(vocabularyId);
3308    
3309                                    count = (Long)q.uniqueResult();
3310    
3311                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
3312                            }
3313                            catch (Exception e) {
3314                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3315    
3316                                    throw processException(e);
3317                            }
3318                            finally {
3319                                    closeSession(session);
3320                            }
3321                    }
3322    
3323                    return count.intValue();
3324            }
3325    
3326            private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
3327            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3328                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3329                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3330                            "findByG_V",
3331                            new String[] {
3332                                    Long.class.getName(), Long.class.getName(),
3333                                    
3334                            Integer.class.getName(), Integer.class.getName(),
3335                                    OrderByComparator.class.getName()
3336                            });
3337            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3338                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
3339                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
3340                            "findByG_V",
3341                            new String[] { Long.class.getName(), Long.class.getName() },
3342                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
3343                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
3344                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
3345            public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3346                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3347                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
3348                            new String[] { Long.class.getName(), Long.class.getName() });
3349            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
3350                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
3351                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
3352                            new String[] { Long.class.getName(), Long.class.getName() });
3353    
3354            /**
3355             * Returns all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3356             *
3357             * @param groupId the group ID
3358             * @param vocabularyId the vocabulary ID
3359             * @return the matching asset categories
3360             * @throws SystemException if a system exception occurred
3361             */
3362            @Override
3363            public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3364                    throws SystemException {
3365                    return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3366                            QueryUtil.ALL_POS, null);
3367            }
3368    
3369            /**
3370             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3371             *
3372             * <p>
3373             * 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.
3374             * </p>
3375             *
3376             * @param groupId the group ID
3377             * @param vocabularyId the vocabulary ID
3378             * @param start the lower bound of the range of asset categories
3379             * @param end the upper bound of the range of asset categories (not inclusive)
3380             * @return the range of matching asset categories
3381             * @throws SystemException if a system exception occurred
3382             */
3383            @Override
3384            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3385                    int start, int end) throws SystemException {
3386                    return findByG_V(groupId, vocabularyId, start, end, null);
3387            }
3388    
3389            /**
3390             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3391             *
3392             * <p>
3393             * 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.
3394             * </p>
3395             *
3396             * @param groupId the group ID
3397             * @param vocabularyId the vocabulary ID
3398             * @param start the lower bound of the range of asset categories
3399             * @param end the upper bound of the range of asset categories (not inclusive)
3400             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3401             * @return the ordered range of matching asset categories
3402             * @throws SystemException if a system exception occurred
3403             */
3404            @Override
3405            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3406                    int start, int end, OrderByComparator orderByComparator)
3407                    throws SystemException {
3408                    boolean pagination = true;
3409                    FinderPath finderPath = null;
3410                    Object[] finderArgs = null;
3411    
3412                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3413                                    (orderByComparator == null)) {
3414                            pagination = false;
3415                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3416                            finderArgs = new Object[] { groupId, vocabularyId };
3417                    }
3418                    else {
3419                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3420                            finderArgs = new Object[] {
3421                                            groupId, vocabularyId,
3422                                            
3423                                            start, end, orderByComparator
3424                                    };
3425                    }
3426    
3427                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3428                                    finderArgs, this);
3429    
3430                    if ((list != null) && !list.isEmpty()) {
3431                            for (AssetCategory assetCategory : list) {
3432                                    if ((groupId != assetCategory.getGroupId()) ||
3433                                                    (vocabularyId != assetCategory.getVocabularyId())) {
3434                                            list = null;
3435    
3436                                            break;
3437                                    }
3438                            }
3439                    }
3440    
3441                    if (list == null) {
3442                            StringBundler query = null;
3443    
3444                            if (orderByComparator != null) {
3445                                    query = new StringBundler(4 +
3446                                                    (orderByComparator.getOrderByFields().length * 3));
3447                            }
3448                            else {
3449                                    query = new StringBundler(4);
3450                            }
3451    
3452                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3453    
3454                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3455    
3456                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3457    
3458                            if (orderByComparator != null) {
3459                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3460                                            orderByComparator);
3461                            }
3462                            else
3463                             if (pagination) {
3464                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3465                            }
3466    
3467                            String sql = query.toString();
3468    
3469                            Session session = null;
3470    
3471                            try {
3472                                    session = openSession();
3473    
3474                                    Query q = session.createQuery(sql);
3475    
3476                                    QueryPos qPos = QueryPos.getInstance(q);
3477    
3478                                    qPos.add(groupId);
3479    
3480                                    qPos.add(vocabularyId);
3481    
3482                                    if (!pagination) {
3483                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3484                                                            start, end, false);
3485    
3486                                            Collections.sort(list);
3487    
3488                                            list = new UnmodifiableList<AssetCategory>(list);
3489                                    }
3490                                    else {
3491                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3492                                                            start, end);
3493                                    }
3494    
3495                                    cacheResult(list);
3496    
3497                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3498                            }
3499                            catch (Exception e) {
3500                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3501    
3502                                    throw processException(e);
3503                            }
3504                            finally {
3505                                    closeSession(session);
3506                            }
3507                    }
3508    
3509                    return list;
3510            }
3511    
3512            /**
3513             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3514             *
3515             * @param groupId the group ID
3516             * @param vocabularyId the vocabulary ID
3517             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3518             * @return the first matching asset category
3519             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3520             * @throws SystemException if a system exception occurred
3521             */
3522            @Override
3523            public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3524                    OrderByComparator orderByComparator)
3525                    throws NoSuchCategoryException, SystemException {
3526                    AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3527                                    orderByComparator);
3528    
3529                    if (assetCategory != null) {
3530                            return assetCategory;
3531                    }
3532    
3533                    StringBundler msg = new StringBundler(6);
3534    
3535                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3536    
3537                    msg.append("groupId=");
3538                    msg.append(groupId);
3539    
3540                    msg.append(", vocabularyId=");
3541                    msg.append(vocabularyId);
3542    
3543                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3544    
3545                    throw new NoSuchCategoryException(msg.toString());
3546            }
3547    
3548            /**
3549             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3550             *
3551             * @param groupId the group ID
3552             * @param vocabularyId the vocabulary ID
3553             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3554             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
3555             * @throws SystemException if a system exception occurred
3556             */
3557            @Override
3558            public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3559                    OrderByComparator orderByComparator) throws SystemException {
3560                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3561                                    orderByComparator);
3562    
3563                    if (!list.isEmpty()) {
3564                            return list.get(0);
3565                    }
3566    
3567                    return null;
3568            }
3569    
3570            /**
3571             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3572             *
3573             * @param groupId the group ID
3574             * @param vocabularyId the vocabulary ID
3575             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3576             * @return the last matching asset category
3577             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3578             * @throws SystemException if a system exception occurred
3579             */
3580            @Override
3581            public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3582                    OrderByComparator orderByComparator)
3583                    throws NoSuchCategoryException, SystemException {
3584                    AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3585                                    orderByComparator);
3586    
3587                    if (assetCategory != null) {
3588                            return assetCategory;
3589                    }
3590    
3591                    StringBundler msg = new StringBundler(6);
3592    
3593                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3594    
3595                    msg.append("groupId=");
3596                    msg.append(groupId);
3597    
3598                    msg.append(", vocabularyId=");
3599                    msg.append(vocabularyId);
3600    
3601                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3602    
3603                    throw new NoSuchCategoryException(msg.toString());
3604            }
3605    
3606            /**
3607             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3608             *
3609             * @param groupId the group ID
3610             * @param vocabularyId the vocabulary ID
3611             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3612             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
3613             * @throws SystemException if a system exception occurred
3614             */
3615            @Override
3616            public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3617                    OrderByComparator orderByComparator) throws SystemException {
3618                    int count = countByG_V(groupId, vocabularyId);
3619    
3620                    if (count == 0) {
3621                            return null;
3622                    }
3623    
3624                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3625                                    count, orderByComparator);
3626    
3627                    if (!list.isEmpty()) {
3628                            return list.get(0);
3629                    }
3630    
3631                    return null;
3632            }
3633    
3634            /**
3635             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3636             *
3637             * @param categoryId the primary key of the current asset category
3638             * @param groupId the group ID
3639             * @param vocabularyId the vocabulary ID
3640             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3641             * @return the previous, current, and next asset category
3642             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3643             * @throws SystemException if a system exception occurred
3644             */
3645            @Override
3646            public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3647                    long vocabularyId, OrderByComparator orderByComparator)
3648                    throws NoSuchCategoryException, SystemException {
3649                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3650    
3651                    Session session = null;
3652    
3653                    try {
3654                            session = openSession();
3655    
3656                            AssetCategory[] array = new AssetCategoryImpl[3];
3657    
3658                            array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3659                                            vocabularyId, orderByComparator, true);
3660    
3661                            array[1] = assetCategory;
3662    
3663                            array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3664                                            vocabularyId, orderByComparator, false);
3665    
3666                            return array;
3667                    }
3668                    catch (Exception e) {
3669                            throw processException(e);
3670                    }
3671                    finally {
3672                            closeSession(session);
3673                    }
3674            }
3675    
3676            protected AssetCategory getByG_V_PrevAndNext(Session session,
3677                    AssetCategory assetCategory, long groupId, long vocabularyId,
3678                    OrderByComparator orderByComparator, boolean previous) {
3679                    StringBundler query = null;
3680    
3681                    if (orderByComparator != null) {
3682                            query = new StringBundler(6 +
3683                                            (orderByComparator.getOrderByFields().length * 6));
3684                    }
3685                    else {
3686                            query = new StringBundler(3);
3687                    }
3688    
3689                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3690    
3691                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3692    
3693                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3694    
3695                    if (orderByComparator != null) {
3696                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3697    
3698                            if (orderByConditionFields.length > 0) {
3699                                    query.append(WHERE_AND);
3700                            }
3701    
3702                            for (int i = 0; i < orderByConditionFields.length; i++) {
3703                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3704                                    query.append(orderByConditionFields[i]);
3705    
3706                                    if ((i + 1) < orderByConditionFields.length) {
3707                                            if (orderByComparator.isAscending() ^ previous) {
3708                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3709                                            }
3710                                            else {
3711                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3712                                            }
3713                                    }
3714                                    else {
3715                                            if (orderByComparator.isAscending() ^ previous) {
3716                                                    query.append(WHERE_GREATER_THAN);
3717                                            }
3718                                            else {
3719                                                    query.append(WHERE_LESSER_THAN);
3720                                            }
3721                                    }
3722                            }
3723    
3724                            query.append(ORDER_BY_CLAUSE);
3725    
3726                            String[] orderByFields = orderByComparator.getOrderByFields();
3727    
3728                            for (int i = 0; i < orderByFields.length; i++) {
3729                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3730                                    query.append(orderByFields[i]);
3731    
3732                                    if ((i + 1) < orderByFields.length) {
3733                                            if (orderByComparator.isAscending() ^ previous) {
3734                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3735                                            }
3736                                            else {
3737                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3738                                            }
3739                                    }
3740                                    else {
3741                                            if (orderByComparator.isAscending() ^ previous) {
3742                                                    query.append(ORDER_BY_ASC);
3743                                            }
3744                                            else {
3745                                                    query.append(ORDER_BY_DESC);
3746                                            }
3747                                    }
3748                            }
3749                    }
3750                    else {
3751                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3752                    }
3753    
3754                    String sql = query.toString();
3755    
3756                    Query q = session.createQuery(sql);
3757    
3758                    q.setFirstResult(0);
3759                    q.setMaxResults(2);
3760    
3761                    QueryPos qPos = QueryPos.getInstance(q);
3762    
3763                    qPos.add(groupId);
3764    
3765                    qPos.add(vocabularyId);
3766    
3767                    if (orderByComparator != null) {
3768                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3769    
3770                            for (Object value : values) {
3771                                    qPos.add(value);
3772                            }
3773                    }
3774    
3775                    List<AssetCategory> list = q.list();
3776    
3777                    if (list.size() == 2) {
3778                            return list.get(1);
3779                    }
3780                    else {
3781                            return null;
3782                    }
3783            }
3784    
3785            /**
3786             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3787             *
3788             * @param groupId the group ID
3789             * @param vocabularyId the vocabulary ID
3790             * @return the matching asset categories that the user has permission to view
3791             * @throws SystemException if a system exception occurred
3792             */
3793            @Override
3794            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3795                    throws SystemException {
3796                    return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3797                            QueryUtil.ALL_POS, null);
3798            }
3799    
3800            /**
3801             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3802             *
3803             * <p>
3804             * 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.
3805             * </p>
3806             *
3807             * @param groupId the group ID
3808             * @param vocabularyId the vocabulary ID
3809             * @param start the lower bound of the range of asset categories
3810             * @param end the upper bound of the range of asset categories (not inclusive)
3811             * @return the range of matching asset categories that the user has permission to view
3812             * @throws SystemException if a system exception occurred
3813             */
3814            @Override
3815            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3816                    int start, int end) throws SystemException {
3817                    return filterFindByG_V(groupId, vocabularyId, start, end, null);
3818            }
3819    
3820            /**
3821             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and vocabularyId = &#63;.
3822             *
3823             * <p>
3824             * 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.
3825             * </p>
3826             *
3827             * @param groupId the group ID
3828             * @param vocabularyId the vocabulary ID
3829             * @param start the lower bound of the range of asset categories
3830             * @param end the upper bound of the range of asset categories (not inclusive)
3831             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3832             * @return the ordered range of matching asset categories that the user has permission to view
3833             * @throws SystemException if a system exception occurred
3834             */
3835            @Override
3836            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3837                    int start, int end, OrderByComparator orderByComparator)
3838                    throws SystemException {
3839                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3840                            return findByG_V(groupId, vocabularyId, start, end,
3841                                    orderByComparator);
3842                    }
3843    
3844                    StringBundler query = null;
3845    
3846                    if (orderByComparator != null) {
3847                            query = new StringBundler(4 +
3848                                            (orderByComparator.getOrderByFields().length * 3));
3849                    }
3850                    else {
3851                            query = new StringBundler(4);
3852                    }
3853    
3854                    if (getDB().isSupportsInlineDistinct()) {
3855                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3856                    }
3857                    else {
3858                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3859                    }
3860    
3861                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3862    
3863                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3864    
3865                    if (!getDB().isSupportsInlineDistinct()) {
3866                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3867                    }
3868    
3869                    if (orderByComparator != null) {
3870                            if (getDB().isSupportsInlineDistinct()) {
3871                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3872                                            orderByComparator, true);
3873                            }
3874                            else {
3875                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3876                                            orderByComparator, true);
3877                            }
3878                    }
3879                    else {
3880                            if (getDB().isSupportsInlineDistinct()) {
3881                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3882                            }
3883                            else {
3884                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3885                            }
3886                    }
3887    
3888                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3889                                    AssetCategory.class.getName(),
3890                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3891    
3892                    Session session = null;
3893    
3894                    try {
3895                            session = openSession();
3896    
3897                            SQLQuery q = session.createSQLQuery(sql);
3898    
3899                            if (getDB().isSupportsInlineDistinct()) {
3900                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3901                            }
3902                            else {
3903                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3904                            }
3905    
3906                            QueryPos qPos = QueryPos.getInstance(q);
3907    
3908                            qPos.add(groupId);
3909    
3910                            qPos.add(vocabularyId);
3911    
3912                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3913                                    end);
3914                    }
3915                    catch (Exception e) {
3916                            throw processException(e);
3917                    }
3918                    finally {
3919                            closeSession(session);
3920                    }
3921            }
3922    
3923            /**
3924             * 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;.
3925             *
3926             * @param categoryId the primary key of the current asset category
3927             * @param groupId the group ID
3928             * @param vocabularyId the vocabulary ID
3929             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3930             * @return the previous, current, and next asset category
3931             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3932             * @throws SystemException if a system exception occurred
3933             */
3934            @Override
3935            public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3936                    long groupId, long vocabularyId, OrderByComparator orderByComparator)
3937                    throws NoSuchCategoryException, SystemException {
3938                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3939                            return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3940                                    orderByComparator);
3941                    }
3942    
3943                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3944    
3945                    Session session = null;
3946    
3947                    try {
3948                            session = openSession();
3949    
3950                            AssetCategory[] array = new AssetCategoryImpl[3];
3951    
3952                            array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3953                                            groupId, vocabularyId, orderByComparator, true);
3954    
3955                            array[1] = assetCategory;
3956    
3957                            array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3958                                            groupId, vocabularyId, orderByComparator, false);
3959    
3960                            return array;
3961                    }
3962                    catch (Exception e) {
3963                            throw processException(e);
3964                    }
3965                    finally {
3966                            closeSession(session);
3967                    }
3968            }
3969    
3970            protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3971                    AssetCategory assetCategory, long groupId, long vocabularyId,
3972                    OrderByComparator orderByComparator, boolean previous) {
3973                    StringBundler query = null;
3974    
3975                    if (orderByComparator != null) {
3976                            query = new StringBundler(6 +
3977                                            (orderByComparator.getOrderByFields().length * 6));
3978                    }
3979                    else {
3980                            query = new StringBundler(3);
3981                    }
3982    
3983                    if (getDB().isSupportsInlineDistinct()) {
3984                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3985                    }
3986                    else {
3987                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3988                    }
3989    
3990                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3991    
3992                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3993    
3994                    if (!getDB().isSupportsInlineDistinct()) {
3995                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3996                    }
3997    
3998                    if (orderByComparator != null) {
3999                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4000    
4001                            if (orderByConditionFields.length > 0) {
4002                                    query.append(WHERE_AND);
4003                            }
4004    
4005                            for (int i = 0; i < orderByConditionFields.length; i++) {
4006                                    if (getDB().isSupportsInlineDistinct()) {
4007                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4008                                    }
4009                                    else {
4010                                            query.append(_ORDER_BY_ENTITY_TABLE);
4011                                    }
4012    
4013                                    query.append(orderByConditionFields[i]);
4014    
4015                                    if ((i + 1) < orderByConditionFields.length) {
4016                                            if (orderByComparator.isAscending() ^ previous) {
4017                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4018                                            }
4019                                            else {
4020                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4021                                            }
4022                                    }
4023                                    else {
4024                                            if (orderByComparator.isAscending() ^ previous) {
4025                                                    query.append(WHERE_GREATER_THAN);
4026                                            }
4027                                            else {
4028                                                    query.append(WHERE_LESSER_THAN);
4029                                            }
4030                                    }
4031                            }
4032    
4033                            query.append(ORDER_BY_CLAUSE);
4034    
4035                            String[] orderByFields = orderByComparator.getOrderByFields();
4036    
4037                            for (int i = 0; i < orderByFields.length; i++) {
4038                                    if (getDB().isSupportsInlineDistinct()) {
4039                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4040                                    }
4041                                    else {
4042                                            query.append(_ORDER_BY_ENTITY_TABLE);
4043                                    }
4044    
4045                                    query.append(orderByFields[i]);
4046    
4047                                    if ((i + 1) < orderByFields.length) {
4048                                            if (orderByComparator.isAscending() ^ previous) {
4049                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4050                                            }
4051                                            else {
4052                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4053                                            }
4054                                    }
4055                                    else {
4056                                            if (orderByComparator.isAscending() ^ previous) {
4057                                                    query.append(ORDER_BY_ASC);
4058                                            }
4059                                            else {
4060                                                    query.append(ORDER_BY_DESC);
4061                                            }
4062                                    }
4063                            }
4064                    }
4065                    else {
4066                            if (getDB().isSupportsInlineDistinct()) {
4067                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4068                            }
4069                            else {
4070                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4071                            }
4072                    }
4073    
4074                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4075                                    AssetCategory.class.getName(),
4076                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4077    
4078                    SQLQuery q = session.createSQLQuery(sql);
4079    
4080                    q.setFirstResult(0);
4081                    q.setMaxResults(2);
4082    
4083                    if (getDB().isSupportsInlineDistinct()) {
4084                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4085                    }
4086                    else {
4087                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4088                    }
4089    
4090                    QueryPos qPos = QueryPos.getInstance(q);
4091    
4092                    qPos.add(groupId);
4093    
4094                    qPos.add(vocabularyId);
4095    
4096                    if (orderByComparator != null) {
4097                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4098    
4099                            for (Object value : values) {
4100                                    qPos.add(value);
4101                            }
4102                    }
4103    
4104                    List<AssetCategory> list = q.list();
4105    
4106                    if (list.size() == 2) {
4107                            return list.get(1);
4108                    }
4109                    else {
4110                            return null;
4111                    }
4112            }
4113    
4114            /**
4115             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4116             *
4117             * @param groupId the group ID
4118             * @param vocabularyIds the vocabulary IDs
4119             * @return the matching asset categories that the user has permission to view
4120             * @throws SystemException if a system exception occurred
4121             */
4122            @Override
4123            public List<AssetCategory> filterFindByG_V(long groupId,
4124                    long[] vocabularyIds) throws SystemException {
4125                    return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4126                            QueryUtil.ALL_POS, null);
4127            }
4128    
4129            /**
4130             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4131             *
4132             * <p>
4133             * 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.
4134             * </p>
4135             *
4136             * @param groupId the group ID
4137             * @param vocabularyIds the vocabulary IDs
4138             * @param start the lower bound of the range of asset categories
4139             * @param end the upper bound of the range of asset categories (not inclusive)
4140             * @return the range of matching asset categories that the user has permission to view
4141             * @throws SystemException if a system exception occurred
4142             */
4143            @Override
4144            public List<AssetCategory> filterFindByG_V(long groupId,
4145                    long[] vocabularyIds, int start, int end) throws SystemException {
4146                    return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4147            }
4148    
4149            /**
4150             * Returns an ordered range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4151             *
4152             * <p>
4153             * 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.
4154             * </p>
4155             *
4156             * @param groupId the group ID
4157             * @param vocabularyIds the vocabulary IDs
4158             * @param start the lower bound of the range of asset categories
4159             * @param end the upper bound of the range of asset categories (not inclusive)
4160             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4161             * @return the ordered range of matching asset categories that the user has permission to view
4162             * @throws SystemException if a system exception occurred
4163             */
4164            @Override
4165            public List<AssetCategory> filterFindByG_V(long groupId,
4166                    long[] vocabularyIds, int start, int end,
4167                    OrderByComparator orderByComparator) throws SystemException {
4168                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4169                            return findByG_V(groupId, vocabularyIds, start, end,
4170                                    orderByComparator);
4171                    }
4172    
4173                    StringBundler query = new StringBundler();
4174    
4175                    if (getDB().isSupportsInlineDistinct()) {
4176                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4177                    }
4178                    else {
4179                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4180                    }
4181    
4182                    boolean conjunctionable = false;
4183    
4184                    if (conjunctionable) {
4185                            query.append(WHERE_AND);
4186                    }
4187    
4188                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4189    
4190                    conjunctionable = true;
4191    
4192                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4193                            if (conjunctionable) {
4194                                    query.append(WHERE_AND);
4195                            }
4196    
4197                            query.append(StringPool.OPEN_PARENTHESIS);
4198    
4199                            for (int i = 0; i < vocabularyIds.length; i++) {
4200                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4201    
4202                                    if ((i + 1) < vocabularyIds.length) {
4203                                            query.append(WHERE_OR);
4204                                    }
4205                            }
4206    
4207                            query.append(StringPool.CLOSE_PARENTHESIS);
4208    
4209                            conjunctionable = true;
4210                    }
4211    
4212                    if (!getDB().isSupportsInlineDistinct()) {
4213                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4214                    }
4215    
4216                    if (orderByComparator != null) {
4217                            if (getDB().isSupportsInlineDistinct()) {
4218                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4219                                            orderByComparator, true);
4220                            }
4221                            else {
4222                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4223                                            orderByComparator, true);
4224                            }
4225                    }
4226                    else {
4227                            if (getDB().isSupportsInlineDistinct()) {
4228                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4229                            }
4230                            else {
4231                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4232                            }
4233                    }
4234    
4235                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4236                                    AssetCategory.class.getName(),
4237                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4238    
4239                    Session session = null;
4240    
4241                    try {
4242                            session = openSession();
4243    
4244                            SQLQuery q = session.createSQLQuery(sql);
4245    
4246                            if (getDB().isSupportsInlineDistinct()) {
4247                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4248                            }
4249                            else {
4250                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4251                            }
4252    
4253                            QueryPos qPos = QueryPos.getInstance(q);
4254    
4255                            qPos.add(groupId);
4256    
4257                            if (vocabularyIds != null) {
4258                                    qPos.add(vocabularyIds);
4259                            }
4260    
4261                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4262                                    end);
4263                    }
4264                    catch (Exception e) {
4265                            throw processException(e);
4266                    }
4267                    finally {
4268                            closeSession(session);
4269                    }
4270            }
4271    
4272            /**
4273             * Returns all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4274             *
4275             * <p>
4276             * 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.
4277             * </p>
4278             *
4279             * @param groupId the group ID
4280             * @param vocabularyIds the vocabulary IDs
4281             * @return the matching asset categories
4282             * @throws SystemException if a system exception occurred
4283             */
4284            @Override
4285            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
4286                    throws SystemException {
4287                    return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4288                            QueryUtil.ALL_POS, null);
4289            }
4290    
4291            /**
4292             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4293             *
4294             * <p>
4295             * 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.
4296             * </p>
4297             *
4298             * @param groupId the group ID
4299             * @param vocabularyIds the vocabulary IDs
4300             * @param start the lower bound of the range of asset categories
4301             * @param end the upper bound of the range of asset categories (not inclusive)
4302             * @return the range of matching asset categories
4303             * @throws SystemException if a system exception occurred
4304             */
4305            @Override
4306            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4307                    int start, int end) throws SystemException {
4308                    return findByG_V(groupId, vocabularyIds, start, end, null);
4309            }
4310    
4311            /**
4312             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
4313             *
4314             * <p>
4315             * 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.
4316             * </p>
4317             *
4318             * @param groupId the group ID
4319             * @param vocabularyIds the vocabulary IDs
4320             * @param start the lower bound of the range of asset categories
4321             * @param end the upper bound of the range of asset categories (not inclusive)
4322             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4323             * @return the ordered range of matching asset categories
4324             * @throws SystemException if a system exception occurred
4325             */
4326            @Override
4327            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
4328                    int start, int end, OrderByComparator orderByComparator)
4329                    throws SystemException {
4330                    if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
4331                            return findByG_V(groupId, vocabularyIds[0], start, end,
4332                                    orderByComparator);
4333                    }
4334    
4335                    boolean pagination = true;
4336                    Object[] finderArgs = null;
4337    
4338                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4339                                    (orderByComparator == null)) {
4340                            pagination = false;
4341                            finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
4342                    }
4343                    else {
4344                            finderArgs = new Object[] {
4345                                            groupId, StringUtil.merge(vocabularyIds),
4346                                            
4347                                            start, end, orderByComparator
4348                                    };
4349                    }
4350    
4351                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4352                                    finderArgs, this);
4353    
4354                    if ((list != null) && !list.isEmpty()) {
4355                            for (AssetCategory assetCategory : list) {
4356                                    if ((groupId != assetCategory.getGroupId()) ||
4357                                                    !ArrayUtil.contains(vocabularyIds,
4358                                                            assetCategory.getVocabularyId())) {
4359                                            list = null;
4360    
4361                                            break;
4362                                    }
4363                            }
4364                    }
4365    
4366                    if (list == null) {
4367                            StringBundler query = new StringBundler();
4368    
4369                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4370    
4371                            boolean conjunctionable = false;
4372    
4373                            if (conjunctionable) {
4374                                    query.append(WHERE_AND);
4375                            }
4376    
4377                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4378    
4379                            conjunctionable = true;
4380    
4381                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4382                                    if (conjunctionable) {
4383                                            query.append(WHERE_AND);
4384                                    }
4385    
4386                                    query.append(StringPool.OPEN_PARENTHESIS);
4387    
4388                                    for (int i = 0; i < vocabularyIds.length; i++) {
4389                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4390    
4391                                            if ((i + 1) < vocabularyIds.length) {
4392                                                    query.append(WHERE_OR);
4393                                            }
4394                                    }
4395    
4396                                    query.append(StringPool.CLOSE_PARENTHESIS);
4397    
4398                                    conjunctionable = true;
4399                            }
4400    
4401                            if (orderByComparator != null) {
4402                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4403                                            orderByComparator);
4404                            }
4405                            else
4406                             if (pagination) {
4407                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4408                            }
4409    
4410                            String sql = query.toString();
4411    
4412                            Session session = null;
4413    
4414                            try {
4415                                    session = openSession();
4416    
4417                                    Query q = session.createQuery(sql);
4418    
4419                                    QueryPos qPos = QueryPos.getInstance(q);
4420    
4421                                    qPos.add(groupId);
4422    
4423                                    if (vocabularyIds != null) {
4424                                            qPos.add(vocabularyIds);
4425                                    }
4426    
4427                                    if (!pagination) {
4428                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4429                                                            start, end, false);
4430    
4431                                            Collections.sort(list);
4432    
4433                                            list = new UnmodifiableList<AssetCategory>(list);
4434                                    }
4435                                    else {
4436                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4437                                                            start, end);
4438                                    }
4439    
4440                                    cacheResult(list);
4441    
4442                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4443                                            finderArgs, list);
4444                            }
4445                            catch (Exception e) {
4446                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V,
4447                                            finderArgs);
4448    
4449                                    throw processException(e);
4450                            }
4451                            finally {
4452                                    closeSession(session);
4453                            }
4454                    }
4455    
4456                    return list;
4457            }
4458    
4459            /**
4460             * Removes all the asset categories where groupId = &#63; and vocabularyId = &#63; from the database.
4461             *
4462             * @param groupId the group ID
4463             * @param vocabularyId the vocabulary ID
4464             * @throws SystemException if a system exception occurred
4465             */
4466            @Override
4467            public void removeByG_V(long groupId, long vocabularyId)
4468                    throws SystemException {
4469                    for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId,
4470                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4471                            remove(assetCategory);
4472                    }
4473            }
4474    
4475            /**
4476             * Returns the number of asset categories where groupId = &#63; and vocabularyId = &#63;.
4477             *
4478             * @param groupId the group ID
4479             * @param vocabularyId the vocabulary ID
4480             * @return the number of matching asset categories
4481             * @throws SystemException if a system exception occurred
4482             */
4483            @Override
4484            public int countByG_V(long groupId, long vocabularyId)
4485                    throws SystemException {
4486                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_V;
4487    
4488                    Object[] finderArgs = new Object[] { groupId, vocabularyId };
4489    
4490                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
4491                                    this);
4492    
4493                    if (count == null) {
4494                            StringBundler query = new StringBundler(3);
4495    
4496                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4497    
4498                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4499    
4500                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4501    
4502                            String sql = query.toString();
4503    
4504                            Session session = null;
4505    
4506                            try {
4507                                    session = openSession();
4508    
4509                                    Query q = session.createQuery(sql);
4510    
4511                                    QueryPos qPos = QueryPos.getInstance(q);
4512    
4513                                    qPos.add(groupId);
4514    
4515                                    qPos.add(vocabularyId);
4516    
4517                                    count = (Long)q.uniqueResult();
4518    
4519                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
4520                            }
4521                            catch (Exception e) {
4522                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4523    
4524                                    throw processException(e);
4525                            }
4526                            finally {
4527                                    closeSession(session);
4528                            }
4529                    }
4530    
4531                    return count.intValue();
4532            }
4533    
4534            /**
4535             * Returns the number of asset categories where groupId = &#63; and vocabularyId = any &#63;.
4536             *
4537             * @param groupId the group ID
4538             * @param vocabularyIds the vocabulary IDs
4539             * @return the number of matching asset categories
4540             * @throws SystemException if a system exception occurred
4541             */
4542            @Override
4543            public int countByG_V(long groupId, long[] vocabularyIds)
4544                    throws SystemException {
4545                    Object[] finderArgs = new Object[] {
4546                                    groupId, StringUtil.merge(vocabularyIds)
4547                            };
4548    
4549                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4550                                    finderArgs, this);
4551    
4552                    if (count == null) {
4553                            StringBundler query = new StringBundler();
4554    
4555                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
4556    
4557                            boolean conjunctionable = false;
4558    
4559                            if (conjunctionable) {
4560                                    query.append(WHERE_AND);
4561                            }
4562    
4563                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4564    
4565                            conjunctionable = true;
4566    
4567                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4568                                    if (conjunctionable) {
4569                                            query.append(WHERE_AND);
4570                                    }
4571    
4572                                    query.append(StringPool.OPEN_PARENTHESIS);
4573    
4574                                    for (int i = 0; i < vocabularyIds.length; i++) {
4575                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4576    
4577                                            if ((i + 1) < vocabularyIds.length) {
4578                                                    query.append(WHERE_OR);
4579                                            }
4580                                    }
4581    
4582                                    query.append(StringPool.CLOSE_PARENTHESIS);
4583    
4584                                    conjunctionable = true;
4585                            }
4586    
4587                            String sql = query.toString();
4588    
4589                            Session session = null;
4590    
4591                            try {
4592                                    session = openSession();
4593    
4594                                    Query q = session.createQuery(sql);
4595    
4596                                    QueryPos qPos = QueryPos.getInstance(q);
4597    
4598                                    qPos.add(groupId);
4599    
4600                                    if (vocabularyIds != null) {
4601                                            qPos.add(vocabularyIds);
4602                                    }
4603    
4604                                    count = (Long)q.uniqueResult();
4605    
4606                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4607                                            finderArgs, count);
4608                            }
4609                            catch (Exception e) {
4610                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
4611                                            finderArgs);
4612    
4613                                    throw processException(e);
4614                            }
4615                            finally {
4616                                    closeSession(session);
4617                            }
4618                    }
4619    
4620                    return count.intValue();
4621            }
4622    
4623            /**
4624             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
4625             *
4626             * @param groupId the group ID
4627             * @param vocabularyId the vocabulary ID
4628             * @return the number of matching asset categories that the user has permission to view
4629             * @throws SystemException if a system exception occurred
4630             */
4631            @Override
4632            public int filterCountByG_V(long groupId, long vocabularyId)
4633                    throws SystemException {
4634                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4635                            return countByG_V(groupId, vocabularyId);
4636                    }
4637    
4638                    StringBundler query = new StringBundler(3);
4639    
4640                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4641    
4642                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
4643    
4644                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
4645    
4646                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4647                                    AssetCategory.class.getName(),
4648                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4649    
4650                    Session session = null;
4651    
4652                    try {
4653                            session = openSession();
4654    
4655                            SQLQuery q = session.createSQLQuery(sql);
4656    
4657                            q.addScalar(COUNT_COLUMN_NAME,
4658                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4659    
4660                            QueryPos qPos = QueryPos.getInstance(q);
4661    
4662                            qPos.add(groupId);
4663    
4664                            qPos.add(vocabularyId);
4665    
4666                            Long count = (Long)q.uniqueResult();
4667    
4668                            return count.intValue();
4669                    }
4670                    catch (Exception e) {
4671                            throw processException(e);
4672                    }
4673                    finally {
4674                            closeSession(session);
4675                    }
4676            }
4677    
4678            /**
4679             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4680             *
4681             * @param groupId the group ID
4682             * @param vocabularyIds the vocabulary IDs
4683             * @return the number of matching asset categories that the user has permission to view
4684             * @throws SystemException if a system exception occurred
4685             */
4686            @Override
4687            public int filterCountByG_V(long groupId, long[] vocabularyIds)
4688                    throws SystemException {
4689                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4690                            return countByG_V(groupId, vocabularyIds);
4691                    }
4692    
4693                    StringBundler query = new StringBundler();
4694    
4695                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
4696    
4697                    boolean conjunctionable = false;
4698    
4699                    if (conjunctionable) {
4700                            query.append(WHERE_AND);
4701                    }
4702    
4703                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4704    
4705                    conjunctionable = true;
4706    
4707                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4708                            if (conjunctionable) {
4709                                    query.append(WHERE_AND);
4710                            }
4711    
4712                            query.append(StringPool.OPEN_PARENTHESIS);
4713    
4714                            for (int i = 0; i < vocabularyIds.length; i++) {
4715                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4716    
4717                                    if ((i + 1) < vocabularyIds.length) {
4718                                            query.append(WHERE_OR);
4719                                    }
4720                            }
4721    
4722                            query.append(StringPool.CLOSE_PARENTHESIS);
4723    
4724                            conjunctionable = true;
4725                    }
4726    
4727                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4728                                    AssetCategory.class.getName(),
4729                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4730    
4731                    Session session = null;
4732    
4733                    try {
4734                            session = openSession();
4735    
4736                            SQLQuery q = session.createSQLQuery(sql);
4737    
4738                            q.addScalar(COUNT_COLUMN_NAME,
4739                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4740    
4741                            QueryPos qPos = QueryPos.getInstance(q);
4742    
4743                            qPos.add(groupId);
4744    
4745                            if (vocabularyIds != null) {
4746                                    qPos.add(vocabularyIds);
4747                            }
4748    
4749                            Long count = (Long)q.uniqueResult();
4750    
4751                            return count.intValue();
4752                    }
4753                    catch (Exception e) {
4754                            throw processException(e);
4755                    }
4756                    finally {
4757                            closeSession(session);
4758                    }
4759            }
4760    
4761            private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
4762            private static final String _FINDER_COLUMN_G_V_GROUPID_5 = "(" +
4763                    removeConjunction(_FINDER_COLUMN_G_V_GROUPID_2) + ")";
4764            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
4765            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_5 = "(" +
4766                    removeConjunction(_FINDER_COLUMN_G_V_VOCABULARYID_2) + ")";
4767            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4768                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4769                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
4770                            "findByP_N",
4771                            new String[] {
4772                                    Long.class.getName(), String.class.getName(),
4773                                    
4774                            Integer.class.getName(), Integer.class.getName(),
4775                                    OrderByComparator.class.getName()
4776                            });
4777            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4778                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
4779                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
4780                            "findByP_N",
4781                            new String[] { Long.class.getName(), String.class.getName() },
4782                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
4783                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
4784            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
4785                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
4786                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
4787                            new String[] { Long.class.getName(), String.class.getName() });
4788    
4789            /**
4790             * Returns all the asset categories where parentCategoryId = &#63; and name = &#63;.
4791             *
4792             * @param parentCategoryId the parent category ID
4793             * @param name the name
4794             * @return the matching asset categories
4795             * @throws SystemException if a system exception occurred
4796             */
4797            @Override
4798            public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4799                    throws SystemException {
4800                    return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4801                            QueryUtil.ALL_POS, null);
4802            }
4803    
4804            /**
4805             * Returns a range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4806             *
4807             * <p>
4808             * 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.
4809             * </p>
4810             *
4811             * @param parentCategoryId the parent category ID
4812             * @param name the name
4813             * @param start the lower bound of the range of asset categories
4814             * @param end the upper bound of the range of asset categories (not inclusive)
4815             * @return the range of matching asset categories
4816             * @throws SystemException if a system exception occurred
4817             */
4818            @Override
4819            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4820                    int start, int end) throws SystemException {
4821                    return findByP_N(parentCategoryId, name, start, end, null);
4822            }
4823    
4824            /**
4825             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4826             *
4827             * <p>
4828             * 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.
4829             * </p>
4830             *
4831             * @param parentCategoryId the parent category ID
4832             * @param name the name
4833             * @param start the lower bound of the range of asset categories
4834             * @param end the upper bound of the range of asset categories (not inclusive)
4835             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4836             * @return the ordered range of matching asset categories
4837             * @throws SystemException if a system exception occurred
4838             */
4839            @Override
4840            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4841                    int start, int end, OrderByComparator orderByComparator)
4842                    throws SystemException {
4843                    boolean pagination = true;
4844                    FinderPath finderPath = null;
4845                    Object[] finderArgs = null;
4846    
4847                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4848                                    (orderByComparator == null)) {
4849                            pagination = false;
4850                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4851                            finderArgs = new Object[] { parentCategoryId, name };
4852                    }
4853                    else {
4854                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4855                            finderArgs = new Object[] {
4856                                            parentCategoryId, name,
4857                                            
4858                                            start, end, orderByComparator
4859                                    };
4860                    }
4861    
4862                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4863                                    finderArgs, this);
4864    
4865                    if ((list != null) && !list.isEmpty()) {
4866                            for (AssetCategory assetCategory : list) {
4867                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4868                                                    !Validator.equals(name, assetCategory.getName())) {
4869                                            list = null;
4870    
4871                                            break;
4872                                    }
4873                            }
4874                    }
4875    
4876                    if (list == null) {
4877                            StringBundler query = null;
4878    
4879                            if (orderByComparator != null) {
4880                                    query = new StringBundler(4 +
4881                                                    (orderByComparator.getOrderByFields().length * 3));
4882                            }
4883                            else {
4884                                    query = new StringBundler(4);
4885                            }
4886    
4887                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4888    
4889                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4890    
4891                            boolean bindName = false;
4892    
4893                            if (name == null) {
4894                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
4895                            }
4896                            else if (name.equals(StringPool.BLANK)) {
4897                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
4898                            }
4899                            else {
4900                                    bindName = true;
4901    
4902                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
4903                            }
4904    
4905                            if (orderByComparator != null) {
4906                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4907                                            orderByComparator);
4908                            }
4909                            else
4910                             if (pagination) {
4911                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4912                            }
4913    
4914                            String sql = query.toString();
4915    
4916                            Session session = null;
4917    
4918                            try {
4919                                    session = openSession();
4920    
4921                                    Query q = session.createQuery(sql);
4922    
4923                                    QueryPos qPos = QueryPos.getInstance(q);
4924    
4925                                    qPos.add(parentCategoryId);
4926    
4927                                    if (bindName) {
4928                                            qPos.add(name);
4929                                    }
4930    
4931                                    if (!pagination) {
4932                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4933                                                            start, end, false);
4934    
4935                                            Collections.sort(list);
4936    
4937                                            list = new UnmodifiableList<AssetCategory>(list);
4938                                    }
4939                                    else {
4940                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4941                                                            start, end);
4942                                    }
4943    
4944                                    cacheResult(list);
4945    
4946                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
4947                            }
4948                            catch (Exception e) {
4949                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
4950    
4951                                    throw processException(e);
4952                            }
4953                            finally {
4954                                    closeSession(session);
4955                            }
4956                    }
4957    
4958                    return list;
4959            }
4960    
4961            /**
4962             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4963             *
4964             * @param parentCategoryId the parent category ID
4965             * @param name the name
4966             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4967             * @return the first matching asset category
4968             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4969             * @throws SystemException if a system exception occurred
4970             */
4971            @Override
4972            public AssetCategory findByP_N_First(long parentCategoryId, String name,
4973                    OrderByComparator orderByComparator)
4974                    throws NoSuchCategoryException, SystemException {
4975                    AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4976                                    orderByComparator);
4977    
4978                    if (assetCategory != null) {
4979                            return assetCategory;
4980                    }
4981    
4982                    StringBundler msg = new StringBundler(6);
4983    
4984                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4985    
4986                    msg.append("parentCategoryId=");
4987                    msg.append(parentCategoryId);
4988    
4989                    msg.append(", name=");
4990                    msg.append(name);
4991    
4992                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4993    
4994                    throw new NoSuchCategoryException(msg.toString());
4995            }
4996    
4997            /**
4998             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4999             *
5000             * @param parentCategoryId the parent category ID
5001             * @param name the name
5002             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5003             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5004             * @throws SystemException if a system exception occurred
5005             */
5006            @Override
5007            public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
5008                    OrderByComparator orderByComparator) throws SystemException {
5009                    List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
5010                                    orderByComparator);
5011    
5012                    if (!list.isEmpty()) {
5013                            return list.get(0);
5014                    }
5015    
5016                    return null;
5017            }
5018    
5019            /**
5020             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5021             *
5022             * @param parentCategoryId the parent category ID
5023             * @param name the name
5024             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5025             * @return the last matching asset category
5026             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5027             * @throws SystemException if a system exception occurred
5028             */
5029            @Override
5030            public AssetCategory findByP_N_Last(long parentCategoryId, String name,
5031                    OrderByComparator orderByComparator)
5032                    throws NoSuchCategoryException, SystemException {
5033                    AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
5034                                    orderByComparator);
5035    
5036                    if (assetCategory != null) {
5037                            return assetCategory;
5038                    }
5039    
5040                    StringBundler msg = new StringBundler(6);
5041    
5042                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5043    
5044                    msg.append("parentCategoryId=");
5045                    msg.append(parentCategoryId);
5046    
5047                    msg.append(", name=");
5048                    msg.append(name);
5049    
5050                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5051    
5052                    throw new NoSuchCategoryException(msg.toString());
5053            }
5054    
5055            /**
5056             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5057             *
5058             * @param parentCategoryId the parent category ID
5059             * @param name the name
5060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5061             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5062             * @throws SystemException if a system exception occurred
5063             */
5064            @Override
5065            public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
5066                    OrderByComparator orderByComparator) throws SystemException {
5067                    int count = countByP_N(parentCategoryId, name);
5068    
5069                    if (count == 0) {
5070                            return null;
5071                    }
5072    
5073                    List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
5074                                    count, orderByComparator);
5075    
5076                    if (!list.isEmpty()) {
5077                            return list.get(0);
5078                    }
5079    
5080                    return null;
5081            }
5082    
5083            /**
5084             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
5085             *
5086             * @param categoryId the primary key of the current asset category
5087             * @param parentCategoryId the parent category ID
5088             * @param name the name
5089             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5090             * @return the previous, current, and next asset category
5091             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5092             * @throws SystemException if a system exception occurred
5093             */
5094            @Override
5095            public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
5096                    long parentCategoryId, String name, OrderByComparator orderByComparator)
5097                    throws NoSuchCategoryException, SystemException {
5098                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5099    
5100                    Session session = null;
5101    
5102                    try {
5103                            session = openSession();
5104    
5105                            AssetCategory[] array = new AssetCategoryImpl[3];
5106    
5107                            array[0] = getByP_N_PrevAndNext(session, assetCategory,
5108                                            parentCategoryId, name, orderByComparator, true);
5109    
5110                            array[1] = assetCategory;
5111    
5112                            array[2] = getByP_N_PrevAndNext(session, assetCategory,
5113                                            parentCategoryId, name, orderByComparator, false);
5114    
5115                            return array;
5116                    }
5117                    catch (Exception e) {
5118                            throw processException(e);
5119                    }
5120                    finally {
5121                            closeSession(session);
5122                    }
5123            }
5124    
5125            protected AssetCategory getByP_N_PrevAndNext(Session session,
5126                    AssetCategory assetCategory, long parentCategoryId, String name,
5127                    OrderByComparator orderByComparator, boolean previous) {
5128                    StringBundler query = null;
5129    
5130                    if (orderByComparator != null) {
5131                            query = new StringBundler(6 +
5132                                            (orderByComparator.getOrderByFields().length * 6));
5133                    }
5134                    else {
5135                            query = new StringBundler(3);
5136                    }
5137    
5138                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5139    
5140                    query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5141    
5142                    boolean bindName = false;
5143    
5144                    if (name == null) {
5145                            query.append(_FINDER_COLUMN_P_N_NAME_1);
5146                    }
5147                    else if (name.equals(StringPool.BLANK)) {
5148                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5149                    }
5150                    else {
5151                            bindName = true;
5152    
5153                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5154                    }
5155    
5156                    if (orderByComparator != null) {
5157                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5158    
5159                            if (orderByConditionFields.length > 0) {
5160                                    query.append(WHERE_AND);
5161                            }
5162    
5163                            for (int i = 0; i < orderByConditionFields.length; i++) {
5164                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5165                                    query.append(orderByConditionFields[i]);
5166    
5167                                    if ((i + 1) < orderByConditionFields.length) {
5168                                            if (orderByComparator.isAscending() ^ previous) {
5169                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5170                                            }
5171                                            else {
5172                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5173                                            }
5174                                    }
5175                                    else {
5176                                            if (orderByComparator.isAscending() ^ previous) {
5177                                                    query.append(WHERE_GREATER_THAN);
5178                                            }
5179                                            else {
5180                                                    query.append(WHERE_LESSER_THAN);
5181                                            }
5182                                    }
5183                            }
5184    
5185                            query.append(ORDER_BY_CLAUSE);
5186    
5187                            String[] orderByFields = orderByComparator.getOrderByFields();
5188    
5189                            for (int i = 0; i < orderByFields.length; i++) {
5190                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5191                                    query.append(orderByFields[i]);
5192    
5193                                    if ((i + 1) < orderByFields.length) {
5194                                            if (orderByComparator.isAscending() ^ previous) {
5195                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5196                                            }
5197                                            else {
5198                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5199                                            }
5200                                    }
5201                                    else {
5202                                            if (orderByComparator.isAscending() ^ previous) {
5203                                                    query.append(ORDER_BY_ASC);
5204                                            }
5205                                            else {
5206                                                    query.append(ORDER_BY_DESC);
5207                                            }
5208                                    }
5209                            }
5210                    }
5211                    else {
5212                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5213                    }
5214    
5215                    String sql = query.toString();
5216    
5217                    Query q = session.createQuery(sql);
5218    
5219                    q.setFirstResult(0);
5220                    q.setMaxResults(2);
5221    
5222                    QueryPos qPos = QueryPos.getInstance(q);
5223    
5224                    qPos.add(parentCategoryId);
5225    
5226                    if (bindName) {
5227                            qPos.add(name);
5228                    }
5229    
5230                    if (orderByComparator != null) {
5231                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5232    
5233                            for (Object value : values) {
5234                                    qPos.add(value);
5235                            }
5236                    }
5237    
5238                    List<AssetCategory> list = q.list();
5239    
5240                    if (list.size() == 2) {
5241                            return list.get(1);
5242                    }
5243                    else {
5244                            return null;
5245                    }
5246            }
5247    
5248            /**
5249             * Removes all the asset categories where parentCategoryId = &#63; and name = &#63; from the database.
5250             *
5251             * @param parentCategoryId the parent category ID
5252             * @param name the name
5253             * @throws SystemException if a system exception occurred
5254             */
5255            @Override
5256            public void removeByP_N(long parentCategoryId, String name)
5257                    throws SystemException {
5258                    for (AssetCategory assetCategory : findByP_N(parentCategoryId, name,
5259                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5260                            remove(assetCategory);
5261                    }
5262            }
5263    
5264            /**
5265             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63;.
5266             *
5267             * @param parentCategoryId the parent category ID
5268             * @param name the name
5269             * @return the number of matching asset categories
5270             * @throws SystemException if a system exception occurred
5271             */
5272            @Override
5273            public int countByP_N(long parentCategoryId, String name)
5274                    throws SystemException {
5275                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N;
5276    
5277                    Object[] finderArgs = new Object[] { parentCategoryId, name };
5278    
5279                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5280                                    this);
5281    
5282                    if (count == null) {
5283                            StringBundler query = new StringBundler(3);
5284    
5285                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5286    
5287                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5288    
5289                            boolean bindName = false;
5290    
5291                            if (name == null) {
5292                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5293                            }
5294                            else if (name.equals(StringPool.BLANK)) {
5295                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
5296                            }
5297                            else {
5298                                    bindName = true;
5299    
5300                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
5301                            }
5302    
5303                            String sql = query.toString();
5304    
5305                            Session session = null;
5306    
5307                            try {
5308                                    session = openSession();
5309    
5310                                    Query q = session.createQuery(sql);
5311    
5312                                    QueryPos qPos = QueryPos.getInstance(q);
5313    
5314                                    qPos.add(parentCategoryId);
5315    
5316                                    if (bindName) {
5317                                            qPos.add(name);
5318                                    }
5319    
5320                                    count = (Long)q.uniqueResult();
5321    
5322                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5323                            }
5324                            catch (Exception e) {
5325                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5326    
5327                                    throw processException(e);
5328                            }
5329                            finally {
5330                                    closeSession(session);
5331                            }
5332                    }
5333    
5334                    return count.intValue();
5335            }
5336    
5337            private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5338            private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
5339            private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
5340            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '')";
5341            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5342                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5343                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5344                            "findByP_V",
5345                            new String[] {
5346                                    Long.class.getName(), Long.class.getName(),
5347                                    
5348                            Integer.class.getName(), Integer.class.getName(),
5349                                    OrderByComparator.class.getName()
5350                            });
5351            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5352                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5353                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5354                            "findByP_V",
5355                            new String[] { Long.class.getName(), Long.class.getName() },
5356                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
5357                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
5358                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
5359            public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5360                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5361                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
5362                            new String[] { Long.class.getName(), Long.class.getName() });
5363    
5364            /**
5365             * Returns all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5366             *
5367             * @param parentCategoryId the parent category ID
5368             * @param vocabularyId the vocabulary ID
5369             * @return the matching asset categories
5370             * @throws SystemException if a system exception occurred
5371             */
5372            @Override
5373            public List<AssetCategory> findByP_V(long parentCategoryId,
5374                    long vocabularyId) throws SystemException {
5375                    return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
5376                            QueryUtil.ALL_POS, null);
5377            }
5378    
5379            /**
5380             * Returns a range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5381             *
5382             * <p>
5383             * 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.
5384             * </p>
5385             *
5386             * @param parentCategoryId the parent category ID
5387             * @param vocabularyId the vocabulary ID
5388             * @param start the lower bound of the range of asset categories
5389             * @param end the upper bound of the range of asset categories (not inclusive)
5390             * @return the range of matching asset categories
5391             * @throws SystemException if a system exception occurred
5392             */
5393            @Override
5394            public List<AssetCategory> findByP_V(long parentCategoryId,
5395                    long vocabularyId, int start, int end) throws SystemException {
5396                    return findByP_V(parentCategoryId, vocabularyId, start, end, null);
5397            }
5398    
5399            /**
5400             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5401             *
5402             * <p>
5403             * 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.
5404             * </p>
5405             *
5406             * @param parentCategoryId the parent category ID
5407             * @param vocabularyId the vocabulary ID
5408             * @param start the lower bound of the range of asset categories
5409             * @param end the upper bound of the range of asset categories (not inclusive)
5410             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5411             * @return the ordered range of matching asset categories
5412             * @throws SystemException if a system exception occurred
5413             */
5414            @Override
5415            public List<AssetCategory> findByP_V(long parentCategoryId,
5416                    long vocabularyId, int start, int end,
5417                    OrderByComparator orderByComparator) throws SystemException {
5418                    boolean pagination = true;
5419                    FinderPath finderPath = null;
5420                    Object[] finderArgs = null;
5421    
5422                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5423                                    (orderByComparator == null)) {
5424                            pagination = false;
5425                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
5426                            finderArgs = new Object[] { parentCategoryId, vocabularyId };
5427                    }
5428                    else {
5429                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
5430                            finderArgs = new Object[] {
5431                                            parentCategoryId, vocabularyId,
5432                                            
5433                                            start, end, orderByComparator
5434                                    };
5435                    }
5436    
5437                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5438                                    finderArgs, this);
5439    
5440                    if ((list != null) && !list.isEmpty()) {
5441                            for (AssetCategory assetCategory : list) {
5442                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
5443                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5444                                            list = null;
5445    
5446                                            break;
5447                                    }
5448                            }
5449                    }
5450    
5451                    if (list == null) {
5452                            StringBundler query = null;
5453    
5454                            if (orderByComparator != null) {
5455                                    query = new StringBundler(4 +
5456                                                    (orderByComparator.getOrderByFields().length * 3));
5457                            }
5458                            else {
5459                                    query = new StringBundler(4);
5460                            }
5461    
5462                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5463    
5464                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5465    
5466                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5467    
5468                            if (orderByComparator != null) {
5469                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5470                                            orderByComparator);
5471                            }
5472                            else
5473                             if (pagination) {
5474                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5475                            }
5476    
5477                            String sql = query.toString();
5478    
5479                            Session session = null;
5480    
5481                            try {
5482                                    session = openSession();
5483    
5484                                    Query q = session.createQuery(sql);
5485    
5486                                    QueryPos qPos = QueryPos.getInstance(q);
5487    
5488                                    qPos.add(parentCategoryId);
5489    
5490                                    qPos.add(vocabularyId);
5491    
5492                                    if (!pagination) {
5493                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5494                                                            start, end, false);
5495    
5496                                            Collections.sort(list);
5497    
5498                                            list = new UnmodifiableList<AssetCategory>(list);
5499                                    }
5500                                    else {
5501                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5502                                                            start, end);
5503                                    }
5504    
5505                                    cacheResult(list);
5506    
5507                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
5508                            }
5509                            catch (Exception e) {
5510                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5511    
5512                                    throw processException(e);
5513                            }
5514                            finally {
5515                                    closeSession(session);
5516                            }
5517                    }
5518    
5519                    return list;
5520            }
5521    
5522            /**
5523             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5524             *
5525             * @param parentCategoryId the parent category ID
5526             * @param vocabularyId the vocabulary ID
5527             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5528             * @return the first matching asset category
5529             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5530             * @throws SystemException if a system exception occurred
5531             */
5532            @Override
5533            public AssetCategory findByP_V_First(long parentCategoryId,
5534                    long vocabularyId, OrderByComparator orderByComparator)
5535                    throws NoSuchCategoryException, SystemException {
5536                    AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
5537                                    vocabularyId, orderByComparator);
5538    
5539                    if (assetCategory != null) {
5540                            return assetCategory;
5541                    }
5542    
5543                    StringBundler msg = new StringBundler(6);
5544    
5545                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5546    
5547                    msg.append("parentCategoryId=");
5548                    msg.append(parentCategoryId);
5549    
5550                    msg.append(", vocabularyId=");
5551                    msg.append(vocabularyId);
5552    
5553                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5554    
5555                    throw new NoSuchCategoryException(msg.toString());
5556            }
5557    
5558            /**
5559             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5560             *
5561             * @param parentCategoryId the parent category ID
5562             * @param vocabularyId the vocabulary ID
5563             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5564             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5565             * @throws SystemException if a system exception occurred
5566             */
5567            @Override
5568            public AssetCategory fetchByP_V_First(long parentCategoryId,
5569                    long vocabularyId, OrderByComparator orderByComparator)
5570                    throws SystemException {
5571                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
5572                                    1, orderByComparator);
5573    
5574                    if (!list.isEmpty()) {
5575                            return list.get(0);
5576                    }
5577    
5578                    return null;
5579            }
5580    
5581            /**
5582             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5583             *
5584             * @param parentCategoryId the parent category ID
5585             * @param vocabularyId the vocabulary ID
5586             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5587             * @return the last matching asset category
5588             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5589             * @throws SystemException if a system exception occurred
5590             */
5591            @Override
5592            public AssetCategory findByP_V_Last(long parentCategoryId,
5593                    long vocabularyId, OrderByComparator orderByComparator)
5594                    throws NoSuchCategoryException, SystemException {
5595                    AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
5596                                    vocabularyId, orderByComparator);
5597    
5598                    if (assetCategory != null) {
5599                            return assetCategory;
5600                    }
5601    
5602                    StringBundler msg = new StringBundler(6);
5603    
5604                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5605    
5606                    msg.append("parentCategoryId=");
5607                    msg.append(parentCategoryId);
5608    
5609                    msg.append(", vocabularyId=");
5610                    msg.append(vocabularyId);
5611    
5612                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5613    
5614                    throw new NoSuchCategoryException(msg.toString());
5615            }
5616    
5617            /**
5618             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5619             *
5620             * @param parentCategoryId the parent category ID
5621             * @param vocabularyId the vocabulary ID
5622             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5623             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5624             * @throws SystemException if a system exception occurred
5625             */
5626            @Override
5627            public AssetCategory fetchByP_V_Last(long parentCategoryId,
5628                    long vocabularyId, OrderByComparator orderByComparator)
5629                    throws SystemException {
5630                    int count = countByP_V(parentCategoryId, vocabularyId);
5631    
5632                    if (count == 0) {
5633                            return null;
5634                    }
5635    
5636                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
5637                                    count - 1, count, orderByComparator);
5638    
5639                    if (!list.isEmpty()) {
5640                            return list.get(0);
5641                    }
5642    
5643                    return null;
5644            }
5645    
5646            /**
5647             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
5648             *
5649             * @param categoryId the primary key of the current asset category
5650             * @param parentCategoryId the parent category ID
5651             * @param vocabularyId the vocabulary ID
5652             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5653             * @return the previous, current, and next asset category
5654             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5655             * @throws SystemException if a system exception occurred
5656             */
5657            @Override
5658            public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
5659                    long parentCategoryId, long vocabularyId,
5660                    OrderByComparator orderByComparator)
5661                    throws NoSuchCategoryException, SystemException {
5662                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5663    
5664                    Session session = null;
5665    
5666                    try {
5667                            session = openSession();
5668    
5669                            AssetCategory[] array = new AssetCategoryImpl[3];
5670    
5671                            array[0] = getByP_V_PrevAndNext(session, assetCategory,
5672                                            parentCategoryId, vocabularyId, orderByComparator, true);
5673    
5674                            array[1] = assetCategory;
5675    
5676                            array[2] = getByP_V_PrevAndNext(session, assetCategory,
5677                                            parentCategoryId, vocabularyId, orderByComparator, false);
5678    
5679                            return array;
5680                    }
5681                    catch (Exception e) {
5682                            throw processException(e);
5683                    }
5684                    finally {
5685                            closeSession(session);
5686                    }
5687            }
5688    
5689            protected AssetCategory getByP_V_PrevAndNext(Session session,
5690                    AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
5691                    OrderByComparator orderByComparator, boolean previous) {
5692                    StringBundler query = null;
5693    
5694                    if (orderByComparator != null) {
5695                            query = new StringBundler(6 +
5696                                            (orderByComparator.getOrderByFields().length * 6));
5697                    }
5698                    else {
5699                            query = new StringBundler(3);
5700                    }
5701    
5702                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5703    
5704                    query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5705    
5706                    query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5707    
5708                    if (orderByComparator != null) {
5709                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5710    
5711                            if (orderByConditionFields.length > 0) {
5712                                    query.append(WHERE_AND);
5713                            }
5714    
5715                            for (int i = 0; i < orderByConditionFields.length; i++) {
5716                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5717                                    query.append(orderByConditionFields[i]);
5718    
5719                                    if ((i + 1) < orderByConditionFields.length) {
5720                                            if (orderByComparator.isAscending() ^ previous) {
5721                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5722                                            }
5723                                            else {
5724                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5725                                            }
5726                                    }
5727                                    else {
5728                                            if (orderByComparator.isAscending() ^ previous) {
5729                                                    query.append(WHERE_GREATER_THAN);
5730                                            }
5731                                            else {
5732                                                    query.append(WHERE_LESSER_THAN);
5733                                            }
5734                                    }
5735                            }
5736    
5737                            query.append(ORDER_BY_CLAUSE);
5738    
5739                            String[] orderByFields = orderByComparator.getOrderByFields();
5740    
5741                            for (int i = 0; i < orderByFields.length; i++) {
5742                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5743                                    query.append(orderByFields[i]);
5744    
5745                                    if ((i + 1) < orderByFields.length) {
5746                                            if (orderByComparator.isAscending() ^ previous) {
5747                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5748                                            }
5749                                            else {
5750                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5751                                            }
5752                                    }
5753                                    else {
5754                                            if (orderByComparator.isAscending() ^ previous) {
5755                                                    query.append(ORDER_BY_ASC);
5756                                            }
5757                                            else {
5758                                                    query.append(ORDER_BY_DESC);
5759                                            }
5760                                    }
5761                            }
5762                    }
5763                    else {
5764                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5765                    }
5766    
5767                    String sql = query.toString();
5768    
5769                    Query q = session.createQuery(sql);
5770    
5771                    q.setFirstResult(0);
5772                    q.setMaxResults(2);
5773    
5774                    QueryPos qPos = QueryPos.getInstance(q);
5775    
5776                    qPos.add(parentCategoryId);
5777    
5778                    qPos.add(vocabularyId);
5779    
5780                    if (orderByComparator != null) {
5781                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5782    
5783                            for (Object value : values) {
5784                                    qPos.add(value);
5785                            }
5786                    }
5787    
5788                    List<AssetCategory> list = q.list();
5789    
5790                    if (list.size() == 2) {
5791                            return list.get(1);
5792                    }
5793                    else {
5794                            return null;
5795                    }
5796            }
5797    
5798            /**
5799             * Removes all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63; from the database.
5800             *
5801             * @param parentCategoryId the parent category ID
5802             * @param vocabularyId the vocabulary ID
5803             * @throws SystemException if a system exception occurred
5804             */
5805            @Override
5806            public void removeByP_V(long parentCategoryId, long vocabularyId)
5807                    throws SystemException {
5808                    for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5809                                    vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
5810                            remove(assetCategory);
5811                    }
5812            }
5813    
5814            /**
5815             * Returns the number of asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5816             *
5817             * @param parentCategoryId the parent category ID
5818             * @param vocabularyId the vocabulary ID
5819             * @return the number of matching asset categories
5820             * @throws SystemException if a system exception occurred
5821             */
5822            @Override
5823            public int countByP_V(long parentCategoryId, long vocabularyId)
5824                    throws SystemException {
5825                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_V;
5826    
5827                    Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5828    
5829                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
5830                                    this);
5831    
5832                    if (count == null) {
5833                            StringBundler query = new StringBundler(3);
5834    
5835                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5836    
5837                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5838    
5839                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5840    
5841                            String sql = query.toString();
5842    
5843                            Session session = null;
5844    
5845                            try {
5846                                    session = openSession();
5847    
5848                                    Query q = session.createQuery(sql);
5849    
5850                                    QueryPos qPos = QueryPos.getInstance(q);
5851    
5852                                    qPos.add(parentCategoryId);
5853    
5854                                    qPos.add(vocabularyId);
5855    
5856                                    count = (Long)q.uniqueResult();
5857    
5858                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
5859                            }
5860                            catch (Exception e) {
5861                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
5862    
5863                                    throw processException(e);
5864                            }
5865                            finally {
5866                                    closeSession(session);
5867                            }
5868                    }
5869    
5870                    return count.intValue();
5871            }
5872    
5873            private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
5874            private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
5875            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5876                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5877                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
5878                            "findByN_V",
5879                            new String[] {
5880                                    String.class.getName(), Long.class.getName(),
5881                                    
5882                            Integer.class.getName(), Integer.class.getName(),
5883                                    OrderByComparator.class.getName()
5884                            });
5885            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5886                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
5887                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
5888                            "findByN_V",
5889                            new String[] { String.class.getName(), Long.class.getName() },
5890                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
5891                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
5892            public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
5893                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
5894                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
5895                            new String[] { String.class.getName(), Long.class.getName() });
5896    
5897            /**
5898             * Returns all the asset categories where name = &#63; and vocabularyId = &#63;.
5899             *
5900             * @param name the name
5901             * @param vocabularyId the vocabulary ID
5902             * @return the matching asset categories
5903             * @throws SystemException if a system exception occurred
5904             */
5905            @Override
5906            public List<AssetCategory> findByN_V(String name, long vocabularyId)
5907                    throws SystemException {
5908                    return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5909                            QueryUtil.ALL_POS, null);
5910            }
5911    
5912            /**
5913             * Returns a range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5914             *
5915             * <p>
5916             * 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.
5917             * </p>
5918             *
5919             * @param name the name
5920             * @param vocabularyId the vocabulary ID
5921             * @param start the lower bound of the range of asset categories
5922             * @param end the upper bound of the range of asset categories (not inclusive)
5923             * @return the range of matching asset categories
5924             * @throws SystemException if a system exception occurred
5925             */
5926            @Override
5927            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5928                    int start, int end) throws SystemException {
5929                    return findByN_V(name, vocabularyId, start, end, null);
5930            }
5931    
5932            /**
5933             * Returns an ordered range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5934             *
5935             * <p>
5936             * 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.
5937             * </p>
5938             *
5939             * @param name the name
5940             * @param vocabularyId the vocabulary ID
5941             * @param start the lower bound of the range of asset categories
5942             * @param end the upper bound of the range of asset categories (not inclusive)
5943             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5944             * @return the ordered range of matching asset categories
5945             * @throws SystemException if a system exception occurred
5946             */
5947            @Override
5948            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5949                    int start, int end, OrderByComparator orderByComparator)
5950                    throws SystemException {
5951                    boolean pagination = true;
5952                    FinderPath finderPath = null;
5953                    Object[] finderArgs = null;
5954    
5955                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5956                                    (orderByComparator == null)) {
5957                            pagination = false;
5958                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5959                            finderArgs = new Object[] { name, vocabularyId };
5960                    }
5961                    else {
5962                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5963                            finderArgs = new Object[] {
5964                                            name, vocabularyId,
5965                                            
5966                                            start, end, orderByComparator
5967                                    };
5968                    }
5969    
5970                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5971                                    finderArgs, this);
5972    
5973                    if ((list != null) && !list.isEmpty()) {
5974                            for (AssetCategory assetCategory : list) {
5975                                    if (!Validator.equals(name, assetCategory.getName()) ||
5976                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5977                                            list = null;
5978    
5979                                            break;
5980                                    }
5981                            }
5982                    }
5983    
5984                    if (list == null) {
5985                            StringBundler query = null;
5986    
5987                            if (orderByComparator != null) {
5988                                    query = new StringBundler(4 +
5989                                                    (orderByComparator.getOrderByFields().length * 3));
5990                            }
5991                            else {
5992                                    query = new StringBundler(4);
5993                            }
5994    
5995                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5996    
5997                            boolean bindName = false;
5998    
5999                            if (name == null) {
6000                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
6001                            }
6002                            else if (name.equals(StringPool.BLANK)) {
6003                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
6004                            }
6005                            else {
6006                                    bindName = true;
6007    
6008                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
6009                            }
6010    
6011                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6012    
6013                            if (orderByComparator != null) {
6014                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6015                                            orderByComparator);
6016                            }
6017                            else
6018                             if (pagination) {
6019                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6020                            }
6021    
6022                            String sql = query.toString();
6023    
6024                            Session session = null;
6025    
6026                            try {
6027                                    session = openSession();
6028    
6029                                    Query q = session.createQuery(sql);
6030    
6031                                    QueryPos qPos = QueryPos.getInstance(q);
6032    
6033                                    if (bindName) {
6034                                            qPos.add(name);
6035                                    }
6036    
6037                                    qPos.add(vocabularyId);
6038    
6039                                    if (!pagination) {
6040                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6041                                                            start, end, false);
6042    
6043                                            Collections.sort(list);
6044    
6045                                            list = new UnmodifiableList<AssetCategory>(list);
6046                                    }
6047                                    else {
6048                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6049                                                            start, end);
6050                                    }
6051    
6052                                    cacheResult(list);
6053    
6054                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6055                            }
6056                            catch (Exception e) {
6057                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6058    
6059                                    throw processException(e);
6060                            }
6061                            finally {
6062                                    closeSession(session);
6063                            }
6064                    }
6065    
6066                    return list;
6067            }
6068    
6069            /**
6070             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6071             *
6072             * @param name the name
6073             * @param vocabularyId the vocabulary ID
6074             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6075             * @return the first matching asset category
6076             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6077             * @throws SystemException if a system exception occurred
6078             */
6079            @Override
6080            public AssetCategory findByN_V_First(String name, long vocabularyId,
6081                    OrderByComparator orderByComparator)
6082                    throws NoSuchCategoryException, SystemException {
6083                    AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
6084                                    orderByComparator);
6085    
6086                    if (assetCategory != null) {
6087                            return assetCategory;
6088                    }
6089    
6090                    StringBundler msg = new StringBundler(6);
6091    
6092                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6093    
6094                    msg.append("name=");
6095                    msg.append(name);
6096    
6097                    msg.append(", vocabularyId=");
6098                    msg.append(vocabularyId);
6099    
6100                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6101    
6102                    throw new NoSuchCategoryException(msg.toString());
6103            }
6104    
6105            /**
6106             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6107             *
6108             * @param name the name
6109             * @param vocabularyId the vocabulary ID
6110             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6111             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
6112             * @throws SystemException if a system exception occurred
6113             */
6114            @Override
6115            public AssetCategory fetchByN_V_First(String name, long vocabularyId,
6116                    OrderByComparator orderByComparator) throws SystemException {
6117                    List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
6118                                    orderByComparator);
6119    
6120                    if (!list.isEmpty()) {
6121                            return list.get(0);
6122                    }
6123    
6124                    return null;
6125            }
6126    
6127            /**
6128             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6129             *
6130             * @param name the name
6131             * @param vocabularyId the vocabulary ID
6132             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6133             * @return the last matching asset category
6134             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6135             * @throws SystemException if a system exception occurred
6136             */
6137            @Override
6138            public AssetCategory findByN_V_Last(String name, long vocabularyId,
6139                    OrderByComparator orderByComparator)
6140                    throws NoSuchCategoryException, SystemException {
6141                    AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
6142                                    orderByComparator);
6143    
6144                    if (assetCategory != null) {
6145                            return assetCategory;
6146                    }
6147    
6148                    StringBundler msg = new StringBundler(6);
6149    
6150                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6151    
6152                    msg.append("name=");
6153                    msg.append(name);
6154    
6155                    msg.append(", vocabularyId=");
6156                    msg.append(vocabularyId);
6157    
6158                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6159    
6160                    throw new NoSuchCategoryException(msg.toString());
6161            }
6162    
6163            /**
6164             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6165             *
6166             * @param name the name
6167             * @param vocabularyId the vocabulary ID
6168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6169             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
6170             * @throws SystemException if a system exception occurred
6171             */
6172            @Override
6173            public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
6174                    OrderByComparator orderByComparator) throws SystemException {
6175                    int count = countByN_V(name, vocabularyId);
6176    
6177                    if (count == 0) {
6178                            return null;
6179                    }
6180    
6181                    List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
6182                                    count, orderByComparator);
6183    
6184                    if (!list.isEmpty()) {
6185                            return list.get(0);
6186                    }
6187    
6188                    return null;
6189            }
6190    
6191            /**
6192             * Returns the asset categories before and after the current asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
6193             *
6194             * @param categoryId the primary key of the current asset category
6195             * @param name the name
6196             * @param vocabularyId the vocabulary ID
6197             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6198             * @return the previous, current, and next asset category
6199             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6200             * @throws SystemException if a system exception occurred
6201             */
6202            @Override
6203            public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
6204                    long vocabularyId, OrderByComparator orderByComparator)
6205                    throws NoSuchCategoryException, SystemException {
6206                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6207    
6208                    Session session = null;
6209    
6210                    try {
6211                            session = openSession();
6212    
6213                            AssetCategory[] array = new AssetCategoryImpl[3];
6214    
6215                            array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
6216                                            vocabularyId, orderByComparator, true);
6217    
6218                            array[1] = assetCategory;
6219    
6220                            array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
6221                                            vocabularyId, orderByComparator, false);
6222    
6223                            return array;
6224                    }
6225                    catch (Exception e) {
6226                            throw processException(e);
6227                    }
6228                    finally {
6229                            closeSession(session);
6230                    }
6231            }
6232    
6233            protected AssetCategory getByN_V_PrevAndNext(Session session,
6234                    AssetCategory assetCategory, String name, long vocabularyId,
6235                    OrderByComparator orderByComparator, boolean previous) {
6236                    StringBundler query = null;
6237    
6238                    if (orderByComparator != null) {
6239                            query = new StringBundler(6 +
6240                                            (orderByComparator.getOrderByFields().length * 6));
6241                    }
6242                    else {
6243                            query = new StringBundler(3);
6244                    }
6245    
6246                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6247    
6248                    boolean bindName = false;
6249    
6250                    if (name == null) {
6251                            query.append(_FINDER_COLUMN_N_V_NAME_1);
6252                    }
6253                    else if (name.equals(StringPool.BLANK)) {
6254                            query.append(_FINDER_COLUMN_N_V_NAME_3);
6255                    }
6256                    else {
6257                            bindName = true;
6258    
6259                            query.append(_FINDER_COLUMN_N_V_NAME_2);
6260                    }
6261    
6262                    query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6263    
6264                    if (orderByComparator != null) {
6265                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6266    
6267                            if (orderByConditionFields.length > 0) {
6268                                    query.append(WHERE_AND);
6269                            }
6270    
6271                            for (int i = 0; i < orderByConditionFields.length; i++) {
6272                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6273                                    query.append(orderByConditionFields[i]);
6274    
6275                                    if ((i + 1) < orderByConditionFields.length) {
6276                                            if (orderByComparator.isAscending() ^ previous) {
6277                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6278                                            }
6279                                            else {
6280                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6281                                            }
6282                                    }
6283                                    else {
6284                                            if (orderByComparator.isAscending() ^ previous) {
6285                                                    query.append(WHERE_GREATER_THAN);
6286                                            }
6287                                            else {
6288                                                    query.append(WHERE_LESSER_THAN);
6289                                            }
6290                                    }
6291                            }
6292    
6293                            query.append(ORDER_BY_CLAUSE);
6294    
6295                            String[] orderByFields = orderByComparator.getOrderByFields();
6296    
6297                            for (int i = 0; i < orderByFields.length; i++) {
6298                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6299                                    query.append(orderByFields[i]);
6300    
6301                                    if ((i + 1) < orderByFields.length) {
6302                                            if (orderByComparator.isAscending() ^ previous) {
6303                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6304                                            }
6305                                            else {
6306                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6307                                            }
6308                                    }
6309                                    else {
6310                                            if (orderByComparator.isAscending() ^ previous) {
6311                                                    query.append(ORDER_BY_ASC);
6312                                            }
6313                                            else {
6314                                                    query.append(ORDER_BY_DESC);
6315                                            }
6316                                    }
6317                            }
6318                    }
6319                    else {
6320                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6321                    }
6322    
6323                    String sql = query.toString();
6324    
6325                    Query q = session.createQuery(sql);
6326    
6327                    q.setFirstResult(0);
6328                    q.setMaxResults(2);
6329    
6330                    QueryPos qPos = QueryPos.getInstance(q);
6331    
6332                    if (bindName) {
6333                            qPos.add(name);
6334                    }
6335    
6336                    qPos.add(vocabularyId);
6337    
6338                    if (orderByComparator != null) {
6339                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6340    
6341                            for (Object value : values) {
6342                                    qPos.add(value);
6343                            }
6344                    }
6345    
6346                    List<AssetCategory> list = q.list();
6347    
6348                    if (list.size() == 2) {
6349                            return list.get(1);
6350                    }
6351                    else {
6352                            return null;
6353                    }
6354            }
6355    
6356            /**
6357             * Removes all the asset categories where name = &#63; and vocabularyId = &#63; from the database.
6358             *
6359             * @param name the name
6360             * @param vocabularyId the vocabulary ID
6361             * @throws SystemException if a system exception occurred
6362             */
6363            @Override
6364            public void removeByN_V(String name, long vocabularyId)
6365                    throws SystemException {
6366                    for (AssetCategory assetCategory : findByN_V(name, vocabularyId,
6367                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
6368                            remove(assetCategory);
6369                    }
6370            }
6371    
6372            /**
6373             * Returns the number of asset categories where name = &#63; and vocabularyId = &#63;.
6374             *
6375             * @param name the name
6376             * @param vocabularyId the vocabulary ID
6377             * @return the number of matching asset categories
6378             * @throws SystemException if a system exception occurred
6379             */
6380            @Override
6381            public int countByN_V(String name, long vocabularyId)
6382                    throws SystemException {
6383                    FinderPath finderPath = FINDER_PATH_COUNT_BY_N_V;
6384    
6385                    Object[] finderArgs = new Object[] { name, vocabularyId };
6386    
6387                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
6388                                    this);
6389    
6390                    if (count == null) {
6391                            StringBundler query = new StringBundler(3);
6392    
6393                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
6394    
6395                            boolean bindName = false;
6396    
6397                            if (name == null) {
6398                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
6399                            }
6400                            else if (name.equals(StringPool.BLANK)) {
6401                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
6402                            }
6403                            else {
6404                                    bindName = true;
6405    
6406                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
6407                            }
6408    
6409                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
6410    
6411                            String sql = query.toString();
6412    
6413                            Session session = null;
6414    
6415                            try {
6416                                    session = openSession();
6417    
6418                                    Query q = session.createQuery(sql);
6419    
6420                                    QueryPos qPos = QueryPos.getInstance(q);
6421    
6422                                    if (bindName) {
6423                                            qPos.add(name);
6424                                    }
6425    
6426                                    qPos.add(vocabularyId);
6427    
6428                                    count = (Long)q.uniqueResult();
6429    
6430                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
6431                            }
6432                            catch (Exception e) {
6433                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6434    
6435                                    throw processException(e);
6436                            }
6437                            finally {
6438                                    closeSession(session);
6439                            }
6440                    }
6441    
6442                    return count.intValue();
6443            }
6444    
6445            private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
6446            private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
6447            private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
6448            private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
6449            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6450                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6451                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
6452                            "findByG_P_V",
6453                            new String[] {
6454                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
6455                                    
6456                            Integer.class.getName(), Integer.class.getName(),
6457                                    OrderByComparator.class.getName()
6458                            });
6459            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6460                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
6461                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
6462                            "findByG_P_V",
6463                            new String[] {
6464                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6465                            },
6466                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
6467                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
6468                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK |
6469                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
6470            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
6471                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
6472                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
6473                            new String[] {
6474                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
6475                            });
6476    
6477            /**
6478             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6479             *
6480             * @param groupId the group ID
6481             * @param parentCategoryId the parent category ID
6482             * @param vocabularyId the vocabulary ID
6483             * @return the matching asset categories
6484             * @throws SystemException if a system exception occurred
6485             */
6486            @Override
6487            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6488                    long vocabularyId) throws SystemException {
6489                    return findByG_P_V(groupId, parentCategoryId, vocabularyId,
6490                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6491            }
6492    
6493            /**
6494             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6495             *
6496             * <p>
6497             * 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.
6498             * </p>
6499             *
6500             * @param groupId the group ID
6501             * @param parentCategoryId the parent category ID
6502             * @param vocabularyId the vocabulary ID
6503             * @param start the lower bound of the range of asset categories
6504             * @param end the upper bound of the range of asset categories (not inclusive)
6505             * @return the range of matching asset categories
6506             * @throws SystemException if a system exception occurred
6507             */
6508            @Override
6509            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6510                    long vocabularyId, int start, int end) throws SystemException {
6511                    return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
6512                            null);
6513            }
6514    
6515            /**
6516             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6517             *
6518             * <p>
6519             * 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.
6520             * </p>
6521             *
6522             * @param groupId the group ID
6523             * @param parentCategoryId the parent category ID
6524             * @param vocabularyId the vocabulary ID
6525             * @param start the lower bound of the range of asset categories
6526             * @param end the upper bound of the range of asset categories (not inclusive)
6527             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6528             * @return the ordered range of matching asset categories
6529             * @throws SystemException if a system exception occurred
6530             */
6531            @Override
6532            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
6533                    long vocabularyId, int start, int end,
6534                    OrderByComparator orderByComparator) throws SystemException {
6535                    boolean pagination = true;
6536                    FinderPath finderPath = null;
6537                    Object[] finderArgs = null;
6538    
6539                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6540                                    (orderByComparator == null)) {
6541                            pagination = false;
6542                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
6543                            finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
6544                    }
6545                    else {
6546                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
6547                            finderArgs = new Object[] {
6548                                            groupId, parentCategoryId, vocabularyId,
6549                                            
6550                                            start, end, orderByComparator
6551                                    };
6552                    }
6553    
6554                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6555                                    finderArgs, this);
6556    
6557                    if ((list != null) && !list.isEmpty()) {
6558                            for (AssetCategory assetCategory : list) {
6559                                    if ((groupId != assetCategory.getGroupId()) ||
6560                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
6561                                                    (vocabularyId != assetCategory.getVocabularyId())) {
6562                                            list = null;
6563    
6564                                            break;
6565                                    }
6566                            }
6567                    }
6568    
6569                    if (list == null) {
6570                            StringBundler query = null;
6571    
6572                            if (orderByComparator != null) {
6573                                    query = new StringBundler(5 +
6574                                                    (orderByComparator.getOrderByFields().length * 3));
6575                            }
6576                            else {
6577                                    query = new StringBundler(5);
6578                            }
6579    
6580                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6581    
6582                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6583    
6584                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6585    
6586                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6587    
6588                            if (orderByComparator != null) {
6589                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6590                                            orderByComparator);
6591                            }
6592                            else
6593                             if (pagination) {
6594                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6595                            }
6596    
6597                            String sql = query.toString();
6598    
6599                            Session session = null;
6600    
6601                            try {
6602                                    session = openSession();
6603    
6604                                    Query q = session.createQuery(sql);
6605    
6606                                    QueryPos qPos = QueryPos.getInstance(q);
6607    
6608                                    qPos.add(groupId);
6609    
6610                                    qPos.add(parentCategoryId);
6611    
6612                                    qPos.add(vocabularyId);
6613    
6614                                    if (!pagination) {
6615                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6616                                                            start, end, false);
6617    
6618                                            Collections.sort(list);
6619    
6620                                            list = new UnmodifiableList<AssetCategory>(list);
6621                                    }
6622                                    else {
6623                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6624                                                            start, end);
6625                                    }
6626    
6627                                    cacheResult(list);
6628    
6629                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
6630                            }
6631                            catch (Exception e) {
6632                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
6633    
6634                                    throw processException(e);
6635                            }
6636                            finally {
6637                                    closeSession(session);
6638                            }
6639                    }
6640    
6641                    return list;
6642            }
6643    
6644            /**
6645             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6646             *
6647             * @param groupId the group ID
6648             * @param parentCategoryId the parent category ID
6649             * @param vocabularyId the vocabulary ID
6650             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6651             * @return the first matching asset category
6652             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6653             * @throws SystemException if a system exception occurred
6654             */
6655            @Override
6656            public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
6657                    long vocabularyId, OrderByComparator orderByComparator)
6658                    throws NoSuchCategoryException, SystemException {
6659                    AssetCategory assetCategory = fetchByG_P_V_First(groupId,
6660                                    parentCategoryId, vocabularyId, orderByComparator);
6661    
6662                    if (assetCategory != null) {
6663                            return assetCategory;
6664                    }
6665    
6666                    StringBundler msg = new StringBundler(8);
6667    
6668                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6669    
6670                    msg.append("groupId=");
6671                    msg.append(groupId);
6672    
6673                    msg.append(", parentCategoryId=");
6674                    msg.append(parentCategoryId);
6675    
6676                    msg.append(", vocabularyId=");
6677                    msg.append(vocabularyId);
6678    
6679                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6680    
6681                    throw new NoSuchCategoryException(msg.toString());
6682            }
6683    
6684            /**
6685             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6686             *
6687             * @param groupId the group ID
6688             * @param parentCategoryId the parent category ID
6689             * @param vocabularyId the vocabulary ID
6690             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6691             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
6692             * @throws SystemException if a system exception occurred
6693             */
6694            @Override
6695            public AssetCategory fetchByG_P_V_First(long groupId,
6696                    long parentCategoryId, long vocabularyId,
6697                    OrderByComparator orderByComparator) throws SystemException {
6698                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6699                                    vocabularyId, 0, 1, orderByComparator);
6700    
6701                    if (!list.isEmpty()) {
6702                            return list.get(0);
6703                    }
6704    
6705                    return null;
6706            }
6707    
6708            /**
6709             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6710             *
6711             * @param groupId the group ID
6712             * @param parentCategoryId the parent category ID
6713             * @param vocabularyId the vocabulary ID
6714             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6715             * @return the last matching asset category
6716             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6717             * @throws SystemException if a system exception occurred
6718             */
6719            @Override
6720            public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
6721                    long vocabularyId, OrderByComparator orderByComparator)
6722                    throws NoSuchCategoryException, SystemException {
6723                    AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
6724                                    parentCategoryId, vocabularyId, orderByComparator);
6725    
6726                    if (assetCategory != null) {
6727                            return assetCategory;
6728                    }
6729    
6730                    StringBundler msg = new StringBundler(8);
6731    
6732                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6733    
6734                    msg.append("groupId=");
6735                    msg.append(groupId);
6736    
6737                    msg.append(", parentCategoryId=");
6738                    msg.append(parentCategoryId);
6739    
6740                    msg.append(", vocabularyId=");
6741                    msg.append(vocabularyId);
6742    
6743                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6744    
6745                    throw new NoSuchCategoryException(msg.toString());
6746            }
6747    
6748            /**
6749             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6750             *
6751             * @param groupId the group ID
6752             * @param parentCategoryId the parent category ID
6753             * @param vocabularyId the vocabulary ID
6754             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6755             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
6756             * @throws SystemException if a system exception occurred
6757             */
6758            @Override
6759            public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
6760                    long vocabularyId, OrderByComparator orderByComparator)
6761                    throws SystemException {
6762                    int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
6763    
6764                    if (count == 0) {
6765                            return null;
6766                    }
6767    
6768                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
6769                                    vocabularyId, count - 1, count, orderByComparator);
6770    
6771                    if (!list.isEmpty()) {
6772                            return list.get(0);
6773                    }
6774    
6775                    return null;
6776            }
6777    
6778            /**
6779             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6780             *
6781             * @param categoryId the primary key of the current asset category
6782             * @param groupId the group ID
6783             * @param parentCategoryId the parent category ID
6784             * @param vocabularyId the vocabulary ID
6785             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6786             * @return the previous, current, and next asset category
6787             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6788             * @throws SystemException if a system exception occurred
6789             */
6790            @Override
6791            public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
6792                    long groupId, long parentCategoryId, long vocabularyId,
6793                    OrderByComparator orderByComparator)
6794                    throws NoSuchCategoryException, SystemException {
6795                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6796    
6797                    Session session = null;
6798    
6799                    try {
6800                            session = openSession();
6801    
6802                            AssetCategory[] array = new AssetCategoryImpl[3];
6803    
6804                            array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6805                                            parentCategoryId, vocabularyId, orderByComparator, true);
6806    
6807                            array[1] = assetCategory;
6808    
6809                            array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
6810                                            parentCategoryId, vocabularyId, orderByComparator, false);
6811    
6812                            return array;
6813                    }
6814                    catch (Exception e) {
6815                            throw processException(e);
6816                    }
6817                    finally {
6818                            closeSession(session);
6819                    }
6820            }
6821    
6822            protected AssetCategory getByG_P_V_PrevAndNext(Session session,
6823                    AssetCategory assetCategory, long groupId, long parentCategoryId,
6824                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6825                    StringBundler query = null;
6826    
6827                    if (orderByComparator != null) {
6828                            query = new StringBundler(6 +
6829                                            (orderByComparator.getOrderByFields().length * 6));
6830                    }
6831                    else {
6832                            query = new StringBundler(3);
6833                    }
6834    
6835                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6836    
6837                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6838    
6839                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6840    
6841                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6842    
6843                    if (orderByComparator != null) {
6844                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6845    
6846                            if (orderByConditionFields.length > 0) {
6847                                    query.append(WHERE_AND);
6848                            }
6849    
6850                            for (int i = 0; i < orderByConditionFields.length; i++) {
6851                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6852                                    query.append(orderByConditionFields[i]);
6853    
6854                                    if ((i + 1) < orderByConditionFields.length) {
6855                                            if (orderByComparator.isAscending() ^ previous) {
6856                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6857                                            }
6858                                            else {
6859                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6860                                            }
6861                                    }
6862                                    else {
6863                                            if (orderByComparator.isAscending() ^ previous) {
6864                                                    query.append(WHERE_GREATER_THAN);
6865                                            }
6866                                            else {
6867                                                    query.append(WHERE_LESSER_THAN);
6868                                            }
6869                                    }
6870                            }
6871    
6872                            query.append(ORDER_BY_CLAUSE);
6873    
6874                            String[] orderByFields = orderByComparator.getOrderByFields();
6875    
6876                            for (int i = 0; i < orderByFields.length; i++) {
6877                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6878                                    query.append(orderByFields[i]);
6879    
6880                                    if ((i + 1) < orderByFields.length) {
6881                                            if (orderByComparator.isAscending() ^ previous) {
6882                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6883                                            }
6884                                            else {
6885                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6886                                            }
6887                                    }
6888                                    else {
6889                                            if (orderByComparator.isAscending() ^ previous) {
6890                                                    query.append(ORDER_BY_ASC);
6891                                            }
6892                                            else {
6893                                                    query.append(ORDER_BY_DESC);
6894                                            }
6895                                    }
6896                            }
6897                    }
6898                    else {
6899                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6900                    }
6901    
6902                    String sql = query.toString();
6903    
6904                    Query q = session.createQuery(sql);
6905    
6906                    q.setFirstResult(0);
6907                    q.setMaxResults(2);
6908    
6909                    QueryPos qPos = QueryPos.getInstance(q);
6910    
6911                    qPos.add(groupId);
6912    
6913                    qPos.add(parentCategoryId);
6914    
6915                    qPos.add(vocabularyId);
6916    
6917                    if (orderByComparator != null) {
6918                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6919    
6920                            for (Object value : values) {
6921                                    qPos.add(value);
6922                            }
6923                    }
6924    
6925                    List<AssetCategory> list = q.list();
6926    
6927                    if (list.size() == 2) {
6928                            return list.get(1);
6929                    }
6930                    else {
6931                            return null;
6932                    }
6933            }
6934    
6935            /**
6936             * Returns all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6937             *
6938             * @param groupId the group ID
6939             * @param parentCategoryId the parent category ID
6940             * @param vocabularyId the vocabulary ID
6941             * @return the matching asset categories that the user has permission to view
6942             * @throws SystemException if a system exception occurred
6943             */
6944            @Override
6945            public List<AssetCategory> filterFindByG_P_V(long groupId,
6946                    long parentCategoryId, long vocabularyId) throws SystemException {
6947                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6948                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6949            }
6950    
6951            /**
6952             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
6953             *
6954             * <p>
6955             * 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.
6956             * </p>
6957             *
6958             * @param groupId the group ID
6959             * @param parentCategoryId the parent category ID
6960             * @param vocabularyId the vocabulary ID
6961             * @param start the lower bound of the range of asset categories
6962             * @param end the upper bound of the range of asset categories (not inclusive)
6963             * @return the range of matching asset categories that the user has permission to view
6964             * @throws SystemException if a system exception occurred
6965             */
6966            @Override
6967            public List<AssetCategory> filterFindByG_P_V(long groupId,
6968                    long parentCategoryId, long vocabularyId, int start, int end)
6969                    throws SystemException {
6970                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
6971                            start, end, null);
6972            }
6973    
6974            /**
6975             * 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;.
6976             *
6977             * <p>
6978             * 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.
6979             * </p>
6980             *
6981             * @param groupId the group ID
6982             * @param parentCategoryId the parent category ID
6983             * @param vocabularyId the vocabulary ID
6984             * @param start the lower bound of the range of asset categories
6985             * @param end the upper bound of the range of asset categories (not inclusive)
6986             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6987             * @return the ordered range of matching asset categories that the user has permission to view
6988             * @throws SystemException if a system exception occurred
6989             */
6990            @Override
6991            public List<AssetCategory> filterFindByG_P_V(long groupId,
6992                    long parentCategoryId, long vocabularyId, int start, int end,
6993                    OrderByComparator orderByComparator) throws SystemException {
6994                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6995                            return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
6996                                    end, orderByComparator);
6997                    }
6998    
6999                    StringBundler query = null;
7000    
7001                    if (orderByComparator != null) {
7002                            query = new StringBundler(5 +
7003                                            (orderByComparator.getOrderByFields().length * 3));
7004                    }
7005                    else {
7006                            query = new StringBundler(5);
7007                    }
7008    
7009                    if (getDB().isSupportsInlineDistinct()) {
7010                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7011                    }
7012                    else {
7013                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7014                    }
7015    
7016                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7017    
7018                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7019    
7020                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7021    
7022                    if (!getDB().isSupportsInlineDistinct()) {
7023                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7024                    }
7025    
7026                    if (orderByComparator != null) {
7027                            if (getDB().isSupportsInlineDistinct()) {
7028                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7029                                            orderByComparator, true);
7030                            }
7031                            else {
7032                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7033                                            orderByComparator, true);
7034                            }
7035                    }
7036                    else {
7037                            if (getDB().isSupportsInlineDistinct()) {
7038                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7039                            }
7040                            else {
7041                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7042                            }
7043                    }
7044    
7045                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7046                                    AssetCategory.class.getName(),
7047                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7048    
7049                    Session session = null;
7050    
7051                    try {
7052                            session = openSession();
7053    
7054                            SQLQuery q = session.createSQLQuery(sql);
7055    
7056                            if (getDB().isSupportsInlineDistinct()) {
7057                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7058                            }
7059                            else {
7060                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7061                            }
7062    
7063                            QueryPos qPos = QueryPos.getInstance(q);
7064    
7065                            qPos.add(groupId);
7066    
7067                            qPos.add(parentCategoryId);
7068    
7069                            qPos.add(vocabularyId);
7070    
7071                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7072                                    end);
7073                    }
7074                    catch (Exception e) {
7075                            throw processException(e);
7076                    }
7077                    finally {
7078                            closeSession(session);
7079                    }
7080            }
7081    
7082            /**
7083             * 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;.
7084             *
7085             * @param categoryId the primary key of the current asset category
7086             * @param groupId the group ID
7087             * @param parentCategoryId the parent category ID
7088             * @param vocabularyId the vocabulary ID
7089             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7090             * @return the previous, current, and next asset category
7091             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7092             * @throws SystemException if a system exception occurred
7093             */
7094            @Override
7095            public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
7096                    long groupId, long parentCategoryId, long vocabularyId,
7097                    OrderByComparator orderByComparator)
7098                    throws NoSuchCategoryException, SystemException {
7099                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7100                            return findByG_P_V_PrevAndNext(categoryId, groupId,
7101                                    parentCategoryId, vocabularyId, orderByComparator);
7102                    }
7103    
7104                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7105    
7106                    Session session = null;
7107    
7108                    try {
7109                            session = openSession();
7110    
7111                            AssetCategory[] array = new AssetCategoryImpl[3];
7112    
7113                            array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7114                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
7115                                            true);
7116    
7117                            array[1] = assetCategory;
7118    
7119                            array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
7120                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
7121                                            false);
7122    
7123                            return array;
7124                    }
7125                    catch (Exception e) {
7126                            throw processException(e);
7127                    }
7128                    finally {
7129                            closeSession(session);
7130                    }
7131            }
7132    
7133            protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
7134                    AssetCategory assetCategory, long groupId, long parentCategoryId,
7135                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7136                    StringBundler query = null;
7137    
7138                    if (orderByComparator != null) {
7139                            query = new StringBundler(6 +
7140                                            (orderByComparator.getOrderByFields().length * 6));
7141                    }
7142                    else {
7143                            query = new StringBundler(3);
7144                    }
7145    
7146                    if (getDB().isSupportsInlineDistinct()) {
7147                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7148                    }
7149                    else {
7150                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7151                    }
7152    
7153                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7154    
7155                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7156    
7157                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7158    
7159                    if (!getDB().isSupportsInlineDistinct()) {
7160                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7161                    }
7162    
7163                    if (orderByComparator != null) {
7164                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7165    
7166                            if (orderByConditionFields.length > 0) {
7167                                    query.append(WHERE_AND);
7168                            }
7169    
7170                            for (int i = 0; i < orderByConditionFields.length; i++) {
7171                                    if (getDB().isSupportsInlineDistinct()) {
7172                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7173                                    }
7174                                    else {
7175                                            query.append(_ORDER_BY_ENTITY_TABLE);
7176                                    }
7177    
7178                                    query.append(orderByConditionFields[i]);
7179    
7180                                    if ((i + 1) < orderByConditionFields.length) {
7181                                            if (orderByComparator.isAscending() ^ previous) {
7182                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7183                                            }
7184                                            else {
7185                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7186                                            }
7187                                    }
7188                                    else {
7189                                            if (orderByComparator.isAscending() ^ previous) {
7190                                                    query.append(WHERE_GREATER_THAN);
7191                                            }
7192                                            else {
7193                                                    query.append(WHERE_LESSER_THAN);
7194                                            }
7195                                    }
7196                            }
7197    
7198                            query.append(ORDER_BY_CLAUSE);
7199    
7200                            String[] orderByFields = orderByComparator.getOrderByFields();
7201    
7202                            for (int i = 0; i < orderByFields.length; i++) {
7203                                    if (getDB().isSupportsInlineDistinct()) {
7204                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7205                                    }
7206                                    else {
7207                                            query.append(_ORDER_BY_ENTITY_TABLE);
7208                                    }
7209    
7210                                    query.append(orderByFields[i]);
7211    
7212                                    if ((i + 1) < orderByFields.length) {
7213                                            if (orderByComparator.isAscending() ^ previous) {
7214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7215                                            }
7216                                            else {
7217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7218                                            }
7219                                    }
7220                                    else {
7221                                            if (orderByComparator.isAscending() ^ previous) {
7222                                                    query.append(ORDER_BY_ASC);
7223                                            }
7224                                            else {
7225                                                    query.append(ORDER_BY_DESC);
7226                                            }
7227                                    }
7228                            }
7229                    }
7230                    else {
7231                            if (getDB().isSupportsInlineDistinct()) {
7232                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7233                            }
7234                            else {
7235                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7236                            }
7237                    }
7238    
7239                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7240                                    AssetCategory.class.getName(),
7241                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7242    
7243                    SQLQuery q = session.createSQLQuery(sql);
7244    
7245                    q.setFirstResult(0);
7246                    q.setMaxResults(2);
7247    
7248                    if (getDB().isSupportsInlineDistinct()) {
7249                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7250                    }
7251                    else {
7252                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7253                    }
7254    
7255                    QueryPos qPos = QueryPos.getInstance(q);
7256    
7257                    qPos.add(groupId);
7258    
7259                    qPos.add(parentCategoryId);
7260    
7261                    qPos.add(vocabularyId);
7262    
7263                    if (orderByComparator != null) {
7264                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7265    
7266                            for (Object value : values) {
7267                                    qPos.add(value);
7268                            }
7269                    }
7270    
7271                    List<AssetCategory> list = q.list();
7272    
7273                    if (list.size() == 2) {
7274                            return list.get(1);
7275                    }
7276                    else {
7277                            return null;
7278                    }
7279            }
7280    
7281            /**
7282             * Removes all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63; from the database.
7283             *
7284             * @param groupId the group ID
7285             * @param parentCategoryId the parent category ID
7286             * @param vocabularyId the vocabulary ID
7287             * @throws SystemException if a system exception occurred
7288             */
7289            @Override
7290            public void removeByG_P_V(long groupId, long parentCategoryId,
7291                    long vocabularyId) throws SystemException {
7292                    for (AssetCategory assetCategory : findByG_P_V(groupId,
7293                                    parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
7294                                    QueryUtil.ALL_POS, null)) {
7295                            remove(assetCategory);
7296                    }
7297            }
7298    
7299            /**
7300             * Returns the number of asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
7301             *
7302             * @param groupId the group ID
7303             * @param parentCategoryId the parent category ID
7304             * @param vocabularyId the vocabulary ID
7305             * @return the number of matching asset categories
7306             * @throws SystemException if a system exception occurred
7307             */
7308            @Override
7309            public int countByG_P_V(long groupId, long parentCategoryId,
7310                    long vocabularyId) throws SystemException {
7311                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_P_V;
7312    
7313                    Object[] finderArgs = new Object[] {
7314                                    groupId, parentCategoryId, vocabularyId
7315                            };
7316    
7317                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
7318                                    this);
7319    
7320                    if (count == null) {
7321                            StringBundler query = new StringBundler(4);
7322    
7323                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
7324    
7325                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7326    
7327                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7328    
7329                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7330    
7331                            String sql = query.toString();
7332    
7333                            Session session = null;
7334    
7335                            try {
7336                                    session = openSession();
7337    
7338                                    Query q = session.createQuery(sql);
7339    
7340                                    QueryPos qPos = QueryPos.getInstance(q);
7341    
7342                                    qPos.add(groupId);
7343    
7344                                    qPos.add(parentCategoryId);
7345    
7346                                    qPos.add(vocabularyId);
7347    
7348                                    count = (Long)q.uniqueResult();
7349    
7350                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
7351                            }
7352                            catch (Exception e) {
7353                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7354    
7355                                    throw processException(e);
7356                            }
7357                            finally {
7358                                    closeSession(session);
7359                            }
7360                    }
7361    
7362                    return count.intValue();
7363            }
7364    
7365            /**
7366             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
7367             *
7368             * @param groupId the group ID
7369             * @param parentCategoryId the parent category ID
7370             * @param vocabularyId the vocabulary ID
7371             * @return the number of matching asset categories that the user has permission to view
7372             * @throws SystemException if a system exception occurred
7373             */
7374            @Override
7375            public int filterCountByG_P_V(long groupId, long parentCategoryId,
7376                    long vocabularyId) throws SystemException {
7377                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7378                            return countByG_P_V(groupId, parentCategoryId, vocabularyId);
7379                    }
7380    
7381                    StringBundler query = new StringBundler(4);
7382    
7383                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
7384    
7385                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
7386    
7387                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
7388    
7389                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
7390    
7391                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7392                                    AssetCategory.class.getName(),
7393                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7394    
7395                    Session session = null;
7396    
7397                    try {
7398                            session = openSession();
7399    
7400                            SQLQuery q = session.createSQLQuery(sql);
7401    
7402                            q.addScalar(COUNT_COLUMN_NAME,
7403                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
7404    
7405                            QueryPos qPos = QueryPos.getInstance(q);
7406    
7407                            qPos.add(groupId);
7408    
7409                            qPos.add(parentCategoryId);
7410    
7411                            qPos.add(vocabularyId);
7412    
7413                            Long count = (Long)q.uniqueResult();
7414    
7415                            return count.intValue();
7416                    }
7417                    catch (Exception e) {
7418                            throw processException(e);
7419                    }
7420                    finally {
7421                            closeSession(session);
7422                    }
7423            }
7424    
7425            private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7426            private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7427            private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7428            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
7429                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7430                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
7431                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
7432                            "findByG_LikeN_V",
7433                            new String[] {
7434                                    Long.class.getName(), String.class.getName(),
7435                                    Long.class.getName(),
7436                                    
7437                            Integer.class.getName(), Integer.class.getName(),
7438                                    OrderByComparator.class.getName()
7439                            });
7440            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
7441                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
7442                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
7443                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
7444                            new String[] {
7445                                    Long.class.getName(), String.class.getName(),
7446                                    Long.class.getName()
7447                            });
7448    
7449            /**
7450             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7451             *
7452             * @param groupId the group ID
7453             * @param name the name
7454             * @param vocabularyId the vocabulary ID
7455             * @return the matching asset categories
7456             * @throws SystemException if a system exception occurred
7457             */
7458            @Override
7459            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7460                    long vocabularyId) throws SystemException {
7461                    return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
7462                            QueryUtil.ALL_POS, null);
7463            }
7464    
7465            /**
7466             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7467             *
7468             * <p>
7469             * 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.
7470             * </p>
7471             *
7472             * @param groupId the group ID
7473             * @param name the name
7474             * @param vocabularyId the vocabulary ID
7475             * @param start the lower bound of the range of asset categories
7476             * @param end the upper bound of the range of asset categories (not inclusive)
7477             * @return the range of matching asset categories
7478             * @throws SystemException if a system exception occurred
7479             */
7480            @Override
7481            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7482                    long vocabularyId, int start, int end) throws SystemException {
7483                    return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
7484            }
7485    
7486            /**
7487             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7488             *
7489             * <p>
7490             * 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.
7491             * </p>
7492             *
7493             * @param groupId the group ID
7494             * @param name the name
7495             * @param vocabularyId the vocabulary ID
7496             * @param start the lower bound of the range of asset categories
7497             * @param end the upper bound of the range of asset categories (not inclusive)
7498             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7499             * @return the ordered range of matching asset categories
7500             * @throws SystemException if a system exception occurred
7501             */
7502            @Override
7503            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
7504                    long vocabularyId, int start, int end,
7505                    OrderByComparator orderByComparator) throws SystemException {
7506                    boolean pagination = true;
7507                    FinderPath finderPath = null;
7508                    Object[] finderArgs = null;
7509    
7510                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
7511                    finderArgs = new Object[] {
7512                                    groupId, name, vocabularyId,
7513                                    
7514                                    start, end, orderByComparator
7515                            };
7516    
7517                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7518                                    finderArgs, this);
7519    
7520                    if ((list != null) && !list.isEmpty()) {
7521                            for (AssetCategory assetCategory : list) {
7522                                    if ((groupId != assetCategory.getGroupId()) ||
7523                                                    !StringUtil.wildcardMatches(assetCategory.getName(),
7524                                                            name, CharPool.UNDERLINE, CharPool.PERCENT,
7525                                                            CharPool.BACK_SLASH, false) ||
7526                                                    (vocabularyId != assetCategory.getVocabularyId())) {
7527                                            list = null;
7528    
7529                                            break;
7530                                    }
7531                            }
7532                    }
7533    
7534                    if (list == null) {
7535                            StringBundler query = null;
7536    
7537                            if (orderByComparator != null) {
7538                                    query = new StringBundler(5 +
7539                                                    (orderByComparator.getOrderByFields().length * 3));
7540                            }
7541                            else {
7542                                    query = new StringBundler(5);
7543                            }
7544    
7545                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7546    
7547                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7548    
7549                            boolean bindName = false;
7550    
7551                            if (name == null) {
7552                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7553                            }
7554                            else if (name.equals(StringPool.BLANK)) {
7555                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7556                            }
7557                            else {
7558                                    bindName = true;
7559    
7560                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7561                            }
7562    
7563                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7564    
7565                            if (orderByComparator != null) {
7566                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7567                                            orderByComparator);
7568                            }
7569                            else
7570                             if (pagination) {
7571                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7572                            }
7573    
7574                            String sql = query.toString();
7575    
7576                            Session session = null;
7577    
7578                            try {
7579                                    session = openSession();
7580    
7581                                    Query q = session.createQuery(sql);
7582    
7583                                    QueryPos qPos = QueryPos.getInstance(q);
7584    
7585                                    qPos.add(groupId);
7586    
7587                                    if (bindName) {
7588                                            qPos.add(name.toLowerCase());
7589                                    }
7590    
7591                                    qPos.add(vocabularyId);
7592    
7593                                    if (!pagination) {
7594                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7595                                                            start, end, false);
7596    
7597                                            Collections.sort(list);
7598    
7599                                            list = new UnmodifiableList<AssetCategory>(list);
7600                                    }
7601                                    else {
7602                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7603                                                            start, end);
7604                                    }
7605    
7606                                    cacheResult(list);
7607    
7608                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
7609                            }
7610                            catch (Exception e) {
7611                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
7612    
7613                                    throw processException(e);
7614                            }
7615                            finally {
7616                                    closeSession(session);
7617                            }
7618                    }
7619    
7620                    return list;
7621            }
7622    
7623            /**
7624             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7625             *
7626             * @param groupId the group ID
7627             * @param name the name
7628             * @param vocabularyId the vocabulary ID
7629             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7630             * @return the first matching asset category
7631             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7632             * @throws SystemException if a system exception occurred
7633             */
7634            @Override
7635            public AssetCategory findByG_LikeN_V_First(long groupId, String name,
7636                    long vocabularyId, OrderByComparator orderByComparator)
7637                    throws NoSuchCategoryException, SystemException {
7638                    AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
7639                                    vocabularyId, orderByComparator);
7640    
7641                    if (assetCategory != null) {
7642                            return assetCategory;
7643                    }
7644    
7645                    StringBundler msg = new StringBundler(8);
7646    
7647                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7648    
7649                    msg.append("groupId=");
7650                    msg.append(groupId);
7651    
7652                    msg.append(", name=");
7653                    msg.append(name);
7654    
7655                    msg.append(", vocabularyId=");
7656                    msg.append(vocabularyId);
7657    
7658                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7659    
7660                    throw new NoSuchCategoryException(msg.toString());
7661            }
7662    
7663            /**
7664             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7665             *
7666             * @param groupId the group ID
7667             * @param name the name
7668             * @param vocabularyId the vocabulary ID
7669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7670             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
7671             * @throws SystemException if a system exception occurred
7672             */
7673            @Override
7674            public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
7675                    long vocabularyId, OrderByComparator orderByComparator)
7676                    throws SystemException {
7677                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7678                                    0, 1, orderByComparator);
7679    
7680                    if (!list.isEmpty()) {
7681                            return list.get(0);
7682                    }
7683    
7684                    return null;
7685            }
7686    
7687            /**
7688             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7689             *
7690             * @param groupId the group ID
7691             * @param name the name
7692             * @param vocabularyId the vocabulary ID
7693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7694             * @return the last matching asset category
7695             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7696             * @throws SystemException if a system exception occurred
7697             */
7698            @Override
7699            public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
7700                    long vocabularyId, OrderByComparator orderByComparator)
7701                    throws NoSuchCategoryException, SystemException {
7702                    AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
7703                                    vocabularyId, orderByComparator);
7704    
7705                    if (assetCategory != null) {
7706                            return assetCategory;
7707                    }
7708    
7709                    StringBundler msg = new StringBundler(8);
7710    
7711                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7712    
7713                    msg.append("groupId=");
7714                    msg.append(groupId);
7715    
7716                    msg.append(", name=");
7717                    msg.append(name);
7718    
7719                    msg.append(", vocabularyId=");
7720                    msg.append(vocabularyId);
7721    
7722                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7723    
7724                    throw new NoSuchCategoryException(msg.toString());
7725            }
7726    
7727            /**
7728             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7729             *
7730             * @param groupId the group ID
7731             * @param name the name
7732             * @param vocabularyId the vocabulary ID
7733             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7734             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
7735             * @throws SystemException if a system exception occurred
7736             */
7737            @Override
7738            public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
7739                    long vocabularyId, OrderByComparator orderByComparator)
7740                    throws SystemException {
7741                    int count = countByG_LikeN_V(groupId, name, vocabularyId);
7742    
7743                    if (count == 0) {
7744                            return null;
7745                    }
7746    
7747                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
7748                                    count - 1, count, orderByComparator);
7749    
7750                    if (!list.isEmpty()) {
7751                            return list.get(0);
7752                    }
7753    
7754                    return null;
7755            }
7756    
7757            /**
7758             * 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;.
7759             *
7760             * @param categoryId the primary key of the current asset category
7761             * @param groupId the group ID
7762             * @param name the name
7763             * @param vocabularyId the vocabulary ID
7764             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7765             * @return the previous, current, and next asset category
7766             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7767             * @throws SystemException if a system exception occurred
7768             */
7769            @Override
7770            public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
7771                    long groupId, String name, long vocabularyId,
7772                    OrderByComparator orderByComparator)
7773                    throws NoSuchCategoryException, SystemException {
7774                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7775    
7776                    Session session = null;
7777    
7778                    try {
7779                            session = openSession();
7780    
7781                            AssetCategory[] array = new AssetCategoryImpl[3];
7782    
7783                            array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7784                                            groupId, name, vocabularyId, orderByComparator, true);
7785    
7786                            array[1] = assetCategory;
7787    
7788                            array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
7789                                            groupId, name, vocabularyId, orderByComparator, false);
7790    
7791                            return array;
7792                    }
7793                    catch (Exception e) {
7794                            throw processException(e);
7795                    }
7796                    finally {
7797                            closeSession(session);
7798                    }
7799            }
7800    
7801            protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
7802                    AssetCategory assetCategory, long groupId, String name,
7803                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7804                    StringBundler query = null;
7805    
7806                    if (orderByComparator != null) {
7807                            query = new StringBundler(6 +
7808                                            (orderByComparator.getOrderByFields().length * 6));
7809                    }
7810                    else {
7811                            query = new StringBundler(3);
7812                    }
7813    
7814                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7815    
7816                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7817    
7818                    boolean bindName = false;
7819    
7820                    if (name == null) {
7821                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7822                    }
7823                    else if (name.equals(StringPool.BLANK)) {
7824                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7825                    }
7826                    else {
7827                            bindName = true;
7828    
7829                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7830                    }
7831    
7832                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7833    
7834                    if (orderByComparator != null) {
7835                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7836    
7837                            if (orderByConditionFields.length > 0) {
7838                                    query.append(WHERE_AND);
7839                            }
7840    
7841                            for (int i = 0; i < orderByConditionFields.length; i++) {
7842                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7843                                    query.append(orderByConditionFields[i]);
7844    
7845                                    if ((i + 1) < orderByConditionFields.length) {
7846                                            if (orderByComparator.isAscending() ^ previous) {
7847                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7848                                            }
7849                                            else {
7850                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7851                                            }
7852                                    }
7853                                    else {
7854                                            if (orderByComparator.isAscending() ^ previous) {
7855                                                    query.append(WHERE_GREATER_THAN);
7856                                            }
7857                                            else {
7858                                                    query.append(WHERE_LESSER_THAN);
7859                                            }
7860                                    }
7861                            }
7862    
7863                            query.append(ORDER_BY_CLAUSE);
7864    
7865                            String[] orderByFields = orderByComparator.getOrderByFields();
7866    
7867                            for (int i = 0; i < orderByFields.length; i++) {
7868                                    query.append(_ORDER_BY_ENTITY_ALIAS);
7869                                    query.append(orderByFields[i]);
7870    
7871                                    if ((i + 1) < orderByFields.length) {
7872                                            if (orderByComparator.isAscending() ^ previous) {
7873                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7874                                            }
7875                                            else {
7876                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7877                                            }
7878                                    }
7879                                    else {
7880                                            if (orderByComparator.isAscending() ^ previous) {
7881                                                    query.append(ORDER_BY_ASC);
7882                                            }
7883                                            else {
7884                                                    query.append(ORDER_BY_DESC);
7885                                            }
7886                                    }
7887                            }
7888                    }
7889                    else {
7890                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7891                    }
7892    
7893                    String sql = query.toString();
7894    
7895                    Query q = session.createQuery(sql);
7896    
7897                    q.setFirstResult(0);
7898                    q.setMaxResults(2);
7899    
7900                    QueryPos qPos = QueryPos.getInstance(q);
7901    
7902                    qPos.add(groupId);
7903    
7904                    if (bindName) {
7905                            qPos.add(name.toLowerCase());
7906                    }
7907    
7908                    qPos.add(vocabularyId);
7909    
7910                    if (orderByComparator != null) {
7911                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7912    
7913                            for (Object value : values) {
7914                                    qPos.add(value);
7915                            }
7916                    }
7917    
7918                    List<AssetCategory> list = q.list();
7919    
7920                    if (list.size() == 2) {
7921                            return list.get(1);
7922                    }
7923                    else {
7924                            return null;
7925                    }
7926            }
7927    
7928            /**
7929             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
7930             *
7931             * @param groupId the group ID
7932             * @param name the name
7933             * @param vocabularyId the vocabulary ID
7934             * @return the matching asset categories that the user has permission to view
7935             * @throws SystemException if a system exception occurred
7936             */
7937            @Override
7938            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7939                    long vocabularyId) throws SystemException {
7940                    return filterFindByG_LikeN_V(groupId, name, vocabularyId,
7941                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7942            }
7943    
7944            /**
7945             * 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;.
7946             *
7947             * <p>
7948             * 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.
7949             * </p>
7950             *
7951             * @param groupId the group ID
7952             * @param name the name
7953             * @param vocabularyId the vocabulary ID
7954             * @param start the lower bound of the range of asset categories
7955             * @param end the upper bound of the range of asset categories (not inclusive)
7956             * @return the range of matching asset categories that the user has permission to view
7957             * @throws SystemException if a system exception occurred
7958             */
7959            @Override
7960            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7961                    long vocabularyId, int start, int end) throws SystemException {
7962                    return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
7963                            null);
7964            }
7965    
7966            /**
7967             * 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;.
7968             *
7969             * <p>
7970             * 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.
7971             * </p>
7972             *
7973             * @param groupId the group ID
7974             * @param name the name
7975             * @param vocabularyId the vocabulary ID
7976             * @param start the lower bound of the range of asset categories
7977             * @param end the upper bound of the range of asset categories (not inclusive)
7978             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7979             * @return the ordered range of matching asset categories that the user has permission to view
7980             * @throws SystemException if a system exception occurred
7981             */
7982            @Override
7983            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7984                    long vocabularyId, int start, int end,
7985                    OrderByComparator orderByComparator) throws SystemException {
7986                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7987                            return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
7988                                    orderByComparator);
7989                    }
7990    
7991                    StringBundler query = null;
7992    
7993                    if (orderByComparator != null) {
7994                            query = new StringBundler(5 +
7995                                            (orderByComparator.getOrderByFields().length * 3));
7996                    }
7997                    else {
7998                            query = new StringBundler(5);
7999                    }
8000    
8001                    if (getDB().isSupportsInlineDistinct()) {
8002                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8003                    }
8004                    else {
8005                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8006                    }
8007    
8008                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8009    
8010                    boolean bindName = false;
8011    
8012                    if (name == null) {
8013                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8014                    }
8015                    else if (name.equals(StringPool.BLANK)) {
8016                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8017                    }
8018                    else {
8019                            bindName = true;
8020    
8021                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8022                    }
8023    
8024                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8025    
8026                    if (!getDB().isSupportsInlineDistinct()) {
8027                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8028                    }
8029    
8030                    if (orderByComparator != null) {
8031                            if (getDB().isSupportsInlineDistinct()) {
8032                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8033                                            orderByComparator, true);
8034                            }
8035                            else {
8036                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8037                                            orderByComparator, true);
8038                            }
8039                    }
8040                    else {
8041                            if (getDB().isSupportsInlineDistinct()) {
8042                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8043                            }
8044                            else {
8045                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8046                            }
8047                    }
8048    
8049                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8050                                    AssetCategory.class.getName(),
8051                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8052    
8053                    Session session = null;
8054    
8055                    try {
8056                            session = openSession();
8057    
8058                            SQLQuery q = session.createSQLQuery(sql);
8059    
8060                            if (getDB().isSupportsInlineDistinct()) {
8061                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8062                            }
8063                            else {
8064                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8065                            }
8066    
8067                            QueryPos qPos = QueryPos.getInstance(q);
8068    
8069                            qPos.add(groupId);
8070    
8071                            if (bindName) {
8072                                    qPos.add(name.toLowerCase());
8073                            }
8074    
8075                            qPos.add(vocabularyId);
8076    
8077                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8078                                    end);
8079                    }
8080                    catch (Exception e) {
8081                            throw processException(e);
8082                    }
8083                    finally {
8084                            closeSession(session);
8085                    }
8086            }
8087    
8088            /**
8089             * 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;.
8090             *
8091             * @param categoryId the primary key of the current asset category
8092             * @param groupId the group ID
8093             * @param name the name
8094             * @param vocabularyId the vocabulary ID
8095             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8096             * @return the previous, current, and next asset category
8097             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
8098             * @throws SystemException if a system exception occurred
8099             */
8100            @Override
8101            public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
8102                    long groupId, String name, long vocabularyId,
8103                    OrderByComparator orderByComparator)
8104                    throws NoSuchCategoryException, SystemException {
8105                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8106                            return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
8107                                    vocabularyId, orderByComparator);
8108                    }
8109    
8110                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
8111    
8112                    Session session = null;
8113    
8114                    try {
8115                            session = openSession();
8116    
8117                            AssetCategory[] array = new AssetCategoryImpl[3];
8118    
8119                            array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8120                                            groupId, name, vocabularyId, orderByComparator, true);
8121    
8122                            array[1] = assetCategory;
8123    
8124                            array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
8125                                            groupId, name, vocabularyId, orderByComparator, false);
8126    
8127                            return array;
8128                    }
8129                    catch (Exception e) {
8130                            throw processException(e);
8131                    }
8132                    finally {
8133                            closeSession(session);
8134                    }
8135            }
8136    
8137            protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
8138                    AssetCategory assetCategory, long groupId, String name,
8139                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
8140                    StringBundler query = null;
8141    
8142                    if (orderByComparator != null) {
8143                            query = new StringBundler(6 +
8144                                            (orderByComparator.getOrderByFields().length * 6));
8145                    }
8146                    else {
8147                            query = new StringBundler(3);
8148                    }
8149    
8150                    if (getDB().isSupportsInlineDistinct()) {
8151                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8152                    }
8153                    else {
8154                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8155                    }
8156    
8157                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8158    
8159                    boolean bindName = false;
8160    
8161                    if (name == null) {
8162                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8163                    }
8164                    else if (name.equals(StringPool.BLANK)) {
8165                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8166                    }
8167                    else {
8168                            bindName = true;
8169    
8170                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8171                    }
8172    
8173                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8174    
8175                    if (!getDB().isSupportsInlineDistinct()) {
8176                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8177                    }
8178    
8179                    if (orderByComparator != null) {
8180                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8181    
8182                            if (orderByConditionFields.length > 0) {
8183                                    query.append(WHERE_AND);
8184                            }
8185    
8186                            for (int i = 0; i < orderByConditionFields.length; i++) {
8187                                    if (getDB().isSupportsInlineDistinct()) {
8188                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8189                                    }
8190                                    else {
8191                                            query.append(_ORDER_BY_ENTITY_TABLE);
8192                                    }
8193    
8194                                    query.append(orderByConditionFields[i]);
8195    
8196                                    if ((i + 1) < orderByConditionFields.length) {
8197                                            if (orderByComparator.isAscending() ^ previous) {
8198                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8199                                            }
8200                                            else {
8201                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8202                                            }
8203                                    }
8204                                    else {
8205                                            if (orderByComparator.isAscending() ^ previous) {
8206                                                    query.append(WHERE_GREATER_THAN);
8207                                            }
8208                                            else {
8209                                                    query.append(WHERE_LESSER_THAN);
8210                                            }
8211                                    }
8212                            }
8213    
8214                            query.append(ORDER_BY_CLAUSE);
8215    
8216                            String[] orderByFields = orderByComparator.getOrderByFields();
8217    
8218                            for (int i = 0; i < orderByFields.length; i++) {
8219                                    if (getDB().isSupportsInlineDistinct()) {
8220                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8221                                    }
8222                                    else {
8223                                            query.append(_ORDER_BY_ENTITY_TABLE);
8224                                    }
8225    
8226                                    query.append(orderByFields[i]);
8227    
8228                                    if ((i + 1) < orderByFields.length) {
8229                                            if (orderByComparator.isAscending() ^ previous) {
8230                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8231                                            }
8232                                            else {
8233                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8234                                            }
8235                                    }
8236                                    else {
8237                                            if (orderByComparator.isAscending() ^ previous) {
8238                                                    query.append(ORDER_BY_ASC);
8239                                            }
8240                                            else {
8241                                                    query.append(ORDER_BY_DESC);
8242                                            }
8243                                    }
8244                            }
8245                    }
8246                    else {
8247                            if (getDB().isSupportsInlineDistinct()) {
8248                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8249                            }
8250                            else {
8251                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8252                            }
8253                    }
8254    
8255                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8256                                    AssetCategory.class.getName(),
8257                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8258    
8259                    SQLQuery q = session.createSQLQuery(sql);
8260    
8261                    q.setFirstResult(0);
8262                    q.setMaxResults(2);
8263    
8264                    if (getDB().isSupportsInlineDistinct()) {
8265                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8266                    }
8267                    else {
8268                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8269                    }
8270    
8271                    QueryPos qPos = QueryPos.getInstance(q);
8272    
8273                    qPos.add(groupId);
8274    
8275                    if (bindName) {
8276                            qPos.add(name.toLowerCase());
8277                    }
8278    
8279                    qPos.add(vocabularyId);
8280    
8281                    if (orderByComparator != null) {
8282                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8283    
8284                            for (Object value : values) {
8285                                    qPos.add(value);
8286                            }
8287                    }
8288    
8289                    List<AssetCategory> list = q.list();
8290    
8291                    if (list.size() == 2) {
8292                            return list.get(1);
8293                    }
8294                    else {
8295                            return null;
8296                    }
8297            }
8298    
8299            /**
8300             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8301             *
8302             * @param groupId the group ID
8303             * @param name the name
8304             * @param vocabularyIds the vocabulary IDs
8305             * @return the matching asset categories that the user has permission to view
8306             * @throws SystemException if a system exception occurred
8307             */
8308            @Override
8309            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8310                    long[] vocabularyIds) throws SystemException {
8311                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
8312                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8313            }
8314    
8315            /**
8316             * 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;.
8317             *
8318             * <p>
8319             * 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.
8320             * </p>
8321             *
8322             * @param groupId the group ID
8323             * @param name the name
8324             * @param vocabularyIds the vocabulary IDs
8325             * @param start the lower bound of the range of asset categories
8326             * @param end the upper bound of the range of asset categories (not inclusive)
8327             * @return the range of matching asset categories that the user has permission to view
8328             * @throws SystemException if a system exception occurred
8329             */
8330            @Override
8331            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8332                    long[] vocabularyIds, int start, int end) throws SystemException {
8333                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8334                            null);
8335            }
8336    
8337            /**
8338             * 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;.
8339             *
8340             * <p>
8341             * 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.
8342             * </p>
8343             *
8344             * @param groupId the group ID
8345             * @param name the name
8346             * @param vocabularyIds the vocabulary IDs
8347             * @param start the lower bound of the range of asset categories
8348             * @param end the upper bound of the range of asset categories (not inclusive)
8349             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8350             * @return the ordered range of matching asset categories that the user has permission to view
8351             * @throws SystemException if a system exception occurred
8352             */
8353            @Override
8354            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
8355                    long[] vocabularyIds, int start, int end,
8356                    OrderByComparator orderByComparator) throws SystemException {
8357                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8358                            return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
8359                                    orderByComparator);
8360                    }
8361    
8362                    StringBundler query = new StringBundler();
8363    
8364                    if (getDB().isSupportsInlineDistinct()) {
8365                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8366                    }
8367                    else {
8368                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8369                    }
8370    
8371                    boolean conjunctionable = false;
8372    
8373                    if (conjunctionable) {
8374                            query.append(WHERE_AND);
8375                    }
8376    
8377                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8378    
8379                    conjunctionable = true;
8380    
8381                    if (conjunctionable) {
8382                            query.append(WHERE_AND);
8383                    }
8384    
8385                    boolean bindName = false;
8386    
8387                    if (name == null) {
8388                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8389                    }
8390                    else if (name.equals(StringPool.BLANK)) {
8391                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8392                    }
8393                    else {
8394                            bindName = true;
8395    
8396                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8397                    }
8398    
8399                    conjunctionable = true;
8400    
8401                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8402                            if (conjunctionable) {
8403                                    query.append(WHERE_AND);
8404                            }
8405    
8406                            query.append(StringPool.OPEN_PARENTHESIS);
8407    
8408                            for (int i = 0; i < vocabularyIds.length; i++) {
8409                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8410    
8411                                    if ((i + 1) < vocabularyIds.length) {
8412                                            query.append(WHERE_OR);
8413                                    }
8414                            }
8415    
8416                            query.append(StringPool.CLOSE_PARENTHESIS);
8417    
8418                            conjunctionable = true;
8419                    }
8420    
8421                    if (!getDB().isSupportsInlineDistinct()) {
8422                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8423                    }
8424    
8425                    if (orderByComparator != null) {
8426                            if (getDB().isSupportsInlineDistinct()) {
8427                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8428                                            orderByComparator, true);
8429                            }
8430                            else {
8431                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8432                                            orderByComparator, true);
8433                            }
8434                    }
8435                    else {
8436                            if (getDB().isSupportsInlineDistinct()) {
8437                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8438                            }
8439                            else {
8440                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8441                            }
8442                    }
8443    
8444                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8445                                    AssetCategory.class.getName(),
8446                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8447    
8448                    Session session = null;
8449    
8450                    try {
8451                            session = openSession();
8452    
8453                            SQLQuery q = session.createSQLQuery(sql);
8454    
8455                            if (getDB().isSupportsInlineDistinct()) {
8456                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8457                            }
8458                            else {
8459                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8460                            }
8461    
8462                            QueryPos qPos = QueryPos.getInstance(q);
8463    
8464                            qPos.add(groupId);
8465    
8466                            if (bindName) {
8467                                    qPos.add(name);
8468                            }
8469    
8470                            if (vocabularyIds != null) {
8471                                    qPos.add(vocabularyIds);
8472                            }
8473    
8474                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8475                                    end);
8476                    }
8477                    catch (Exception e) {
8478                            throw processException(e);
8479                    }
8480                    finally {
8481                            closeSession(session);
8482                    }
8483            }
8484    
8485            /**
8486             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8487             *
8488             * <p>
8489             * 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.
8490             * </p>
8491             *
8492             * @param groupId the group ID
8493             * @param name the name
8494             * @param vocabularyIds the vocabulary IDs
8495             * @return the matching asset categories
8496             * @throws SystemException if a system exception occurred
8497             */
8498            @Override
8499            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8500                    long[] vocabularyIds) throws SystemException {
8501                    return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
8502                            QueryUtil.ALL_POS, null);
8503            }
8504    
8505            /**
8506             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8507             *
8508             * <p>
8509             * 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.
8510             * </p>
8511             *
8512             * @param groupId the group ID
8513             * @param name the name
8514             * @param vocabularyIds the vocabulary IDs
8515             * @param start the lower bound of the range of asset categories
8516             * @param end the upper bound of the range of asset categories (not inclusive)
8517             * @return the range of matching asset categories
8518             * @throws SystemException if a system exception occurred
8519             */
8520            @Override
8521            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8522                    long[] vocabularyIds, int start, int end) throws SystemException {
8523                    return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
8524            }
8525    
8526            /**
8527             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8528             *
8529             * <p>
8530             * 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.
8531             * </p>
8532             *
8533             * @param groupId the group ID
8534             * @param name the name
8535             * @param vocabularyIds the vocabulary IDs
8536             * @param start the lower bound of the range of asset categories
8537             * @param end the upper bound of the range of asset categories (not inclusive)
8538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8539             * @return the ordered range of matching asset categories
8540             * @throws SystemException if a system exception occurred
8541             */
8542            @Override
8543            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
8544                    long[] vocabularyIds, int start, int end,
8545                    OrderByComparator orderByComparator) throws SystemException {
8546                    if ((vocabularyIds != null) && (vocabularyIds.length == 1)) {
8547                            return findByG_LikeN_V(groupId, name, vocabularyIds[0], start, end,
8548                                    orderByComparator);
8549                    }
8550    
8551                    boolean pagination = true;
8552                    Object[] finderArgs = null;
8553    
8554                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8555                                    (orderByComparator == null)) {
8556                            pagination = false;
8557                            finderArgs = new Object[] {
8558                                            groupId, name, StringUtil.merge(vocabularyIds)
8559                                    };
8560                    }
8561                    else {
8562                            finderArgs = new Object[] {
8563                                            groupId, name, StringUtil.merge(vocabularyIds),
8564                                            
8565                                            start, end, orderByComparator
8566                                    };
8567                    }
8568    
8569                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8570                                    finderArgs, this);
8571    
8572                    if ((list != null) && !list.isEmpty()) {
8573                            for (AssetCategory assetCategory : list) {
8574                                    if ((groupId != assetCategory.getGroupId()) ||
8575                                                    !StringUtil.wildcardMatches(assetCategory.getName(),
8576                                                            name, CharPool.UNDERLINE, CharPool.PERCENT,
8577                                                            CharPool.BACK_SLASH, false) ||
8578                                                    !ArrayUtil.contains(vocabularyIds,
8579                                                            assetCategory.getVocabularyId())) {
8580                                            list = null;
8581    
8582                                            break;
8583                                    }
8584                            }
8585                    }
8586    
8587                    if (list == null) {
8588                            StringBundler query = new StringBundler();
8589    
8590                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8591    
8592                            boolean conjunctionable = false;
8593    
8594                            if (conjunctionable) {
8595                                    query.append(WHERE_AND);
8596                            }
8597    
8598                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8599    
8600                            conjunctionable = true;
8601    
8602                            if (conjunctionable) {
8603                                    query.append(WHERE_AND);
8604                            }
8605    
8606                            boolean bindName = false;
8607    
8608                            if (name == null) {
8609                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8610                            }
8611                            else if (name.equals(StringPool.BLANK)) {
8612                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8613                            }
8614                            else {
8615                                    bindName = true;
8616    
8617                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8618                            }
8619    
8620                            conjunctionable = true;
8621    
8622                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8623                                    if (conjunctionable) {
8624                                            query.append(WHERE_AND);
8625                                    }
8626    
8627                                    query.append(StringPool.OPEN_PARENTHESIS);
8628    
8629                                    for (int i = 0; i < vocabularyIds.length; i++) {
8630                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8631    
8632                                            if ((i + 1) < vocabularyIds.length) {
8633                                                    query.append(WHERE_OR);
8634                                            }
8635                                    }
8636    
8637                                    query.append(StringPool.CLOSE_PARENTHESIS);
8638    
8639                                    conjunctionable = true;
8640                            }
8641    
8642                            if (orderByComparator != null) {
8643                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8644                                            orderByComparator);
8645                            }
8646                            else
8647                             if (pagination) {
8648                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8649                            }
8650    
8651                            String sql = query.toString();
8652    
8653                            Session session = null;
8654    
8655                            try {
8656                                    session = openSession();
8657    
8658                                    Query q = session.createQuery(sql);
8659    
8660                                    QueryPos qPos = QueryPos.getInstance(q);
8661    
8662                                    qPos.add(groupId);
8663    
8664                                    if (bindName) {
8665                                            qPos.add(name);
8666                                    }
8667    
8668                                    if (vocabularyIds != null) {
8669                                            qPos.add(vocabularyIds);
8670                                    }
8671    
8672                                    if (!pagination) {
8673                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8674                                                            start, end, false);
8675    
8676                                            Collections.sort(list);
8677    
8678                                            list = new UnmodifiableList<AssetCategory>(list);
8679                                    }
8680                                    else {
8681                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8682                                                            start, end);
8683                                    }
8684    
8685                                    cacheResult(list);
8686    
8687                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8688                                            finderArgs, list);
8689                            }
8690                            catch (Exception e) {
8691                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V,
8692                                            finderArgs);
8693    
8694                                    throw processException(e);
8695                            }
8696                            finally {
8697                                    closeSession(session);
8698                            }
8699                    }
8700    
8701                    return list;
8702            }
8703    
8704            /**
8705             * Removes all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63; from the database.
8706             *
8707             * @param groupId the group ID
8708             * @param name the name
8709             * @param vocabularyId the vocabulary ID
8710             * @throws SystemException if a system exception occurred
8711             */
8712            @Override
8713            public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8714                    throws SystemException {
8715                    for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8716                                    vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
8717                            remove(assetCategory);
8718                    }
8719            }
8720    
8721            /**
8722             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
8723             *
8724             * @param groupId the group ID
8725             * @param name the name
8726             * @param vocabularyId the vocabulary ID
8727             * @return the number of matching asset categories
8728             * @throws SystemException if a system exception occurred
8729             */
8730            @Override
8731            public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
8732                    throws SystemException {
8733                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V;
8734    
8735                    Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
8736    
8737                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
8738                                    this);
8739    
8740                    if (count == null) {
8741                            StringBundler query = new StringBundler(4);
8742    
8743                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8744    
8745                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8746    
8747                            boolean bindName = false;
8748    
8749                            if (name == null) {
8750                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8751                            }
8752                            else if (name.equals(StringPool.BLANK)) {
8753                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8754                            }
8755                            else {
8756                                    bindName = true;
8757    
8758                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8759                            }
8760    
8761                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8762    
8763                            String sql = query.toString();
8764    
8765                            Session session = null;
8766    
8767                            try {
8768                                    session = openSession();
8769    
8770                                    Query q = session.createQuery(sql);
8771    
8772                                    QueryPos qPos = QueryPos.getInstance(q);
8773    
8774                                    qPos.add(groupId);
8775    
8776                                    if (bindName) {
8777                                            qPos.add(name.toLowerCase());
8778                                    }
8779    
8780                                    qPos.add(vocabularyId);
8781    
8782                                    count = (Long)q.uniqueResult();
8783    
8784                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
8785                            }
8786                            catch (Exception e) {
8787                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
8788    
8789                                    throw processException(e);
8790                            }
8791                            finally {
8792                                    closeSession(session);
8793                            }
8794                    }
8795    
8796                    return count.intValue();
8797            }
8798    
8799            /**
8800             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8801             *
8802             * @param groupId the group ID
8803             * @param name the name
8804             * @param vocabularyIds the vocabulary IDs
8805             * @return the number of matching asset categories
8806             * @throws SystemException if a system exception occurred
8807             */
8808            @Override
8809            public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
8810                    throws SystemException {
8811                    Object[] finderArgs = new Object[] {
8812                                    groupId, name, StringUtil.merge(vocabularyIds)
8813                            };
8814    
8815                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8816                                    finderArgs, this);
8817    
8818                    if (count == null) {
8819                            StringBundler query = new StringBundler();
8820    
8821                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8822    
8823                            boolean conjunctionable = false;
8824    
8825                            if (conjunctionable) {
8826                                    query.append(WHERE_AND);
8827                            }
8828    
8829                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
8830    
8831                            conjunctionable = true;
8832    
8833                            if (conjunctionable) {
8834                                    query.append(WHERE_AND);
8835                            }
8836    
8837                            boolean bindName = false;
8838    
8839                            if (name == null) {
8840                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
8841                            }
8842                            else if (name.equals(StringPool.BLANK)) {
8843                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
8844                            }
8845                            else {
8846                                    bindName = true;
8847    
8848                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
8849                            }
8850    
8851                            conjunctionable = true;
8852    
8853                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
8854                                    if (conjunctionable) {
8855                                            query.append(WHERE_AND);
8856                                    }
8857    
8858                                    query.append(StringPool.OPEN_PARENTHESIS);
8859    
8860                                    for (int i = 0; i < vocabularyIds.length; i++) {
8861                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
8862    
8863                                            if ((i + 1) < vocabularyIds.length) {
8864                                                    query.append(WHERE_OR);
8865                                            }
8866                                    }
8867    
8868                                    query.append(StringPool.CLOSE_PARENTHESIS);
8869    
8870                                    conjunctionable = true;
8871                            }
8872    
8873                            String sql = query.toString();
8874    
8875                            Session session = null;
8876    
8877                            try {
8878                                    session = openSession();
8879    
8880                                    Query q = session.createQuery(sql);
8881    
8882                                    QueryPos qPos = QueryPos.getInstance(q);
8883    
8884                                    qPos.add(groupId);
8885    
8886                                    if (bindName) {
8887                                            qPos.add(name);
8888                                    }
8889    
8890                                    if (vocabularyIds != null) {
8891                                            qPos.add(vocabularyIds);
8892                                    }
8893    
8894                                    count = (Long)q.uniqueResult();
8895    
8896                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8897                                            finderArgs, count);
8898                            }
8899                            catch (Exception e) {
8900                                    FinderCacheUtil.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
8901                                            finderArgs);
8902    
8903                                    throw processException(e);
8904                            }
8905                            finally {
8906                                    closeSession(session);
8907                            }
8908                    }
8909    
8910                    return count.intValue();
8911            }
8912    
8913            /**
8914             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
8915             *
8916             * @param groupId the group ID
8917             * @param name the name
8918             * @param vocabularyId the vocabulary ID
8919             * @return the number of matching asset categories that the user has permission to view
8920             * @throws SystemException if a system exception occurred
8921             */
8922            @Override
8923            public int filterCountByG_LikeN_V(long groupId, String name,
8924                    long vocabularyId) throws SystemException {
8925                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8926                            return countByG_LikeN_V(groupId, name, vocabularyId);
8927                    }
8928    
8929                    StringBundler query = new StringBundler(4);
8930    
8931                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
8932    
8933                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
8934    
8935                    boolean bindName = false;
8936    
8937                    if (name == null) {
8938                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
8939                    }
8940                    else if (name.equals(StringPool.BLANK)) {
8941                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
8942                    }
8943                    else {
8944                            bindName = true;
8945    
8946                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
8947                    }
8948    
8949                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
8950    
8951                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8952                                    AssetCategory.class.getName(),
8953                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8954    
8955                    Session session = null;
8956    
8957                    try {
8958                            session = openSession();
8959    
8960                            SQLQuery q = session.createSQLQuery(sql);
8961    
8962                            q.addScalar(COUNT_COLUMN_NAME,
8963                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
8964    
8965                            QueryPos qPos = QueryPos.getInstance(q);
8966    
8967                            qPos.add(groupId);
8968    
8969                            if (bindName) {
8970                                    qPos.add(name.toLowerCase());
8971                            }
8972    
8973                            qPos.add(vocabularyId);
8974    
8975                            Long count = (Long)q.uniqueResult();
8976    
8977                            return count.intValue();
8978                    }
8979                    catch (Exception e) {
8980                            throw processException(e);
8981                    }
8982                    finally {
8983                            closeSession(session);
8984                    }
8985            }
8986    
8987            /**
8988             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
8989             *
8990             * @param groupId the group ID
8991             * @param name the name
8992             * @param vocabularyIds the vocabulary IDs
8993             * @return the number of matching asset categories that the user has permission to view
8994             * @throws SystemException if a system exception occurred
8995             */
8996            @Override
8997            public int filterCountByG_LikeN_V(long groupId, String name,
8998                    long[] vocabularyIds) throws SystemException {
8999                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9000                            return countByG_LikeN_V(groupId, name, vocabularyIds);
9001                    }
9002    
9003                    StringBundler query = new StringBundler();
9004    
9005                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9006    
9007                    boolean conjunctionable = false;
9008    
9009                    if (conjunctionable) {
9010                            query.append(WHERE_AND);
9011                    }
9012    
9013                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
9014    
9015                    conjunctionable = true;
9016    
9017                    if (conjunctionable) {
9018                            query.append(WHERE_AND);
9019                    }
9020    
9021                    boolean bindName = false;
9022    
9023                    if (name == null) {
9024                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
9025                    }
9026                    else if (name.equals(StringPool.BLANK)) {
9027                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
9028                    }
9029                    else {
9030                            bindName = true;
9031    
9032                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
9033                    }
9034    
9035                    conjunctionable = true;
9036    
9037                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9038                            if (conjunctionable) {
9039                                    query.append(WHERE_AND);
9040                            }
9041    
9042                            query.append(StringPool.OPEN_PARENTHESIS);
9043    
9044                            for (int i = 0; i < vocabularyIds.length; i++) {
9045                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
9046    
9047                                    if ((i + 1) < vocabularyIds.length) {
9048                                            query.append(WHERE_OR);
9049                                    }
9050                            }
9051    
9052                            query.append(StringPool.CLOSE_PARENTHESIS);
9053    
9054                            conjunctionable = true;
9055                    }
9056    
9057                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9058                                    AssetCategory.class.getName(),
9059                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9060    
9061                    Session session = null;
9062    
9063                    try {
9064                            session = openSession();
9065    
9066                            SQLQuery q = session.createSQLQuery(sql);
9067    
9068                            q.addScalar(COUNT_COLUMN_NAME,
9069                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9070    
9071                            QueryPos qPos = QueryPos.getInstance(q);
9072    
9073                            qPos.add(groupId);
9074    
9075                            if (bindName) {
9076                                    qPos.add(name);
9077                            }
9078    
9079                            if (vocabularyIds != null) {
9080                                    qPos.add(vocabularyIds);
9081                            }
9082    
9083                            Long count = (Long)q.uniqueResult();
9084    
9085                            return count.intValue();
9086                    }
9087                    catch (Exception e) {
9088                            throw processException(e);
9089                    }
9090                    finally {
9091                            closeSession(session);
9092                    }
9093            }
9094    
9095            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
9096            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
9097                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
9098            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
9099            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "lower(assetCategory.name) LIKE ? AND ";
9100            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE '') AND ";
9101            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
9102                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
9103            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
9104                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
9105            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
9106                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
9107            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9108            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
9109                    removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
9110            public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9111                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9112                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
9113                            new String[] {
9114                                    Long.class.getName(), String.class.getName(),
9115                                    Long.class.getName()
9116                            },
9117                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9118                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9119                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9120            public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9121                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
9123                            new String[] {
9124                                    Long.class.getName(), String.class.getName(),
9125                                    Long.class.getName()
9126                            });
9127    
9128            /**
9129             * 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.
9130             *
9131             * @param parentCategoryId the parent category ID
9132             * @param name the name
9133             * @param vocabularyId the vocabulary ID
9134             * @return the matching asset category
9135             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
9136             * @throws SystemException if a system exception occurred
9137             */
9138            @Override
9139            public AssetCategory findByP_N_V(long parentCategoryId, String name,
9140                    long vocabularyId) throws NoSuchCategoryException, SystemException {
9141                    AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
9142                                    vocabularyId);
9143    
9144                    if (assetCategory == null) {
9145                            StringBundler msg = new StringBundler(8);
9146    
9147                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
9148    
9149                            msg.append("parentCategoryId=");
9150                            msg.append(parentCategoryId);
9151    
9152                            msg.append(", name=");
9153                            msg.append(name);
9154    
9155                            msg.append(", vocabularyId=");
9156                            msg.append(vocabularyId);
9157    
9158                            msg.append(StringPool.CLOSE_CURLY_BRACE);
9159    
9160                            if (_log.isWarnEnabled()) {
9161                                    _log.warn(msg.toString());
9162                            }
9163    
9164                            throw new NoSuchCategoryException(msg.toString());
9165                    }
9166    
9167                    return assetCategory;
9168            }
9169    
9170            /**
9171             * 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.
9172             *
9173             * @param parentCategoryId the parent category ID
9174             * @param name the name
9175             * @param vocabularyId the vocabulary ID
9176             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
9177             * @throws SystemException if a system exception occurred
9178             */
9179            @Override
9180            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9181                    long vocabularyId) throws SystemException {
9182                    return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
9183            }
9184    
9185            /**
9186             * 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.
9187             *
9188             * @param parentCategoryId the parent category ID
9189             * @param name the name
9190             * @param vocabularyId the vocabulary ID
9191             * @param retrieveFromCache whether to use the finder cache
9192             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
9193             * @throws SystemException if a system exception occurred
9194             */
9195            @Override
9196            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
9197                    long vocabularyId, boolean retrieveFromCache) throws SystemException {
9198                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9199    
9200                    Object result = null;
9201    
9202                    if (retrieveFromCache) {
9203                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
9204                                            finderArgs, this);
9205                    }
9206    
9207                    if (result instanceof AssetCategory) {
9208                            AssetCategory assetCategory = (AssetCategory)result;
9209    
9210                            if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
9211                                            !Validator.equals(name, assetCategory.getName()) ||
9212                                            (vocabularyId != assetCategory.getVocabularyId())) {
9213                                    result = null;
9214                            }
9215                    }
9216    
9217                    if (result == null) {
9218                            StringBundler query = new StringBundler(5);
9219    
9220                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9221    
9222                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9223    
9224                            boolean bindName = false;
9225    
9226                            if (name == null) {
9227                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9228                            }
9229                            else if (name.equals(StringPool.BLANK)) {
9230                                    query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9231                            }
9232                            else {
9233                                    bindName = true;
9234    
9235                                    query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9236                            }
9237    
9238                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9239    
9240                            String sql = query.toString();
9241    
9242                            Session session = null;
9243    
9244                            try {
9245                                    session = openSession();
9246    
9247                                    Query q = session.createQuery(sql);
9248    
9249                                    QueryPos qPos = QueryPos.getInstance(q);
9250    
9251                                    qPos.add(parentCategoryId);
9252    
9253                                    if (bindName) {
9254                                            qPos.add(name);
9255                                    }
9256    
9257                                    qPos.add(vocabularyId);
9258    
9259                                    List<AssetCategory> list = q.list();
9260    
9261                                    if (list.isEmpty()) {
9262                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9263                                                    finderArgs, list);
9264                                    }
9265                                    else {
9266                                            AssetCategory assetCategory = list.get(0);
9267    
9268                                            result = assetCategory;
9269    
9270                                            cacheResult(assetCategory);
9271    
9272                                            if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
9273                                                            (assetCategory.getName() == null) ||
9274                                                            !assetCategory.getName().equals(name) ||
9275                                                            (assetCategory.getVocabularyId() != vocabularyId)) {
9276                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
9277                                                            finderArgs, assetCategory);
9278                                            }
9279                                    }
9280                            }
9281                            catch (Exception e) {
9282                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
9283                                            finderArgs);
9284    
9285                                    throw processException(e);
9286                            }
9287                            finally {
9288                                    closeSession(session);
9289                            }
9290                    }
9291    
9292                    if (result instanceof List<?>) {
9293                            return null;
9294                    }
9295                    else {
9296                            return (AssetCategory)result;
9297                    }
9298            }
9299    
9300            /**
9301             * Removes the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
9302             *
9303             * @param parentCategoryId the parent category ID
9304             * @param name the name
9305             * @param vocabularyId the vocabulary ID
9306             * @return the asset category that was removed
9307             * @throws SystemException if a system exception occurred
9308             */
9309            @Override
9310            public AssetCategory removeByP_N_V(long parentCategoryId, String name,
9311                    long vocabularyId) throws NoSuchCategoryException, SystemException {
9312                    AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
9313                                    vocabularyId);
9314    
9315                    return remove(assetCategory);
9316            }
9317    
9318            /**
9319             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9320             *
9321             * @param parentCategoryId the parent category ID
9322             * @param name the name
9323             * @param vocabularyId the vocabulary ID
9324             * @return the number of matching asset categories
9325             * @throws SystemException if a system exception occurred
9326             */
9327            @Override
9328            public int countByP_N_V(long parentCategoryId, String name,
9329                    long vocabularyId) throws SystemException {
9330                    FinderPath finderPath = FINDER_PATH_COUNT_BY_P_N_V;
9331    
9332                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
9333    
9334                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
9335                                    this);
9336    
9337                    if (count == null) {
9338                            StringBundler query = new StringBundler(4);
9339    
9340                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9341    
9342                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
9343    
9344                            boolean bindName = false;
9345    
9346                            if (name == null) {
9347                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
9348                            }
9349                            else if (name.equals(StringPool.BLANK)) {
9350                                    query.append(_FINDER_COLUMN_P_N_V_NAME_3);
9351                            }
9352                            else {
9353                                    bindName = true;
9354    
9355                                    query.append(_FINDER_COLUMN_P_N_V_NAME_2);
9356                            }
9357    
9358                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
9359    
9360                            String sql = query.toString();
9361    
9362                            Session session = null;
9363    
9364                            try {
9365                                    session = openSession();
9366    
9367                                    Query q = session.createQuery(sql);
9368    
9369                                    QueryPos qPos = QueryPos.getInstance(q);
9370    
9371                                    qPos.add(parentCategoryId);
9372    
9373                                    if (bindName) {
9374                                            qPos.add(name);
9375                                    }
9376    
9377                                    qPos.add(vocabularyId);
9378    
9379                                    count = (Long)q.uniqueResult();
9380    
9381                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
9382                            }
9383                            catch (Exception e) {
9384                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
9385    
9386                                    throw processException(e);
9387                            }
9388                            finally {
9389                                    closeSession(session);
9390                            }
9391                    }
9392    
9393                    return count.intValue();
9394            }
9395    
9396            private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
9397            private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
9398            private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
9399            private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = '') AND ";
9400            private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
9401            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9402                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9403                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
9404                            "findByG_P_N_V",
9405                            new String[] {
9406                                    Long.class.getName(), Long.class.getName(),
9407                                    String.class.getName(), Long.class.getName(),
9408                                    
9409                            Integer.class.getName(), Integer.class.getName(),
9410                                    OrderByComparator.class.getName()
9411                            });
9412            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
9413                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9414                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
9415                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
9416                            "findByG_P_N_V",
9417                            new String[] {
9418                                    Long.class.getName(), Long.class.getName(),
9419                                    String.class.getName(), Long.class.getName()
9420                            },
9421                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
9422                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
9423                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
9424                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
9425            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
9426                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
9427                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
9428                            new String[] {
9429                                    Long.class.getName(), Long.class.getName(),
9430                                    String.class.getName(), Long.class.getName()
9431                            });
9432    
9433            /**
9434             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9435             *
9436             * @param groupId the group ID
9437             * @param parentCategoryId the parent category ID
9438             * @param name the name
9439             * @param vocabularyId the vocabulary ID
9440             * @return the matching asset categories
9441             * @throws SystemException if a system exception occurred
9442             */
9443            @Override
9444            public List<AssetCategory> findByG_P_N_V(long groupId,
9445                    long parentCategoryId, String name, long vocabularyId)
9446                    throws SystemException {
9447                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9448                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
9449            }
9450    
9451            /**
9452             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9453             *
9454             * <p>
9455             * 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.
9456             * </p>
9457             *
9458             * @param groupId the group ID
9459             * @param parentCategoryId the parent category ID
9460             * @param name the name
9461             * @param vocabularyId the vocabulary ID
9462             * @param start the lower bound of the range of asset categories
9463             * @param end the upper bound of the range of asset categories (not inclusive)
9464             * @return the range of matching asset categories
9465             * @throws SystemException if a system exception occurred
9466             */
9467            @Override
9468            public List<AssetCategory> findByG_P_N_V(long groupId,
9469                    long parentCategoryId, String name, long vocabularyId, int start,
9470                    int end) throws SystemException {
9471                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
9472                            start, end, null);
9473            }
9474    
9475            /**
9476             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
9477             *
9478             * <p>
9479             * 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.
9480             * </p>
9481             *
9482             * @param groupId the group ID
9483             * @param parentCategoryId the parent category ID
9484             * @param name the name
9485             * @param vocabularyId the vocabulary ID
9486             * @param start the lower bound of the range of asset categories
9487             * @param end the upper bound of the range of asset categories (not inclusive)
9488             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
9489             * @return the ordered range of matching asset categories
9490             * @throws SystemException if a system exception occurred
9491             */
9492            @Override
9493            public List<AssetCategory> findByG_P_N_V(long groupId,
9494                    long parentCategoryId, String name, long vocabularyId, int start,
9495                    int end, OrderByComparator orderByComparator) throws SystemException {
9496                    boolean pagination = true;
9497                    FinderPath finderPath = null;
9498                    Object[] finderArgs = null;
9499    
9500                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
9501                                    (orderByComparator == null)) {
9502                            pagination = false;
9503                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
9504                            finderArgs = new Object[] {
9505                                            groupId, parentCategoryId, name, vocabularyId
9506                                    };
9507                    }
9508                    else {
9509                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
9510                            finderArgs = new Object[] {
9511                                            groupId, parentCategoryId, name, vocabularyId,
9512                                            
9513                                            start, end, orderByComparator
9514                                    };
9515                    }
9516    
9517                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
9518                                    finderArgs, this);
9519    
9520                    if ((list != null) && !list.isEmpty()) {
9521                            for (AssetCategory assetCategory : list) {
9522                                    if ((groupId != assetCategory.getGroupId()) ||
9523                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
9524                                                    !Validator.equals(name, assetCategory.getName()) ||
9525                                                    (vocabularyId != assetCategory.getVocabularyId())) {
9526                                            list = null;
9527    
9528                                            break;
9529                                    }
9530                            }
9531                    }
9532    
9533                    if (list == null) {
9534                            StringBundler query = null;
9535    
9536                            if (orderByComparator != null) {
9537                                    query = new StringBundler(6 +
9538                                                    (orderByComparator.getOrderByFields().length * 3));
9539                            }
9540                            else {
9541                                    query = new StringBundler(6);
9542                            }
9543    
9544                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
9545    
9546                            query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
9547    
9548                            query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
9549    
9550                            boolean bindName = false;
9551    
9552                            if (name == null) {
9553                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
9554                            }
9555                            else if (name.equals(StringPool.BLANK)) {
9556                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
9557                            }
9558                            else {
9559                                    bindName = true;
9560    
9561                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
9562                            }
9563    
9564                            query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
9565    
9566                            if (orderByComparator != null) {
9567                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
9568                                            orderByComparator);
9569                            }
9570                            else
9571                             if (pagination) {
9572                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
9573                            }
9574    
9575                            String sql = query.toString();
9576    
9577                            Session session = null;
9578    
9579                            try {
9580                                    session = openSession();
9581    
9582                                    Query q = session.createQuery(sql);
9583    
9584                                    QueryPos qPos = QueryPos.getInstance(q);
9585    
9586                                    qPos.add(groupId);
9587    
9588                                    qPos.add(parentCategoryId);
9589    
9590                                    if (bindName) {
9591                                            qPos.add(name);
9592                                    }
9593    
9594                                    qPos.add(vocabularyId);
9595    
9596                                    if (!pagination) {
9597                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
9598                                                            start, end, false);
9599    
9600                                            Collections.sort(list);
9601    
9602                                            list = new UnmodifiableList<AssetCategory>(list);
9603                                    }
9604                                    else {
9605                                            list = (List<AssetCategory>)QueryUtil.list(q, get