001    /**
002     * Copyright (c) 2000-present 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.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.SQLQuery;
029    import com.liferay.portal.kernel.dao.orm.Session;
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.OrderByComparator;
035    import com.liferay.portal.kernel.util.SetUtil;
036    import com.liferay.portal.kernel.util.StringBundler;
037    import com.liferay.portal.kernel.util.StringPool;
038    import com.liferay.portal.kernel.util.StringUtil;
039    import com.liferay.portal.kernel.util.Validator;
040    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
041    import com.liferay.portal.model.CacheModel;
042    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
043    import com.liferay.portal.service.ServiceContext;
044    import com.liferay.portal.service.ServiceContextThreadLocal;
045    import com.liferay.portal.service.persistence.CompanyProvider;
046    import com.liferay.portal.service.persistence.CompanyProviderWrapper;
047    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
048    
049    import com.liferay.portlet.asset.exception.NoSuchVocabularyException;
050    import com.liferay.portlet.asset.model.AssetVocabulary;
051    import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
052    import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
053    import com.liferay.portlet.asset.service.persistence.AssetVocabularyPersistence;
054    
055    import java.io.Serializable;
056    
057    import java.util.Arrays;
058    import java.util.Collections;
059    import java.util.Date;
060    import java.util.HashMap;
061    import java.util.HashSet;
062    import java.util.Iterator;
063    import java.util.List;
064    import java.util.Map;
065    import java.util.Set;
066    
067    /**
068     * The persistence implementation for the asset vocabulary service.
069     *
070     * <p>
071     * Caching information and settings can be found in <code>portal.properties</code>
072     * </p>
073     *
074     * @author Brian Wing Shun Chan
075     * @see AssetVocabularyPersistence
076     * @see com.liferay.portlet.asset.service.persistence.AssetVocabularyUtil
077     * @generated
078     */
079    @ProviderType
080    public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
081            implements AssetVocabularyPersistence {
082            /*
083             * NOTE FOR DEVELOPERS:
084             *
085             * Never modify or reference this class directly. Always use {@link AssetVocabularyUtil} to access the asset vocabulary persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
086             */
087            public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
088            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List1";
090            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
091                    ".List2";
092            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
093                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
094                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
095                            "findAll", new String[0]);
096            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
097                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
098                            AssetVocabularyImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
100            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
101                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
102                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
103            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
104                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
105                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
106                            "findByUuid",
107                            new String[] {
108                                    String.class.getName(),
109                                    
110                            Integer.class.getName(), Integer.class.getName(),
111                                    OrderByComparator.class.getName()
112                            });
113            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
114                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
115                            AssetVocabularyImpl.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
117                            new String[] { String.class.getName() },
118                            AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
119                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
121                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
123                            new String[] { String.class.getName() });
124    
125            /**
126             * Returns all the asset vocabularies where uuid = &#63;.
127             *
128             * @param uuid the uuid
129             * @return the matching asset vocabularies
130             */
131            @Override
132            public List<AssetVocabulary> findByUuid(String uuid) {
133                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
134            }
135    
136            /**
137             * Returns a range of all the asset vocabularies where uuid = &#63;.
138             *
139             * <p>
140             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
141             * </p>
142             *
143             * @param uuid the uuid
144             * @param start the lower bound of the range of asset vocabularies
145             * @param end the upper bound of the range of asset vocabularies (not inclusive)
146             * @return the range of matching asset vocabularies
147             */
148            @Override
149            public List<AssetVocabulary> findByUuid(String uuid, int start, int end) {
150                    return findByUuid(uuid, start, end, null);
151            }
152    
153            /**
154             * Returns an ordered range of all the asset vocabularies where uuid = &#63;.
155             *
156             * <p>
157             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
158             * </p>
159             *
160             * @param uuid the uuid
161             * @param start the lower bound of the range of asset vocabularies
162             * @param end the upper bound of the range of asset vocabularies (not inclusive)
163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
164             * @return the ordered range of matching asset vocabularies
165             */
166            @Override
167            public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
168                    OrderByComparator<AssetVocabulary> orderByComparator) {
169                    return findByUuid(uuid, start, end, orderByComparator, true);
170            }
171    
172            /**
173             * Returns an ordered range of all the asset vocabularies where uuid = &#63;.
174             *
175             * <p>
176             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
177             * </p>
178             *
179             * @param uuid the uuid
180             * @param start the lower bound of the range of asset vocabularies
181             * @param end the upper bound of the range of asset vocabularies (not inclusive)
182             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
183             * @param retrieveFromCache whether to retrieve from the finder cache
184             * @return the ordered range of matching asset vocabularies
185             */
186            @Override
187            public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
188                    OrderByComparator<AssetVocabulary> orderByComparator,
189                    boolean retrieveFromCache) {
190                    boolean pagination = true;
191                    FinderPath finderPath = null;
192                    Object[] finderArgs = null;
193    
194                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
195                                    (orderByComparator == null)) {
196                            pagination = false;
197                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
198                            finderArgs = new Object[] { uuid };
199                    }
200                    else {
201                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
202                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
203                    }
204    
205                    List<AssetVocabulary> list = null;
206    
207                    if (retrieveFromCache) {
208                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
209                                            finderArgs, this);
210    
211                            if ((list != null) && !list.isEmpty()) {
212                                    for (AssetVocabulary assetVocabulary : list) {
213                                            if (!Validator.equals(uuid, assetVocabulary.getUuid())) {
214                                                    list = null;
215    
216                                                    break;
217                                            }
218                                    }
219                            }
220                    }
221    
222                    if (list == null) {
223                            StringBundler query = null;
224    
225                            if (orderByComparator != null) {
226                                    query = new StringBundler(3 +
227                                                    (orderByComparator.getOrderByFields().length * 3));
228                            }
229                            else {
230                                    query = new StringBundler(3);
231                            }
232    
233                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
234    
235                            boolean bindUuid = false;
236    
237                            if (uuid == null) {
238                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
239                            }
240                            else if (uuid.equals(StringPool.BLANK)) {
241                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
242                            }
243                            else {
244                                    bindUuid = true;
245    
246                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
247                            }
248    
249                            if (orderByComparator != null) {
250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
251                                            orderByComparator);
252                            }
253                            else
254                             if (pagination) {
255                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
256                            }
257    
258                            String sql = query.toString();
259    
260                            Session session = null;
261    
262                            try {
263                                    session = openSession();
264    
265                                    Query q = session.createQuery(sql);
266    
267                                    QueryPos qPos = QueryPos.getInstance(q);
268    
269                                    if (bindUuid) {
270                                            qPos.add(uuid);
271                                    }
272    
273                                    if (!pagination) {
274                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
275                                                            getDialect(), start, end, false);
276    
277                                            Collections.sort(list);
278    
279                                            list = Collections.unmodifiableList(list);
280                                    }
281                                    else {
282                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
283                                                            getDialect(), start, end);
284                                    }
285    
286                                    cacheResult(list);
287    
288                                    finderCache.putResult(finderPath, finderArgs, list);
289                            }
290                            catch (Exception e) {
291                                    finderCache.removeResult(finderPath, finderArgs);
292    
293                                    throw processException(e);
294                            }
295                            finally {
296                                    closeSession(session);
297                            }
298                    }
299    
300                    return list;
301            }
302    
303            /**
304             * Returns the first asset vocabulary in the ordered set where uuid = &#63;.
305             *
306             * @param uuid the uuid
307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
308             * @return the first matching asset vocabulary
309             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
310             */
311            @Override
312            public AssetVocabulary findByUuid_First(String uuid,
313                    OrderByComparator<AssetVocabulary> orderByComparator)
314                    throws NoSuchVocabularyException {
315                    AssetVocabulary assetVocabulary = fetchByUuid_First(uuid,
316                                    orderByComparator);
317    
318                    if (assetVocabulary != null) {
319                            return assetVocabulary;
320                    }
321    
322                    StringBundler msg = new StringBundler(4);
323    
324                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
325    
326                    msg.append("uuid=");
327                    msg.append(uuid);
328    
329                    msg.append(StringPool.CLOSE_CURLY_BRACE);
330    
331                    throw new NoSuchVocabularyException(msg.toString());
332            }
333    
334            /**
335             * Returns the first asset vocabulary in the ordered set where uuid = &#63;.
336             *
337             * @param uuid the uuid
338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
339             * @return the first matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
340             */
341            @Override
342            public AssetVocabulary fetchByUuid_First(String uuid,
343                    OrderByComparator<AssetVocabulary> orderByComparator) {
344                    List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
345    
346                    if (!list.isEmpty()) {
347                            return list.get(0);
348                    }
349    
350                    return null;
351            }
352    
353            /**
354             * Returns the last asset vocabulary in the ordered set where uuid = &#63;.
355             *
356             * @param uuid the uuid
357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
358             * @return the last matching asset vocabulary
359             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
360             */
361            @Override
362            public AssetVocabulary findByUuid_Last(String uuid,
363                    OrderByComparator<AssetVocabulary> orderByComparator)
364                    throws NoSuchVocabularyException {
365                    AssetVocabulary assetVocabulary = fetchByUuid_Last(uuid,
366                                    orderByComparator);
367    
368                    if (assetVocabulary != null) {
369                            return assetVocabulary;
370                    }
371    
372                    StringBundler msg = new StringBundler(4);
373    
374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
375    
376                    msg.append("uuid=");
377                    msg.append(uuid);
378    
379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
380    
381                    throw new NoSuchVocabularyException(msg.toString());
382            }
383    
384            /**
385             * Returns the last asset vocabulary in the ordered set where uuid = &#63;.
386             *
387             * @param uuid the uuid
388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
389             * @return the last matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
390             */
391            @Override
392            public AssetVocabulary fetchByUuid_Last(String uuid,
393                    OrderByComparator<AssetVocabulary> orderByComparator) {
394                    int count = countByUuid(uuid);
395    
396                    if (count == 0) {
397                            return null;
398                    }
399    
400                    List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
401                                    orderByComparator);
402    
403                    if (!list.isEmpty()) {
404                            return list.get(0);
405                    }
406    
407                    return null;
408            }
409    
410            /**
411             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where uuid = &#63;.
412             *
413             * @param vocabularyId the primary key of the current asset vocabulary
414             * @param uuid the uuid
415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
416             * @return the previous, current, and next asset vocabulary
417             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
418             */
419            @Override
420            public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
421                    String uuid, OrderByComparator<AssetVocabulary> orderByComparator)
422                    throws NoSuchVocabularyException {
423                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
424    
425                    Session session = null;
426    
427                    try {
428                            session = openSession();
429    
430                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
431    
432                            array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
433                                            orderByComparator, true);
434    
435                            array[1] = assetVocabulary;
436    
437                            array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
438                                            orderByComparator, false);
439    
440                            return array;
441                    }
442                    catch (Exception e) {
443                            throw processException(e);
444                    }
445                    finally {
446                            closeSession(session);
447                    }
448            }
449    
450            protected AssetVocabulary getByUuid_PrevAndNext(Session session,
451                    AssetVocabulary assetVocabulary, String uuid,
452                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
453                    StringBundler query = null;
454    
455                    if (orderByComparator != null) {
456                            query = new StringBundler(6 +
457                                            (orderByComparator.getOrderByFields().length * 6));
458                    }
459                    else {
460                            query = new StringBundler(3);
461                    }
462    
463                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
464    
465                    boolean bindUuid = false;
466    
467                    if (uuid == null) {
468                            query.append(_FINDER_COLUMN_UUID_UUID_1);
469                    }
470                    else if (uuid.equals(StringPool.BLANK)) {
471                            query.append(_FINDER_COLUMN_UUID_UUID_3);
472                    }
473                    else {
474                            bindUuid = true;
475    
476                            query.append(_FINDER_COLUMN_UUID_UUID_2);
477                    }
478    
479                    if (orderByComparator != null) {
480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
481    
482                            if (orderByConditionFields.length > 0) {
483                                    query.append(WHERE_AND);
484                            }
485    
486                            for (int i = 0; i < orderByConditionFields.length; i++) {
487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
488                                    query.append(orderByConditionFields[i]);
489    
490                                    if ((i + 1) < orderByConditionFields.length) {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
493                                            }
494                                            else {
495                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
496                                            }
497                                    }
498                                    else {
499                                            if (orderByComparator.isAscending() ^ previous) {
500                                                    query.append(WHERE_GREATER_THAN);
501                                            }
502                                            else {
503                                                    query.append(WHERE_LESSER_THAN);
504                                            }
505                                    }
506                            }
507    
508                            query.append(ORDER_BY_CLAUSE);
509    
510                            String[] orderByFields = orderByComparator.getOrderByFields();
511    
512                            for (int i = 0; i < orderByFields.length; i++) {
513                                    query.append(_ORDER_BY_ENTITY_ALIAS);
514                                    query.append(orderByFields[i]);
515    
516                                    if ((i + 1) < orderByFields.length) {
517                                            if (orderByComparator.isAscending() ^ previous) {
518                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
519                                            }
520                                            else {
521                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
522                                            }
523                                    }
524                                    else {
525                                            if (orderByComparator.isAscending() ^ previous) {
526                                                    query.append(ORDER_BY_ASC);
527                                            }
528                                            else {
529                                                    query.append(ORDER_BY_DESC);
530                                            }
531                                    }
532                            }
533                    }
534                    else {
535                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
536                    }
537    
538                    String sql = query.toString();
539    
540                    Query q = session.createQuery(sql);
541    
542                    q.setFirstResult(0);
543                    q.setMaxResults(2);
544    
545                    QueryPos qPos = QueryPos.getInstance(q);
546    
547                    if (bindUuid) {
548                            qPos.add(uuid);
549                    }
550    
551                    if (orderByComparator != null) {
552                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
553    
554                            for (Object value : values) {
555                                    qPos.add(value);
556                            }
557                    }
558    
559                    List<AssetVocabulary> list = q.list();
560    
561                    if (list.size() == 2) {
562                            return list.get(1);
563                    }
564                    else {
565                            return null;
566                    }
567            }
568    
569            /**
570             * Removes all the asset vocabularies where uuid = &#63; from the database.
571             *
572             * @param uuid the uuid
573             */
574            @Override
575            public void removeByUuid(String uuid) {
576                    for (AssetVocabulary assetVocabulary : findByUuid(uuid,
577                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
578                            remove(assetVocabulary);
579                    }
580            }
581    
582            /**
583             * Returns the number of asset vocabularies where uuid = &#63;.
584             *
585             * @param uuid the uuid
586             * @return the number of matching asset vocabularies
587             */
588            @Override
589            public int countByUuid(String uuid) {
590                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
591    
592                    Object[] finderArgs = new Object[] { uuid };
593    
594                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
595    
596                    if (count == null) {
597                            StringBundler query = new StringBundler(2);
598    
599                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
600    
601                            boolean bindUuid = false;
602    
603                            if (uuid == null) {
604                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
605                            }
606                            else if (uuid.equals(StringPool.BLANK)) {
607                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
608                            }
609                            else {
610                                    bindUuid = true;
611    
612                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
613                            }
614    
615                            String sql = query.toString();
616    
617                            Session session = null;
618    
619                            try {
620                                    session = openSession();
621    
622                                    Query q = session.createQuery(sql);
623    
624                                    QueryPos qPos = QueryPos.getInstance(q);
625    
626                                    if (bindUuid) {
627                                            qPos.add(uuid);
628                                    }
629    
630                                    count = (Long)q.uniqueResult();
631    
632                                    finderCache.putResult(finderPath, finderArgs, count);
633                            }
634                            catch (Exception e) {
635                                    finderCache.removeResult(finderPath, finderArgs);
636    
637                                    throw processException(e);
638                            }
639                            finally {
640                                    closeSession(session);
641                            }
642                    }
643    
644                    return count.intValue();
645            }
646    
647            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
648            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
649            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '')";
650            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
651                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
652                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
653                            "fetchByUUID_G",
654                            new String[] { String.class.getName(), Long.class.getName() },
655                            AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
656                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
657            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
658                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
659                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
660                            new String[] { String.class.getName(), Long.class.getName() });
661    
662            /**
663             * Returns the asset vocabulary where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchVocabularyException} if it could not be found.
664             *
665             * @param uuid the uuid
666             * @param groupId the group ID
667             * @return the matching asset vocabulary
668             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
669             */
670            @Override
671            public AssetVocabulary findByUUID_G(String uuid, long groupId)
672                    throws NoSuchVocabularyException {
673                    AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
674    
675                    if (assetVocabulary == null) {
676                            StringBundler msg = new StringBundler(6);
677    
678                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679    
680                            msg.append("uuid=");
681                            msg.append(uuid);
682    
683                            msg.append(", groupId=");
684                            msg.append(groupId);
685    
686                            msg.append(StringPool.CLOSE_CURLY_BRACE);
687    
688                            if (_log.isWarnEnabled()) {
689                                    _log.warn(msg.toString());
690                            }
691    
692                            throw new NoSuchVocabularyException(msg.toString());
693                    }
694    
695                    return assetVocabulary;
696            }
697    
698            /**
699             * Returns the asset vocabulary where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
700             *
701             * @param uuid the uuid
702             * @param groupId the group ID
703             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
704             */
705            @Override
706            public AssetVocabulary fetchByUUID_G(String uuid, long groupId) {
707                    return fetchByUUID_G(uuid, groupId, true);
708            }
709    
710            /**
711             * Returns the asset vocabulary where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
712             *
713             * @param uuid the uuid
714             * @param groupId the group ID
715             * @param retrieveFromCache whether to retrieve from the finder cache
716             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
717             */
718            @Override
719            public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
720                    boolean retrieveFromCache) {
721                    Object[] finderArgs = new Object[] { uuid, groupId };
722    
723                    Object result = null;
724    
725                    if (retrieveFromCache) {
726                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
727                                            finderArgs, this);
728                    }
729    
730                    if (result instanceof AssetVocabulary) {
731                            AssetVocabulary assetVocabulary = (AssetVocabulary)result;
732    
733                            if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
734                                            (groupId != assetVocabulary.getGroupId())) {
735                                    result = null;
736                            }
737                    }
738    
739                    if (result == null) {
740                            StringBundler query = new StringBundler(4);
741    
742                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
743    
744                            boolean bindUuid = false;
745    
746                            if (uuid == null) {
747                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
748                            }
749                            else if (uuid.equals(StringPool.BLANK)) {
750                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
751                            }
752                            else {
753                                    bindUuid = true;
754    
755                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
756                            }
757    
758                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
759    
760                            String sql = query.toString();
761    
762                            Session session = null;
763    
764                            try {
765                                    session = openSession();
766    
767                                    Query q = session.createQuery(sql);
768    
769                                    QueryPos qPos = QueryPos.getInstance(q);
770    
771                                    if (bindUuid) {
772                                            qPos.add(uuid);
773                                    }
774    
775                                    qPos.add(groupId);
776    
777                                    List<AssetVocabulary> list = q.list();
778    
779                                    if (list.isEmpty()) {
780                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
781                                                    finderArgs, list);
782                                    }
783                                    else {
784                                            AssetVocabulary assetVocabulary = list.get(0);
785    
786                                            result = assetVocabulary;
787    
788                                            cacheResult(assetVocabulary);
789    
790                                            if ((assetVocabulary.getUuid() == null) ||
791                                                            !assetVocabulary.getUuid().equals(uuid) ||
792                                                            (assetVocabulary.getGroupId() != groupId)) {
793                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
794                                                            finderArgs, assetVocabulary);
795                                            }
796                                    }
797                            }
798                            catch (Exception e) {
799                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
800    
801                                    throw processException(e);
802                            }
803                            finally {
804                                    closeSession(session);
805                            }
806                    }
807    
808                    if (result instanceof List<?>) {
809                            return null;
810                    }
811                    else {
812                            return (AssetVocabulary)result;
813                    }
814            }
815    
816            /**
817             * Removes the asset vocabulary where uuid = &#63; and groupId = &#63; from the database.
818             *
819             * @param uuid the uuid
820             * @param groupId the group ID
821             * @return the asset vocabulary that was removed
822             */
823            @Override
824            public AssetVocabulary removeByUUID_G(String uuid, long groupId)
825                    throws NoSuchVocabularyException {
826                    AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
827    
828                    return remove(assetVocabulary);
829            }
830    
831            /**
832             * Returns the number of asset vocabularies where uuid = &#63; and groupId = &#63;.
833             *
834             * @param uuid the uuid
835             * @param groupId the group ID
836             * @return the number of matching asset vocabularies
837             */
838            @Override
839            public int countByUUID_G(String uuid, long groupId) {
840                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
841    
842                    Object[] finderArgs = new Object[] { uuid, groupId };
843    
844                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
845    
846                    if (count == null) {
847                            StringBundler query = new StringBundler(3);
848    
849                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
850    
851                            boolean bindUuid = false;
852    
853                            if (uuid == null) {
854                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
855                            }
856                            else if (uuid.equals(StringPool.BLANK)) {
857                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
858                            }
859                            else {
860                                    bindUuid = true;
861    
862                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
863                            }
864    
865                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
866    
867                            String sql = query.toString();
868    
869                            Session session = null;
870    
871                            try {
872                                    session = openSession();
873    
874                                    Query q = session.createQuery(sql);
875    
876                                    QueryPos qPos = QueryPos.getInstance(q);
877    
878                                    if (bindUuid) {
879                                            qPos.add(uuid);
880                                    }
881    
882                                    qPos.add(groupId);
883    
884                                    count = (Long)q.uniqueResult();
885    
886                                    finderCache.putResult(finderPath, finderArgs, count);
887                            }
888                            catch (Exception e) {
889                                    finderCache.removeResult(finderPath, finderArgs);
890    
891                                    throw processException(e);
892                            }
893                            finally {
894                                    closeSession(session);
895                            }
896                    }
897    
898                    return count.intValue();
899            }
900    
901            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
902            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
903            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '') AND ";
904            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
905            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
906                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
907                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
908                            "findByUuid_C",
909                            new String[] {
910                                    String.class.getName(), Long.class.getName(),
911                                    
912                            Integer.class.getName(), Integer.class.getName(),
913                                    OrderByComparator.class.getName()
914                            });
915            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
916                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
917                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
918                            AssetVocabularyImpl.class,
919                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
920                            new String[] { String.class.getName(), Long.class.getName() },
921                            AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
922                            AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
923                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
924            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
925                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
926                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
927                            new String[] { String.class.getName(), Long.class.getName() });
928    
929            /**
930             * Returns all the asset vocabularies where uuid = &#63; and companyId = &#63;.
931             *
932             * @param uuid the uuid
933             * @param companyId the company ID
934             * @return the matching asset vocabularies
935             */
936            @Override
937            public List<AssetVocabulary> findByUuid_C(String uuid, long companyId) {
938                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
939                            QueryUtil.ALL_POS, null);
940            }
941    
942            /**
943             * Returns a range of all the asset vocabularies where uuid = &#63; and companyId = &#63;.
944             *
945             * <p>
946             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
947             * </p>
948             *
949             * @param uuid the uuid
950             * @param companyId the company ID
951             * @param start the lower bound of the range of asset vocabularies
952             * @param end the upper bound of the range of asset vocabularies (not inclusive)
953             * @return the range of matching asset vocabularies
954             */
955            @Override
956            public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
957                    int start, int end) {
958                    return findByUuid_C(uuid, companyId, start, end, null);
959            }
960    
961            /**
962             * Returns an ordered range of all the asset vocabularies where uuid = &#63; and companyId = &#63;.
963             *
964             * <p>
965             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
966             * </p>
967             *
968             * @param uuid the uuid
969             * @param companyId the company ID
970             * @param start the lower bound of the range of asset vocabularies
971             * @param end the upper bound of the range of asset vocabularies (not inclusive)
972             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
973             * @return the ordered range of matching asset vocabularies
974             */
975            @Override
976            public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
977                    int start, int end, OrderByComparator<AssetVocabulary> orderByComparator) {
978                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
979            }
980    
981            /**
982             * Returns an ordered range of all the asset vocabularies where uuid = &#63; and companyId = &#63;.
983             *
984             * <p>
985             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
986             * </p>
987             *
988             * @param uuid the uuid
989             * @param companyId the company ID
990             * @param start the lower bound of the range of asset vocabularies
991             * @param end the upper bound of the range of asset vocabularies (not inclusive)
992             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
993             * @param retrieveFromCache whether to retrieve from the finder cache
994             * @return the ordered range of matching asset vocabularies
995             */
996            @Override
997            public List<AssetVocabulary> findByUuid_C(String uuid, long companyId,
998                    int start, int end,
999                    OrderByComparator<AssetVocabulary> orderByComparator,
1000                    boolean retrieveFromCache) {
1001                    boolean pagination = true;
1002                    FinderPath finderPath = null;
1003                    Object[] finderArgs = null;
1004    
1005                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1006                                    (orderByComparator == null)) {
1007                            pagination = false;
1008                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1009                            finderArgs = new Object[] { uuid, companyId };
1010                    }
1011                    else {
1012                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1013                            finderArgs = new Object[] {
1014                                            uuid, companyId,
1015                                            
1016                                            start, end, orderByComparator
1017                                    };
1018                    }
1019    
1020                    List<AssetVocabulary> list = null;
1021    
1022                    if (retrieveFromCache) {
1023                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
1024                                            finderArgs, this);
1025    
1026                            if ((list != null) && !list.isEmpty()) {
1027                                    for (AssetVocabulary assetVocabulary : list) {
1028                                            if (!Validator.equals(uuid, assetVocabulary.getUuid()) ||
1029                                                            (companyId != assetVocabulary.getCompanyId())) {
1030                                                    list = null;
1031    
1032                                                    break;
1033                                            }
1034                                    }
1035                            }
1036                    }
1037    
1038                    if (list == null) {
1039                            StringBundler query = null;
1040    
1041                            if (orderByComparator != null) {
1042                                    query = new StringBundler(4 +
1043                                                    (orderByComparator.getOrderByFields().length * 3));
1044                            }
1045                            else {
1046                                    query = new StringBundler(4);
1047                            }
1048    
1049                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1050    
1051                            boolean bindUuid = false;
1052    
1053                            if (uuid == null) {
1054                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1055                            }
1056                            else if (uuid.equals(StringPool.BLANK)) {
1057                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1058                            }
1059                            else {
1060                                    bindUuid = true;
1061    
1062                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1063                            }
1064    
1065                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1066    
1067                            if (orderByComparator != null) {
1068                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1069                                            orderByComparator);
1070                            }
1071                            else
1072                             if (pagination) {
1073                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1074                            }
1075    
1076                            String sql = query.toString();
1077    
1078                            Session session = null;
1079    
1080                            try {
1081                                    session = openSession();
1082    
1083                                    Query q = session.createQuery(sql);
1084    
1085                                    QueryPos qPos = QueryPos.getInstance(q);
1086    
1087                                    if (bindUuid) {
1088                                            qPos.add(uuid);
1089                                    }
1090    
1091                                    qPos.add(companyId);
1092    
1093                                    if (!pagination) {
1094                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
1095                                                            getDialect(), start, end, false);
1096    
1097                                            Collections.sort(list);
1098    
1099                                            list = Collections.unmodifiableList(list);
1100                                    }
1101                                    else {
1102                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
1103                                                            getDialect(), start, end);
1104                                    }
1105    
1106                                    cacheResult(list);
1107    
1108                                    finderCache.putResult(finderPath, finderArgs, list);
1109                            }
1110                            catch (Exception e) {
1111                                    finderCache.removeResult(finderPath, finderArgs);
1112    
1113                                    throw processException(e);
1114                            }
1115                            finally {
1116                                    closeSession(session);
1117                            }
1118                    }
1119    
1120                    return list;
1121            }
1122    
1123            /**
1124             * Returns the first asset vocabulary in the ordered set where uuid = &#63; and companyId = &#63;.
1125             *
1126             * @param uuid the uuid
1127             * @param companyId the company ID
1128             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1129             * @return the first matching asset vocabulary
1130             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
1131             */
1132            @Override
1133            public AssetVocabulary findByUuid_C_First(String uuid, long companyId,
1134                    OrderByComparator<AssetVocabulary> orderByComparator)
1135                    throws NoSuchVocabularyException {
1136                    AssetVocabulary assetVocabulary = fetchByUuid_C_First(uuid, companyId,
1137                                    orderByComparator);
1138    
1139                    if (assetVocabulary != null) {
1140                            return assetVocabulary;
1141                    }
1142    
1143                    StringBundler msg = new StringBundler(6);
1144    
1145                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1146    
1147                    msg.append("uuid=");
1148                    msg.append(uuid);
1149    
1150                    msg.append(", companyId=");
1151                    msg.append(companyId);
1152    
1153                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1154    
1155                    throw new NoSuchVocabularyException(msg.toString());
1156            }
1157    
1158            /**
1159             * Returns the first asset vocabulary in the ordered set where uuid = &#63; and companyId = &#63;.
1160             *
1161             * @param uuid the uuid
1162             * @param companyId the company ID
1163             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1164             * @return the first matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1165             */
1166            @Override
1167            public AssetVocabulary fetchByUuid_C_First(String uuid, long companyId,
1168                    OrderByComparator<AssetVocabulary> orderByComparator) {
1169                    List<AssetVocabulary> list = findByUuid_C(uuid, companyId, 0, 1,
1170                                    orderByComparator);
1171    
1172                    if (!list.isEmpty()) {
1173                            return list.get(0);
1174                    }
1175    
1176                    return null;
1177            }
1178    
1179            /**
1180             * Returns the last asset vocabulary in the ordered set where uuid = &#63; and companyId = &#63;.
1181             *
1182             * @param uuid the uuid
1183             * @param companyId the company ID
1184             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1185             * @return the last matching asset vocabulary
1186             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
1187             */
1188            @Override
1189            public AssetVocabulary findByUuid_C_Last(String uuid, long companyId,
1190                    OrderByComparator<AssetVocabulary> orderByComparator)
1191                    throws NoSuchVocabularyException {
1192                    AssetVocabulary assetVocabulary = fetchByUuid_C_Last(uuid, companyId,
1193                                    orderByComparator);
1194    
1195                    if (assetVocabulary != null) {
1196                            return assetVocabulary;
1197                    }
1198    
1199                    StringBundler msg = new StringBundler(6);
1200    
1201                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1202    
1203                    msg.append("uuid=");
1204                    msg.append(uuid);
1205    
1206                    msg.append(", companyId=");
1207                    msg.append(companyId);
1208    
1209                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1210    
1211                    throw new NoSuchVocabularyException(msg.toString());
1212            }
1213    
1214            /**
1215             * Returns the last asset vocabulary in the ordered set where uuid = &#63; and companyId = &#63;.
1216             *
1217             * @param uuid the uuid
1218             * @param companyId the company ID
1219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1220             * @return the last matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1221             */
1222            @Override
1223            public AssetVocabulary fetchByUuid_C_Last(String uuid, long companyId,
1224                    OrderByComparator<AssetVocabulary> orderByComparator) {
1225                    int count = countByUuid_C(uuid, companyId);
1226    
1227                    if (count == 0) {
1228                            return null;
1229                    }
1230    
1231                    List<AssetVocabulary> list = findByUuid_C(uuid, companyId, count - 1,
1232                                    count, orderByComparator);
1233    
1234                    if (!list.isEmpty()) {
1235                            return list.get(0);
1236                    }
1237    
1238                    return null;
1239            }
1240    
1241            /**
1242             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where uuid = &#63; and companyId = &#63;.
1243             *
1244             * @param vocabularyId the primary key of the current asset vocabulary
1245             * @param uuid the uuid
1246             * @param companyId the company ID
1247             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1248             * @return the previous, current, and next asset vocabulary
1249             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
1250             */
1251            @Override
1252            public AssetVocabulary[] findByUuid_C_PrevAndNext(long vocabularyId,
1253                    String uuid, long companyId,
1254                    OrderByComparator<AssetVocabulary> orderByComparator)
1255                    throws NoSuchVocabularyException {
1256                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1257    
1258                    Session session = null;
1259    
1260                    try {
1261                            session = openSession();
1262    
1263                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
1264    
1265                            array[0] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1266                                            companyId, orderByComparator, true);
1267    
1268                            array[1] = assetVocabulary;
1269    
1270                            array[2] = getByUuid_C_PrevAndNext(session, assetVocabulary, uuid,
1271                                            companyId, orderByComparator, false);
1272    
1273                            return array;
1274                    }
1275                    catch (Exception e) {
1276                            throw processException(e);
1277                    }
1278                    finally {
1279                            closeSession(session);
1280                    }
1281            }
1282    
1283            protected AssetVocabulary getByUuid_C_PrevAndNext(Session session,
1284                    AssetVocabulary assetVocabulary, String uuid, long companyId,
1285                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
1286                    StringBundler query = null;
1287    
1288                    if (orderByComparator != null) {
1289                            query = new StringBundler(6 +
1290                                            (orderByComparator.getOrderByFields().length * 6));
1291                    }
1292                    else {
1293                            query = new StringBundler(3);
1294                    }
1295    
1296                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1297    
1298                    boolean bindUuid = false;
1299    
1300                    if (uuid == null) {
1301                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1302                    }
1303                    else if (uuid.equals(StringPool.BLANK)) {
1304                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1305                    }
1306                    else {
1307                            bindUuid = true;
1308    
1309                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1310                    }
1311    
1312                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1313    
1314                    if (orderByComparator != null) {
1315                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1316    
1317                            if (orderByConditionFields.length > 0) {
1318                                    query.append(WHERE_AND);
1319                            }
1320    
1321                            for (int i = 0; i < orderByConditionFields.length; i++) {
1322                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1323                                    query.append(orderByConditionFields[i]);
1324    
1325                                    if ((i + 1) < orderByConditionFields.length) {
1326                                            if (orderByComparator.isAscending() ^ previous) {
1327                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1328                                            }
1329                                            else {
1330                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1331                                            }
1332                                    }
1333                                    else {
1334                                            if (orderByComparator.isAscending() ^ previous) {
1335                                                    query.append(WHERE_GREATER_THAN);
1336                                            }
1337                                            else {
1338                                                    query.append(WHERE_LESSER_THAN);
1339                                            }
1340                                    }
1341                            }
1342    
1343                            query.append(ORDER_BY_CLAUSE);
1344    
1345                            String[] orderByFields = orderByComparator.getOrderByFields();
1346    
1347                            for (int i = 0; i < orderByFields.length; i++) {
1348                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1349                                    query.append(orderByFields[i]);
1350    
1351                                    if ((i + 1) < orderByFields.length) {
1352                                            if (orderByComparator.isAscending() ^ previous) {
1353                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1354                                            }
1355                                            else {
1356                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1357                                            }
1358                                    }
1359                                    else {
1360                                            if (orderByComparator.isAscending() ^ previous) {
1361                                                    query.append(ORDER_BY_ASC);
1362                                            }
1363                                            else {
1364                                                    query.append(ORDER_BY_DESC);
1365                                            }
1366                                    }
1367                            }
1368                    }
1369                    else {
1370                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1371                    }
1372    
1373                    String sql = query.toString();
1374    
1375                    Query q = session.createQuery(sql);
1376    
1377                    q.setFirstResult(0);
1378                    q.setMaxResults(2);
1379    
1380                    QueryPos qPos = QueryPos.getInstance(q);
1381    
1382                    if (bindUuid) {
1383                            qPos.add(uuid);
1384                    }
1385    
1386                    qPos.add(companyId);
1387    
1388                    if (orderByComparator != null) {
1389                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1390    
1391                            for (Object value : values) {
1392                                    qPos.add(value);
1393                            }
1394                    }
1395    
1396                    List<AssetVocabulary> list = q.list();
1397    
1398                    if (list.size() == 2) {
1399                            return list.get(1);
1400                    }
1401                    else {
1402                            return null;
1403                    }
1404            }
1405    
1406            /**
1407             * Removes all the asset vocabularies where uuid = &#63; and companyId = &#63; from the database.
1408             *
1409             * @param uuid the uuid
1410             * @param companyId the company ID
1411             */
1412            @Override
1413            public void removeByUuid_C(String uuid, long companyId) {
1414                    for (AssetVocabulary assetVocabulary : findByUuid_C(uuid, companyId,
1415                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1416                            remove(assetVocabulary);
1417                    }
1418            }
1419    
1420            /**
1421             * Returns the number of asset vocabularies where uuid = &#63; and companyId = &#63;.
1422             *
1423             * @param uuid the uuid
1424             * @param companyId the company ID
1425             * @return the number of matching asset vocabularies
1426             */
1427            @Override
1428            public int countByUuid_C(String uuid, long companyId) {
1429                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1430    
1431                    Object[] finderArgs = new Object[] { uuid, companyId };
1432    
1433                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1434    
1435                    if (count == null) {
1436                            StringBundler query = new StringBundler(3);
1437    
1438                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
1439    
1440                            boolean bindUuid = false;
1441    
1442                            if (uuid == null) {
1443                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1444                            }
1445                            else if (uuid.equals(StringPool.BLANK)) {
1446                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1447                            }
1448                            else {
1449                                    bindUuid = true;
1450    
1451                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1452                            }
1453    
1454                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1455    
1456                            String sql = query.toString();
1457    
1458                            Session session = null;
1459    
1460                            try {
1461                                    session = openSession();
1462    
1463                                    Query q = session.createQuery(sql);
1464    
1465                                    QueryPos qPos = QueryPos.getInstance(q);
1466    
1467                                    if (bindUuid) {
1468                                            qPos.add(uuid);
1469                                    }
1470    
1471                                    qPos.add(companyId);
1472    
1473                                    count = (Long)q.uniqueResult();
1474    
1475                                    finderCache.putResult(finderPath, finderArgs, count);
1476                            }
1477                            catch (Exception e) {
1478                                    finderCache.removeResult(finderPath, finderArgs);
1479    
1480                                    throw processException(e);
1481                            }
1482                            finally {
1483                                    closeSession(session);
1484                            }
1485                    }
1486    
1487                    return count.intValue();
1488            }
1489    
1490            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
1491            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "assetVocabulary.uuid = ? AND ";
1492            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = '') AND ";
1493            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "assetVocabulary.companyId = ?";
1494            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1495                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1496                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1497                            "findByGroupId",
1498                            new String[] {
1499                                    Long.class.getName(),
1500                                    
1501                            Integer.class.getName(), Integer.class.getName(),
1502                                    OrderByComparator.class.getName()
1503                            });
1504            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1505                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1506                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
1507                            AssetVocabularyImpl.class,
1508                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1509                            new String[] { Long.class.getName() },
1510                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
1511                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
1512            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1513                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1514                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1515                            new String[] { Long.class.getName() });
1516            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
1517                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
1518                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
1519                            new String[] { Long.class.getName() });
1520    
1521            /**
1522             * Returns all the asset vocabularies where groupId = &#63;.
1523             *
1524             * @param groupId the group ID
1525             * @return the matching asset vocabularies
1526             */
1527            @Override
1528            public List<AssetVocabulary> findByGroupId(long groupId) {
1529                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1530            }
1531    
1532            /**
1533             * Returns a range of all the asset vocabularies where groupId = &#63;.
1534             *
1535             * <p>
1536             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
1537             * </p>
1538             *
1539             * @param groupId the group ID
1540             * @param start the lower bound of the range of asset vocabularies
1541             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1542             * @return the range of matching asset vocabularies
1543             */
1544            @Override
1545            public List<AssetVocabulary> findByGroupId(long groupId, int start, int end) {
1546                    return findByGroupId(groupId, start, end, null);
1547            }
1548    
1549            /**
1550             * Returns an ordered range of all the asset vocabularies where groupId = &#63;.
1551             *
1552             * <p>
1553             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
1554             * </p>
1555             *
1556             * @param groupId the group ID
1557             * @param start the lower bound of the range of asset vocabularies
1558             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1559             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1560             * @return the ordered range of matching asset vocabularies
1561             */
1562            @Override
1563            public List<AssetVocabulary> findByGroupId(long groupId, int start,
1564                    int end, OrderByComparator<AssetVocabulary> orderByComparator) {
1565                    return findByGroupId(groupId, start, end, orderByComparator, true);
1566            }
1567    
1568            /**
1569             * Returns an ordered range of all the asset vocabularies where groupId = &#63;.
1570             *
1571             * <p>
1572             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
1573             * </p>
1574             *
1575             * @param groupId the group ID
1576             * @param start the lower bound of the range of asset vocabularies
1577             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1578             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1579             * @param retrieveFromCache whether to retrieve from the finder cache
1580             * @return the ordered range of matching asset vocabularies
1581             */
1582            @Override
1583            public List<AssetVocabulary> findByGroupId(long groupId, int start,
1584                    int end, OrderByComparator<AssetVocabulary> orderByComparator,
1585                    boolean retrieveFromCache) {
1586                    boolean pagination = true;
1587                    FinderPath finderPath = null;
1588                    Object[] finderArgs = null;
1589    
1590                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1591                                    (orderByComparator == null)) {
1592                            pagination = false;
1593                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1594                            finderArgs = new Object[] { groupId };
1595                    }
1596                    else {
1597                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1598                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1599                    }
1600    
1601                    List<AssetVocabulary> list = null;
1602    
1603                    if (retrieveFromCache) {
1604                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
1605                                            finderArgs, this);
1606    
1607                            if ((list != null) && !list.isEmpty()) {
1608                                    for (AssetVocabulary assetVocabulary : list) {
1609                                            if ((groupId != assetVocabulary.getGroupId())) {
1610                                                    list = null;
1611    
1612                                                    break;
1613                                            }
1614                                    }
1615                            }
1616                    }
1617    
1618                    if (list == null) {
1619                            StringBundler query = null;
1620    
1621                            if (orderByComparator != null) {
1622                                    query = new StringBundler(3 +
1623                                                    (orderByComparator.getOrderByFields().length * 3));
1624                            }
1625                            else {
1626                                    query = new StringBundler(3);
1627                            }
1628    
1629                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1630    
1631                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1632    
1633                            if (orderByComparator != null) {
1634                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1635                                            orderByComparator);
1636                            }
1637                            else
1638                             if (pagination) {
1639                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1640                            }
1641    
1642                            String sql = query.toString();
1643    
1644                            Session session = null;
1645    
1646                            try {
1647                                    session = openSession();
1648    
1649                                    Query q = session.createQuery(sql);
1650    
1651                                    QueryPos qPos = QueryPos.getInstance(q);
1652    
1653                                    qPos.add(groupId);
1654    
1655                                    if (!pagination) {
1656                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
1657                                                            getDialect(), start, end, false);
1658    
1659                                            Collections.sort(list);
1660    
1661                                            list = Collections.unmodifiableList(list);
1662                                    }
1663                                    else {
1664                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
1665                                                            getDialect(), start, end);
1666                                    }
1667    
1668                                    cacheResult(list);
1669    
1670                                    finderCache.putResult(finderPath, finderArgs, list);
1671                            }
1672                            catch (Exception e) {
1673                                    finderCache.removeResult(finderPath, finderArgs);
1674    
1675                                    throw processException(e);
1676                            }
1677                            finally {
1678                                    closeSession(session);
1679                            }
1680                    }
1681    
1682                    return list;
1683            }
1684    
1685            /**
1686             * Returns the first asset vocabulary in the ordered set where groupId = &#63;.
1687             *
1688             * @param groupId the group ID
1689             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1690             * @return the first matching asset vocabulary
1691             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
1692             */
1693            @Override
1694            public AssetVocabulary findByGroupId_First(long groupId,
1695                    OrderByComparator<AssetVocabulary> orderByComparator)
1696                    throws NoSuchVocabularyException {
1697                    AssetVocabulary assetVocabulary = fetchByGroupId_First(groupId,
1698                                    orderByComparator);
1699    
1700                    if (assetVocabulary != null) {
1701                            return assetVocabulary;
1702                    }
1703    
1704                    StringBundler msg = new StringBundler(4);
1705    
1706                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1707    
1708                    msg.append("groupId=");
1709                    msg.append(groupId);
1710    
1711                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1712    
1713                    throw new NoSuchVocabularyException(msg.toString());
1714            }
1715    
1716            /**
1717             * Returns the first asset vocabulary in the ordered set where groupId = &#63;.
1718             *
1719             * @param groupId the group ID
1720             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1721             * @return the first matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1722             */
1723            @Override
1724            public AssetVocabulary fetchByGroupId_First(long groupId,
1725                    OrderByComparator<AssetVocabulary> orderByComparator) {
1726                    List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1727                                    orderByComparator);
1728    
1729                    if (!list.isEmpty()) {
1730                            return list.get(0);
1731                    }
1732    
1733                    return null;
1734            }
1735    
1736            /**
1737             * Returns the last asset vocabulary in the ordered set where groupId = &#63;.
1738             *
1739             * @param groupId the group ID
1740             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1741             * @return the last matching asset vocabulary
1742             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
1743             */
1744            @Override
1745            public AssetVocabulary findByGroupId_Last(long groupId,
1746                    OrderByComparator<AssetVocabulary> orderByComparator)
1747                    throws NoSuchVocabularyException {
1748                    AssetVocabulary assetVocabulary = fetchByGroupId_Last(groupId,
1749                                    orderByComparator);
1750    
1751                    if (assetVocabulary != null) {
1752                            return assetVocabulary;
1753                    }
1754    
1755                    StringBundler msg = new StringBundler(4);
1756    
1757                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1758    
1759                    msg.append("groupId=");
1760                    msg.append(groupId);
1761    
1762                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1763    
1764                    throw new NoSuchVocabularyException(msg.toString());
1765            }
1766    
1767            /**
1768             * Returns the last asset vocabulary in the ordered set where groupId = &#63;.
1769             *
1770             * @param groupId the group ID
1771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1772             * @return the last matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1773             */
1774            @Override
1775            public AssetVocabulary fetchByGroupId_Last(long groupId,
1776                    OrderByComparator<AssetVocabulary> orderByComparator) {
1777                    int count = countByGroupId(groupId);
1778    
1779                    if (count == 0) {
1780                            return null;
1781                    }
1782    
1783                    List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1784                                    orderByComparator);
1785    
1786                    if (!list.isEmpty()) {
1787                            return list.get(0);
1788                    }
1789    
1790                    return null;
1791            }
1792    
1793            /**
1794             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where groupId = &#63;.
1795             *
1796             * @param vocabularyId the primary key of the current asset vocabulary
1797             * @param groupId the group ID
1798             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1799             * @return the previous, current, and next asset vocabulary
1800             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
1801             */
1802            @Override
1803            public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1804                    long groupId, OrderByComparator<AssetVocabulary> orderByComparator)
1805                    throws NoSuchVocabularyException {
1806                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1807    
1808                    Session session = null;
1809    
1810                    try {
1811                            session = openSession();
1812    
1813                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
1814    
1815                            array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1816                                            groupId, orderByComparator, true);
1817    
1818                            array[1] = assetVocabulary;
1819    
1820                            array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1821                                            groupId, orderByComparator, false);
1822    
1823                            return array;
1824                    }
1825                    catch (Exception e) {
1826                            throw processException(e);
1827                    }
1828                    finally {
1829                            closeSession(session);
1830                    }
1831            }
1832    
1833            protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1834                    AssetVocabulary assetVocabulary, long groupId,
1835                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
1836                    StringBundler query = null;
1837    
1838                    if (orderByComparator != null) {
1839                            query = new StringBundler(6 +
1840                                            (orderByComparator.getOrderByFields().length * 6));
1841                    }
1842                    else {
1843                            query = new StringBundler(3);
1844                    }
1845    
1846                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1847    
1848                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1849    
1850                    if (orderByComparator != null) {
1851                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1852    
1853                            if (orderByConditionFields.length > 0) {
1854                                    query.append(WHERE_AND);
1855                            }
1856    
1857                            for (int i = 0; i < orderByConditionFields.length; i++) {
1858                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1859                                    query.append(orderByConditionFields[i]);
1860    
1861                                    if ((i + 1) < orderByConditionFields.length) {
1862                                            if (orderByComparator.isAscending() ^ previous) {
1863                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1864                                            }
1865                                            else {
1866                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1867                                            }
1868                                    }
1869                                    else {
1870                                            if (orderByComparator.isAscending() ^ previous) {
1871                                                    query.append(WHERE_GREATER_THAN);
1872                                            }
1873                                            else {
1874                                                    query.append(WHERE_LESSER_THAN);
1875                                            }
1876                                    }
1877                            }
1878    
1879                            query.append(ORDER_BY_CLAUSE);
1880    
1881                            String[] orderByFields = orderByComparator.getOrderByFields();
1882    
1883                            for (int i = 0; i < orderByFields.length; i++) {
1884                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1885                                    query.append(orderByFields[i]);
1886    
1887                                    if ((i + 1) < orderByFields.length) {
1888                                            if (orderByComparator.isAscending() ^ previous) {
1889                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1890                                            }
1891                                            else {
1892                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1893                                            }
1894                                    }
1895                                    else {
1896                                            if (orderByComparator.isAscending() ^ previous) {
1897                                                    query.append(ORDER_BY_ASC);
1898                                            }
1899                                            else {
1900                                                    query.append(ORDER_BY_DESC);
1901                                            }
1902                                    }
1903                            }
1904                    }
1905                    else {
1906                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1907                    }
1908    
1909                    String sql = query.toString();
1910    
1911                    Query q = session.createQuery(sql);
1912    
1913                    q.setFirstResult(0);
1914                    q.setMaxResults(2);
1915    
1916                    QueryPos qPos = QueryPos.getInstance(q);
1917    
1918                    qPos.add(groupId);
1919    
1920                    if (orderByComparator != null) {
1921                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1922    
1923                            for (Object value : values) {
1924                                    qPos.add(value);
1925                            }
1926                    }
1927    
1928                    List<AssetVocabulary> list = q.list();
1929    
1930                    if (list.size() == 2) {
1931                            return list.get(1);
1932                    }
1933                    else {
1934                            return null;
1935                    }
1936            }
1937    
1938            /**
1939             * Returns all the asset vocabularies that the user has permission to view where groupId = &#63;.
1940             *
1941             * @param groupId the group ID
1942             * @return the matching asset vocabularies that the user has permission to view
1943             */
1944            @Override
1945            public List<AssetVocabulary> filterFindByGroupId(long groupId) {
1946                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1947                            QueryUtil.ALL_POS, null);
1948            }
1949    
1950            /**
1951             * Returns a range of all the asset vocabularies that the user has permission to view where groupId = &#63;.
1952             *
1953             * <p>
1954             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
1955             * </p>
1956             *
1957             * @param groupId the group ID
1958             * @param start the lower bound of the range of asset vocabularies
1959             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1960             * @return the range of matching asset vocabularies that the user has permission to view
1961             */
1962            @Override
1963            public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1964                    int end) {
1965                    return filterFindByGroupId(groupId, start, end, null);
1966            }
1967    
1968            /**
1969             * Returns an ordered range of all the asset vocabularies that the user has permissions to view where groupId = &#63;.
1970             *
1971             * <p>
1972             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
1973             * </p>
1974             *
1975             * @param groupId the group ID
1976             * @param start the lower bound of the range of asset vocabularies
1977             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1978             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1979             * @return the ordered range of matching asset vocabularies that the user has permission to view
1980             */
1981            @Override
1982            public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1983                    int end, OrderByComparator<AssetVocabulary> orderByComparator) {
1984                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1985                            return findByGroupId(groupId, start, end, orderByComparator);
1986                    }
1987    
1988                    StringBundler query = null;
1989    
1990                    if (orderByComparator != null) {
1991                            query = new StringBundler(3 +
1992                                            (orderByComparator.getOrderByFields().length * 3));
1993                    }
1994                    else {
1995                            query = new StringBundler(3);
1996                    }
1997    
1998                    if (getDB().isSupportsInlineDistinct()) {
1999                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2000                    }
2001                    else {
2002                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2003                    }
2004    
2005                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2006    
2007                    if (!getDB().isSupportsInlineDistinct()) {
2008                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2009                    }
2010    
2011                    if (orderByComparator != null) {
2012                            if (getDB().isSupportsInlineDistinct()) {
2013                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2014                                            orderByComparator, true);
2015                            }
2016                            else {
2017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2018                                            orderByComparator, true);
2019                            }
2020                    }
2021                    else {
2022                            if (getDB().isSupportsInlineDistinct()) {
2023                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2024                            }
2025                            else {
2026                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2027                            }
2028                    }
2029    
2030                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2031                                    AssetVocabulary.class.getName(),
2032                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2033    
2034                    Session session = null;
2035    
2036                    try {
2037                            session = openSession();
2038    
2039                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2040    
2041                            if (getDB().isSupportsInlineDistinct()) {
2042                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2043                            }
2044                            else {
2045                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2046                            }
2047    
2048                            QueryPos qPos = QueryPos.getInstance(q);
2049    
2050                            qPos.add(groupId);
2051    
2052                            return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2053                                    start, end);
2054                    }
2055                    catch (Exception e) {
2056                            throw processException(e);
2057                    }
2058                    finally {
2059                            closeSession(session);
2060                    }
2061            }
2062    
2063            /**
2064             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set of asset vocabularies that the user has permission to view where groupId = &#63;.
2065             *
2066             * @param vocabularyId the primary key of the current asset vocabulary
2067             * @param groupId the group ID
2068             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2069             * @return the previous, current, and next asset vocabulary
2070             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
2071             */
2072            @Override
2073            public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
2074                    long vocabularyId, long groupId,
2075                    OrderByComparator<AssetVocabulary> orderByComparator)
2076                    throws NoSuchVocabularyException {
2077                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2078                            return findByGroupId_PrevAndNext(vocabularyId, groupId,
2079                                    orderByComparator);
2080                    }
2081    
2082                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2083    
2084                    Session session = null;
2085    
2086                    try {
2087                            session = openSession();
2088    
2089                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
2090    
2091                            array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
2092                                            groupId, orderByComparator, true);
2093    
2094                            array[1] = assetVocabulary;
2095    
2096                            array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
2097                                            groupId, orderByComparator, false);
2098    
2099                            return array;
2100                    }
2101                    catch (Exception e) {
2102                            throw processException(e);
2103                    }
2104                    finally {
2105                            closeSession(session);
2106                    }
2107            }
2108    
2109            protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
2110                    AssetVocabulary assetVocabulary, long groupId,
2111                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
2112                    StringBundler query = null;
2113    
2114                    if (orderByComparator != null) {
2115                            query = new StringBundler(6 +
2116                                            (orderByComparator.getOrderByFields().length * 6));
2117                    }
2118                    else {
2119                            query = new StringBundler(3);
2120                    }
2121    
2122                    if (getDB().isSupportsInlineDistinct()) {
2123                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2124                    }
2125                    else {
2126                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2127                    }
2128    
2129                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2130    
2131                    if (!getDB().isSupportsInlineDistinct()) {
2132                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2133                    }
2134    
2135                    if (orderByComparator != null) {
2136                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2137    
2138                            if (orderByConditionFields.length > 0) {
2139                                    query.append(WHERE_AND);
2140                            }
2141    
2142                            for (int i = 0; i < orderByConditionFields.length; i++) {
2143                                    if (getDB().isSupportsInlineDistinct()) {
2144                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2145                                    }
2146                                    else {
2147                                            query.append(_ORDER_BY_ENTITY_TABLE);
2148                                    }
2149    
2150                                    query.append(orderByConditionFields[i]);
2151    
2152                                    if ((i + 1) < orderByConditionFields.length) {
2153                                            if (orderByComparator.isAscending() ^ previous) {
2154                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2155                                            }
2156                                            else {
2157                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2158                                            }
2159                                    }
2160                                    else {
2161                                            if (orderByComparator.isAscending() ^ previous) {
2162                                                    query.append(WHERE_GREATER_THAN);
2163                                            }
2164                                            else {
2165                                                    query.append(WHERE_LESSER_THAN);
2166                                            }
2167                                    }
2168                            }
2169    
2170                            query.append(ORDER_BY_CLAUSE);
2171    
2172                            String[] orderByFields = orderByComparator.getOrderByFields();
2173    
2174                            for (int i = 0; i < orderByFields.length; i++) {
2175                                    if (getDB().isSupportsInlineDistinct()) {
2176                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2177                                    }
2178                                    else {
2179                                            query.append(_ORDER_BY_ENTITY_TABLE);
2180                                    }
2181    
2182                                    query.append(orderByFields[i]);
2183    
2184                                    if ((i + 1) < orderByFields.length) {
2185                                            if (orderByComparator.isAscending() ^ previous) {
2186                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2187                                            }
2188                                            else {
2189                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2190                                            }
2191                                    }
2192                                    else {
2193                                            if (orderByComparator.isAscending() ^ previous) {
2194                                                    query.append(ORDER_BY_ASC);
2195                                            }
2196                                            else {
2197                                                    query.append(ORDER_BY_DESC);
2198                                            }
2199                                    }
2200                            }
2201                    }
2202                    else {
2203                            if (getDB().isSupportsInlineDistinct()) {
2204                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2205                            }
2206                            else {
2207                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2208                            }
2209                    }
2210    
2211                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2212                                    AssetVocabulary.class.getName(),
2213                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2214    
2215                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2216    
2217                    q.setFirstResult(0);
2218                    q.setMaxResults(2);
2219    
2220                    if (getDB().isSupportsInlineDistinct()) {
2221                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2222                    }
2223                    else {
2224                            q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2225                    }
2226    
2227                    QueryPos qPos = QueryPos.getInstance(q);
2228    
2229                    qPos.add(groupId);
2230    
2231                    if (orderByComparator != null) {
2232                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2233    
2234                            for (Object value : values) {
2235                                    qPos.add(value);
2236                            }
2237                    }
2238    
2239                    List<AssetVocabulary> list = q.list();
2240    
2241                    if (list.size() == 2) {
2242                            return list.get(1);
2243                    }
2244                    else {
2245                            return null;
2246                    }
2247            }
2248    
2249            /**
2250             * Returns all the asset vocabularies that the user has permission to view where groupId = any &#63;.
2251             *
2252             * @param groupIds the group IDs
2253             * @return the matching asset vocabularies that the user has permission to view
2254             */
2255            @Override
2256            public List<AssetVocabulary> filterFindByGroupId(long[] groupIds) {
2257                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2258                            QueryUtil.ALL_POS, null);
2259            }
2260    
2261            /**
2262             * Returns a range of all the asset vocabularies that the user has permission to view where groupId = any &#63;.
2263             *
2264             * <p>
2265             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2266             * </p>
2267             *
2268             * @param groupIds the group IDs
2269             * @param start the lower bound of the range of asset vocabularies
2270             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2271             * @return the range of matching asset vocabularies that the user has permission to view
2272             */
2273            @Override
2274            public List<AssetVocabulary> filterFindByGroupId(long[] groupIds,
2275                    int start, int end) {
2276                    return filterFindByGroupId(groupIds, start, end, null);
2277            }
2278    
2279            /**
2280             * Returns an ordered range of all the asset vocabularies that the user has permission to view where groupId = any &#63;.
2281             *
2282             * <p>
2283             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2284             * </p>
2285             *
2286             * @param groupIds the group IDs
2287             * @param start the lower bound of the range of asset vocabularies
2288             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2289             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2290             * @return the ordered range of matching asset vocabularies that the user has permission to view
2291             */
2292            @Override
2293            public List<AssetVocabulary> filterFindByGroupId(long[] groupIds,
2294                    int start, int end, OrderByComparator<AssetVocabulary> orderByComparator) {
2295                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2296                            return findByGroupId(groupIds, start, end, orderByComparator);
2297                    }
2298    
2299                    if (groupIds == null) {
2300                            groupIds = new long[0];
2301                    }
2302                    else if (groupIds.length > 1) {
2303                            groupIds = ArrayUtil.unique(groupIds);
2304    
2305                            Arrays.sort(groupIds);
2306                    }
2307    
2308                    StringBundler query = new StringBundler();
2309    
2310                    if (getDB().isSupportsInlineDistinct()) {
2311                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
2312                    }
2313                    else {
2314                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
2315                    }
2316    
2317                    if (groupIds.length > 0) {
2318                            query.append(StringPool.OPEN_PARENTHESIS);
2319    
2320                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2321    
2322                            query.append(StringUtil.merge(groupIds));
2323    
2324                            query.append(StringPool.CLOSE_PARENTHESIS);
2325    
2326                            query.append(StringPool.CLOSE_PARENTHESIS);
2327                    }
2328    
2329                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2330                            query.index() - 1);
2331    
2332                    if (!getDB().isSupportsInlineDistinct()) {
2333                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
2334                    }
2335    
2336                    if (orderByComparator != null) {
2337                            if (getDB().isSupportsInlineDistinct()) {
2338                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2339                                            orderByComparator, true);
2340                            }
2341                            else {
2342                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2343                                            orderByComparator, true);
2344                            }
2345                    }
2346                    else {
2347                            if (getDB().isSupportsInlineDistinct()) {
2348                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2349                            }
2350                            else {
2351                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
2352                            }
2353                    }
2354    
2355                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2356                                    AssetVocabulary.class.getName(),
2357                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2358    
2359                    Session session = null;
2360    
2361                    try {
2362                            session = openSession();
2363    
2364                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2365    
2366                            if (getDB().isSupportsInlineDistinct()) {
2367                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
2368                            }
2369                            else {
2370                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
2371                            }
2372    
2373                            return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
2374                                    start, end);
2375                    }
2376                    catch (Exception e) {
2377                            throw processException(e);
2378                    }
2379                    finally {
2380                            closeSession(session);
2381                    }
2382            }
2383    
2384            /**
2385             * Returns all the asset vocabularies where groupId = any &#63;.
2386             *
2387             * <p>
2388             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2389             * </p>
2390             *
2391             * @param groupIds the group IDs
2392             * @return the matching asset vocabularies
2393             */
2394            @Override
2395            public List<AssetVocabulary> findByGroupId(long[] groupIds) {
2396                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2397                            null);
2398            }
2399    
2400            /**
2401             * Returns a range of all the asset vocabularies where groupId = any &#63;.
2402             *
2403             * <p>
2404             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2405             * </p>
2406             *
2407             * @param groupIds the group IDs
2408             * @param start the lower bound of the range of asset vocabularies
2409             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2410             * @return the range of matching asset vocabularies
2411             */
2412            @Override
2413            public List<AssetVocabulary> findByGroupId(long[] groupIds, int start,
2414                    int end) {
2415                    return findByGroupId(groupIds, start, end, null);
2416            }
2417    
2418            /**
2419             * Returns an ordered range of all the asset vocabularies where groupId = any &#63;.
2420             *
2421             * <p>
2422             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2423             * </p>
2424             *
2425             * @param groupIds the group IDs
2426             * @param start the lower bound of the range of asset vocabularies
2427             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2428             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2429             * @return the ordered range of matching asset vocabularies
2430             */
2431            @Override
2432            public List<AssetVocabulary> findByGroupId(long[] groupIds, int start,
2433                    int end, OrderByComparator<AssetVocabulary> orderByComparator) {
2434                    return findByGroupId(groupIds, start, end, orderByComparator, true);
2435            }
2436    
2437            /**
2438             * Returns an ordered range of all the asset vocabularies where groupId = &#63;, optionally using the finder cache.
2439             *
2440             * <p>
2441             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2442             * </p>
2443             *
2444             * @param groupId the group ID
2445             * @param start the lower bound of the range of asset vocabularies
2446             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2447             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2448             * @param retrieveFromCache whether to retrieve from the finder cache
2449             * @return the ordered range of matching asset vocabularies
2450             */
2451            @Override
2452            public List<AssetVocabulary> findByGroupId(long[] groupIds, int start,
2453                    int end, OrderByComparator<AssetVocabulary> orderByComparator,
2454                    boolean retrieveFromCache) {
2455                    if (groupIds == null) {
2456                            groupIds = new long[0];
2457                    }
2458                    else if (groupIds.length > 1) {
2459                            groupIds = ArrayUtil.unique(groupIds);
2460    
2461                            Arrays.sort(groupIds);
2462                    }
2463    
2464                    if (groupIds.length == 1) {
2465                            return findByGroupId(groupIds[0], start, end, orderByComparator);
2466                    }
2467    
2468                    boolean pagination = true;
2469                    Object[] finderArgs = null;
2470    
2471                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2472                                    (orderByComparator == null)) {
2473                            pagination = false;
2474                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
2475                    }
2476                    else {
2477                            finderArgs = new Object[] {
2478                                            StringUtil.merge(groupIds),
2479                                            
2480                                            start, end, orderByComparator
2481                                    };
2482                    }
2483    
2484                    List<AssetVocabulary> list = null;
2485    
2486                    if (retrieveFromCache) {
2487                            list = (List<AssetVocabulary>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2488                                            finderArgs, this);
2489    
2490                            if ((list != null) && !list.isEmpty()) {
2491                                    for (AssetVocabulary assetVocabulary : list) {
2492                                            if (!ArrayUtil.contains(groupIds,
2493                                                                    assetVocabulary.getGroupId())) {
2494                                                    list = null;
2495    
2496                                                    break;
2497                                            }
2498                                    }
2499                            }
2500                    }
2501    
2502                    if (list == null) {
2503                            StringBundler query = new StringBundler();
2504    
2505                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2506    
2507                            if (groupIds.length > 0) {
2508                                    query.append(StringPool.OPEN_PARENTHESIS);
2509    
2510                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2511    
2512                                    query.append(StringUtil.merge(groupIds));
2513    
2514                                    query.append(StringPool.CLOSE_PARENTHESIS);
2515    
2516                                    query.append(StringPool.CLOSE_PARENTHESIS);
2517                            }
2518    
2519                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2520                                                    1)), query.index() - 1);
2521    
2522                            if (orderByComparator != null) {
2523                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2524                                            orderByComparator);
2525                            }
2526                            else
2527                             if (pagination) {
2528                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2529                            }
2530    
2531                            String sql = query.toString();
2532    
2533                            Session session = null;
2534    
2535                            try {
2536                                    session = openSession();
2537    
2538                                    Query q = session.createQuery(sql);
2539    
2540                                    if (!pagination) {
2541                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2542                                                            getDialect(), start, end, false);
2543    
2544                                            Collections.sort(list);
2545    
2546                                            list = Collections.unmodifiableList(list);
2547                                    }
2548                                    else {
2549                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2550                                                            getDialect(), start, end);
2551                                    }
2552    
2553                                    cacheResult(list);
2554    
2555                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2556                                            finderArgs, list);
2557                            }
2558                            catch (Exception e) {
2559                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2560                                            finderArgs);
2561    
2562                                    throw processException(e);
2563                            }
2564                            finally {
2565                                    closeSession(session);
2566                            }
2567                    }
2568    
2569                    return list;
2570            }
2571    
2572            /**
2573             * Removes all the asset vocabularies where groupId = &#63; from the database.
2574             *
2575             * @param groupId the group ID
2576             */
2577            @Override
2578            public void removeByGroupId(long groupId) {
2579                    for (AssetVocabulary assetVocabulary : findByGroupId(groupId,
2580                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2581                            remove(assetVocabulary);
2582                    }
2583            }
2584    
2585            /**
2586             * Returns the number of asset vocabularies where groupId = &#63;.
2587             *
2588             * @param groupId the group ID
2589             * @return the number of matching asset vocabularies
2590             */
2591            @Override
2592            public int countByGroupId(long groupId) {
2593                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2594    
2595                    Object[] finderArgs = new Object[] { groupId };
2596    
2597                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2598    
2599                    if (count == null) {
2600                            StringBundler query = new StringBundler(2);
2601    
2602                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2603    
2604                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2605    
2606                            String sql = query.toString();
2607    
2608                            Session session = null;
2609    
2610                            try {
2611                                    session = openSession();
2612    
2613                                    Query q = session.createQuery(sql);
2614    
2615                                    QueryPos qPos = QueryPos.getInstance(q);
2616    
2617                                    qPos.add(groupId);
2618    
2619                                    count = (Long)q.uniqueResult();
2620    
2621                                    finderCache.putResult(finderPath, finderArgs, count);
2622                            }
2623                            catch (Exception e) {
2624                                    finderCache.removeResult(finderPath, finderArgs);
2625    
2626                                    throw processException(e);
2627                            }
2628                            finally {
2629                                    closeSession(session);
2630                            }
2631                    }
2632    
2633                    return count.intValue();
2634            }
2635    
2636            /**
2637             * Returns the number of asset vocabularies where groupId = any &#63;.
2638             *
2639             * @param groupIds the group IDs
2640             * @return the number of matching asset vocabularies
2641             */
2642            @Override
2643            public int countByGroupId(long[] groupIds) {
2644                    if (groupIds == null) {
2645                            groupIds = new long[0];
2646                    }
2647                    else if (groupIds.length > 1) {
2648                            groupIds = ArrayUtil.unique(groupIds);
2649    
2650                            Arrays.sort(groupIds);
2651                    }
2652    
2653                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2654    
2655                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2656                                    finderArgs, this);
2657    
2658                    if (count == null) {
2659                            StringBundler query = new StringBundler();
2660    
2661                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2662    
2663                            if (groupIds.length > 0) {
2664                                    query.append(StringPool.OPEN_PARENTHESIS);
2665    
2666                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2667    
2668                                    query.append(StringUtil.merge(groupIds));
2669    
2670                                    query.append(StringPool.CLOSE_PARENTHESIS);
2671    
2672                                    query.append(StringPool.CLOSE_PARENTHESIS);
2673                            }
2674    
2675                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2676                                                    1)), query.index() - 1);
2677    
2678                            String sql = query.toString();
2679    
2680                            Session session = null;
2681    
2682                            try {
2683                                    session = openSession();
2684    
2685                                    Query q = session.createQuery(sql);
2686    
2687                                    count = (Long)q.uniqueResult();
2688    
2689                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2690                                            finderArgs, count);
2691                            }
2692                            catch (Exception e) {
2693                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2694                                            finderArgs);
2695    
2696                                    throw processException(e);
2697                            }
2698                            finally {
2699                                    closeSession(session);
2700                            }
2701                    }
2702    
2703                    return count.intValue();
2704            }
2705    
2706            /**
2707             * Returns the number of asset vocabularies that the user has permission to view where groupId = &#63;.
2708             *
2709             * @param groupId the group ID
2710             * @return the number of matching asset vocabularies that the user has permission to view
2711             */
2712            @Override
2713            public int filterCountByGroupId(long groupId) {
2714                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2715                            return countByGroupId(groupId);
2716                    }
2717    
2718                    StringBundler query = new StringBundler(2);
2719    
2720                    query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2721    
2722                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2723    
2724                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2725                                    AssetVocabulary.class.getName(),
2726                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2727    
2728                    Session session = null;
2729    
2730                    try {
2731                            session = openSession();
2732    
2733                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2734    
2735                            q.addScalar(COUNT_COLUMN_NAME,
2736                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2737    
2738                            QueryPos qPos = QueryPos.getInstance(q);
2739    
2740                            qPos.add(groupId);
2741    
2742                            Long count = (Long)q.uniqueResult();
2743    
2744                            return count.intValue();
2745                    }
2746                    catch (Exception e) {
2747                            throw processException(e);
2748                    }
2749                    finally {
2750                            closeSession(session);
2751                    }
2752            }
2753    
2754            /**
2755             * Returns the number of asset vocabularies that the user has permission to view where groupId = any &#63;.
2756             *
2757             * @param groupIds the group IDs
2758             * @return the number of matching asset vocabularies that the user has permission to view
2759             */
2760            @Override
2761            public int filterCountByGroupId(long[] groupIds) {
2762                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2763                            return countByGroupId(groupIds);
2764                    }
2765    
2766                    if (groupIds == null) {
2767                            groupIds = new long[0];
2768                    }
2769                    else if (groupIds.length > 1) {
2770                            groupIds = ArrayUtil.unique(groupIds);
2771    
2772                            Arrays.sort(groupIds);
2773                    }
2774    
2775                    StringBundler query = new StringBundler();
2776    
2777                    query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2778    
2779                    if (groupIds.length > 0) {
2780                            query.append(StringPool.OPEN_PARENTHESIS);
2781    
2782                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2783    
2784                            query.append(StringUtil.merge(groupIds));
2785    
2786                            query.append(StringPool.CLOSE_PARENTHESIS);
2787    
2788                            query.append(StringPool.CLOSE_PARENTHESIS);
2789                    }
2790    
2791                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2792                            query.index() - 1);
2793    
2794                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2795                                    AssetVocabulary.class.getName(),
2796                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2797    
2798                    Session session = null;
2799    
2800                    try {
2801                            session = openSession();
2802    
2803                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2804    
2805                            q.addScalar(COUNT_COLUMN_NAME,
2806                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2807    
2808                            Long count = (Long)q.uniqueResult();
2809    
2810                            return count.intValue();
2811                    }
2812                    catch (Exception e) {
2813                            throw processException(e);
2814                    }
2815                    finally {
2816                            closeSession(session);
2817                    }
2818            }
2819    
2820            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
2821            private static final String _FINDER_COLUMN_GROUPID_GROUPID_7 = "assetVocabulary.groupId IN (";
2822            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
2823                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2824                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2825                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
2826                            "findByCompanyId",
2827                            new String[] {
2828                                    Long.class.getName(),
2829                                    
2830                            Integer.class.getName(), Integer.class.getName(),
2831                                    OrderByComparator.class.getName()
2832                            });
2833            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
2834                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2835                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
2836                            AssetVocabularyImpl.class,
2837                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
2838                            new String[] { Long.class.getName() },
2839                            AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK |
2840                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
2841            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
2842                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
2843                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
2844                            new String[] { Long.class.getName() });
2845    
2846            /**
2847             * Returns all the asset vocabularies where companyId = &#63;.
2848             *
2849             * @param companyId the company ID
2850             * @return the matching asset vocabularies
2851             */
2852            @Override
2853            public List<AssetVocabulary> findByCompanyId(long companyId) {
2854                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2855                            null);
2856            }
2857    
2858            /**
2859             * Returns a range of all the asset vocabularies where companyId = &#63;.
2860             *
2861             * <p>
2862             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2863             * </p>
2864             *
2865             * @param companyId the company ID
2866             * @param start the lower bound of the range of asset vocabularies
2867             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2868             * @return the range of matching asset vocabularies
2869             */
2870            @Override
2871            public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2872                    int end) {
2873                    return findByCompanyId(companyId, start, end, null);
2874            }
2875    
2876            /**
2877             * Returns an ordered range of all the asset vocabularies where companyId = &#63;.
2878             *
2879             * <p>
2880             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2881             * </p>
2882             *
2883             * @param companyId the company ID
2884             * @param start the lower bound of the range of asset vocabularies
2885             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2886             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2887             * @return the ordered range of matching asset vocabularies
2888             */
2889            @Override
2890            public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2891                    int end, OrderByComparator<AssetVocabulary> orderByComparator) {
2892                    return findByCompanyId(companyId, start, end, orderByComparator, true);
2893            }
2894    
2895            /**
2896             * Returns an ordered range of all the asset vocabularies where companyId = &#63;.
2897             *
2898             * <p>
2899             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
2900             * </p>
2901             *
2902             * @param companyId the company ID
2903             * @param start the lower bound of the range of asset vocabularies
2904             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2905             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2906             * @param retrieveFromCache whether to retrieve from the finder cache
2907             * @return the ordered range of matching asset vocabularies
2908             */
2909            @Override
2910            public List<AssetVocabulary> findByCompanyId(long companyId, int start,
2911                    int end, OrderByComparator<AssetVocabulary> orderByComparator,
2912                    boolean retrieveFromCache) {
2913                    boolean pagination = true;
2914                    FinderPath finderPath = null;
2915                    Object[] finderArgs = null;
2916    
2917                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2918                                    (orderByComparator == null)) {
2919                            pagination = false;
2920                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
2921                            finderArgs = new Object[] { companyId };
2922                    }
2923                    else {
2924                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
2925                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
2926                    }
2927    
2928                    List<AssetVocabulary> list = null;
2929    
2930                    if (retrieveFromCache) {
2931                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
2932                                            finderArgs, this);
2933    
2934                            if ((list != null) && !list.isEmpty()) {
2935                                    for (AssetVocabulary assetVocabulary : list) {
2936                                            if ((companyId != assetVocabulary.getCompanyId())) {
2937                                                    list = null;
2938    
2939                                                    break;
2940                                            }
2941                                    }
2942                            }
2943                    }
2944    
2945                    if (list == null) {
2946                            StringBundler query = null;
2947    
2948                            if (orderByComparator != null) {
2949                                    query = new StringBundler(3 +
2950                                                    (orderByComparator.getOrderByFields().length * 3));
2951                            }
2952                            else {
2953                                    query = new StringBundler(3);
2954                            }
2955    
2956                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2957    
2958                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2959    
2960                            if (orderByComparator != null) {
2961                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2962                                            orderByComparator);
2963                            }
2964                            else
2965                             if (pagination) {
2966                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2967                            }
2968    
2969                            String sql = query.toString();
2970    
2971                            Session session = null;
2972    
2973                            try {
2974                                    session = openSession();
2975    
2976                                    Query q = session.createQuery(sql);
2977    
2978                                    QueryPos qPos = QueryPos.getInstance(q);
2979    
2980                                    qPos.add(companyId);
2981    
2982                                    if (!pagination) {
2983                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2984                                                            getDialect(), start, end, false);
2985    
2986                                            Collections.sort(list);
2987    
2988                                            list = Collections.unmodifiableList(list);
2989                                    }
2990                                    else {
2991                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2992                                                            getDialect(), start, end);
2993                                    }
2994    
2995                                    cacheResult(list);
2996    
2997                                    finderCache.putResult(finderPath, finderArgs, list);
2998                            }
2999                            catch (Exception e) {
3000                                    finderCache.removeResult(finderPath, finderArgs);
3001    
3002                                    throw processException(e);
3003                            }
3004                            finally {
3005                                    closeSession(session);
3006                            }
3007                    }
3008    
3009                    return list;
3010            }
3011    
3012            /**
3013             * Returns the first asset vocabulary in the ordered set where companyId = &#63;.
3014             *
3015             * @param companyId the company ID
3016             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3017             * @return the first matching asset vocabulary
3018             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
3019             */
3020            @Override
3021            public AssetVocabulary findByCompanyId_First(long companyId,
3022                    OrderByComparator<AssetVocabulary> orderByComparator)
3023                    throws NoSuchVocabularyException {
3024                    AssetVocabulary assetVocabulary = fetchByCompanyId_First(companyId,
3025                                    orderByComparator);
3026    
3027                    if (assetVocabulary != null) {
3028                            return assetVocabulary;
3029                    }
3030    
3031                    StringBundler msg = new StringBundler(4);
3032    
3033                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3034    
3035                    msg.append("companyId=");
3036                    msg.append(companyId);
3037    
3038                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3039    
3040                    throw new NoSuchVocabularyException(msg.toString());
3041            }
3042    
3043            /**
3044             * Returns the first asset vocabulary in the ordered set where companyId = &#63;.
3045             *
3046             * @param companyId the company ID
3047             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3048             * @return the first matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3049             */
3050            @Override
3051            public AssetVocabulary fetchByCompanyId_First(long companyId,
3052                    OrderByComparator<AssetVocabulary> orderByComparator) {
3053                    List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
3054                                    orderByComparator);
3055    
3056                    if (!list.isEmpty()) {
3057                            return list.get(0);
3058                    }
3059    
3060                    return null;
3061            }
3062    
3063            /**
3064             * Returns the last asset vocabulary in the ordered set where companyId = &#63;.
3065             *
3066             * @param companyId the company ID
3067             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3068             * @return the last matching asset vocabulary
3069             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
3070             */
3071            @Override
3072            public AssetVocabulary findByCompanyId_Last(long companyId,
3073                    OrderByComparator<AssetVocabulary> orderByComparator)
3074                    throws NoSuchVocabularyException {
3075                    AssetVocabulary assetVocabulary = fetchByCompanyId_Last(companyId,
3076                                    orderByComparator);
3077    
3078                    if (assetVocabulary != null) {
3079                            return assetVocabulary;
3080                    }
3081    
3082                    StringBundler msg = new StringBundler(4);
3083    
3084                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3085    
3086                    msg.append("companyId=");
3087                    msg.append(companyId);
3088    
3089                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3090    
3091                    throw new NoSuchVocabularyException(msg.toString());
3092            }
3093    
3094            /**
3095             * Returns the last asset vocabulary in the ordered set where companyId = &#63;.
3096             *
3097             * @param companyId the company ID
3098             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3099             * @return the last matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3100             */
3101            @Override
3102            public AssetVocabulary fetchByCompanyId_Last(long companyId,
3103                    OrderByComparator<AssetVocabulary> orderByComparator) {
3104                    int count = countByCompanyId(companyId);
3105    
3106                    if (count == 0) {
3107                            return null;
3108                    }
3109    
3110                    List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
3111                                    count, orderByComparator);
3112    
3113                    if (!list.isEmpty()) {
3114                            return list.get(0);
3115                    }
3116    
3117                    return null;
3118            }
3119    
3120            /**
3121             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where companyId = &#63;.
3122             *
3123             * @param vocabularyId the primary key of the current asset vocabulary
3124             * @param companyId the company ID
3125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3126             * @return the previous, current, and next asset vocabulary
3127             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
3128             */
3129            @Override
3130            public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
3131                    long companyId, OrderByComparator<AssetVocabulary> orderByComparator)
3132                    throws NoSuchVocabularyException {
3133                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
3134    
3135                    Session session = null;
3136    
3137                    try {
3138                            session = openSession();
3139    
3140                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
3141    
3142                            array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
3143                                            companyId, orderByComparator, true);
3144    
3145                            array[1] = assetVocabulary;
3146    
3147                            array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
3148                                            companyId, orderByComparator, false);
3149    
3150                            return array;
3151                    }
3152                    catch (Exception e) {
3153                            throw processException(e);
3154                    }
3155                    finally {
3156                            closeSession(session);
3157                    }
3158            }
3159    
3160            protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
3161                    AssetVocabulary assetVocabulary, long companyId,
3162                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
3163                    StringBundler query = null;
3164    
3165                    if (orderByComparator != null) {
3166                            query = new StringBundler(6 +
3167                                            (orderByComparator.getOrderByFields().length * 6));
3168                    }
3169                    else {
3170                            query = new StringBundler(3);
3171                    }
3172    
3173                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
3174    
3175                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3176    
3177                    if (orderByComparator != null) {
3178                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3179    
3180                            if (orderByConditionFields.length > 0) {
3181                                    query.append(WHERE_AND);
3182                            }
3183    
3184                            for (int i = 0; i < orderByConditionFields.length; i++) {
3185                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3186                                    query.append(orderByConditionFields[i]);
3187    
3188                                    if ((i + 1) < orderByConditionFields.length) {
3189                                            if (orderByComparator.isAscending() ^ previous) {
3190                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3191                                            }
3192                                            else {
3193                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3194                                            }
3195                                    }
3196                                    else {
3197                                            if (orderByComparator.isAscending() ^ previous) {
3198                                                    query.append(WHERE_GREATER_THAN);
3199                                            }
3200                                            else {
3201                                                    query.append(WHERE_LESSER_THAN);
3202                                            }
3203                                    }
3204                            }
3205    
3206                            query.append(ORDER_BY_CLAUSE);
3207    
3208                            String[] orderByFields = orderByComparator.getOrderByFields();
3209    
3210                            for (int i = 0; i < orderByFields.length; i++) {
3211                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3212                                    query.append(orderByFields[i]);
3213    
3214                                    if ((i + 1) < orderByFields.length) {
3215                                            if (orderByComparator.isAscending() ^ previous) {
3216                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3217                                            }
3218                                            else {
3219                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3220                                            }
3221                                    }
3222                                    else {
3223                                            if (orderByComparator.isAscending() ^ previous) {
3224                                                    query.append(ORDER_BY_ASC);
3225                                            }
3226                                            else {
3227                                                    query.append(ORDER_BY_DESC);
3228                                            }
3229                                    }
3230                            }
3231                    }
3232                    else {
3233                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
3234                    }
3235    
3236                    String sql = query.toString();
3237    
3238                    Query q = session.createQuery(sql);
3239    
3240                    q.setFirstResult(0);
3241                    q.setMaxResults(2);
3242    
3243                    QueryPos qPos = QueryPos.getInstance(q);
3244    
3245                    qPos.add(companyId);
3246    
3247                    if (orderByComparator != null) {
3248                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
3249    
3250                            for (Object value : values) {
3251                                    qPos.add(value);
3252                            }
3253                    }
3254    
3255                    List<AssetVocabulary> list = q.list();
3256    
3257                    if (list.size() == 2) {
3258                            return list.get(1);
3259                    }
3260                    else {
3261                            return null;
3262                    }
3263            }
3264    
3265            /**
3266             * Removes all the asset vocabularies where companyId = &#63; from the database.
3267             *
3268             * @param companyId the company ID
3269             */
3270            @Override
3271            public void removeByCompanyId(long companyId) {
3272                    for (AssetVocabulary assetVocabulary : findByCompanyId(companyId,
3273                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
3274                            remove(assetVocabulary);
3275                    }
3276            }
3277    
3278            /**
3279             * Returns the number of asset vocabularies where companyId = &#63;.
3280             *
3281             * @param companyId the company ID
3282             * @return the number of matching asset vocabularies
3283             */
3284            @Override
3285            public int countByCompanyId(long companyId) {
3286                    FinderPath finderPath = FINDER_PATH_COUNT_BY_COMPANYID;
3287    
3288                    Object[] finderArgs = new Object[] { companyId };
3289    
3290                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3291    
3292                    if (count == null) {
3293                            StringBundler query = new StringBundler(2);
3294    
3295                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3296    
3297                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3298    
3299                            String sql = query.toString();
3300    
3301                            Session session = null;
3302    
3303                            try {
3304                                    session = openSession();
3305    
3306                                    Query q = session.createQuery(sql);
3307    
3308                                    QueryPos qPos = QueryPos.getInstance(q);
3309    
3310                                    qPos.add(companyId);
3311    
3312                                    count = (Long)q.uniqueResult();
3313    
3314                                    finderCache.putResult(finderPath, finderArgs, count);
3315                            }
3316                            catch (Exception e) {
3317                                    finderCache.removeResult(finderPath, finderArgs);
3318    
3319                                    throw processException(e);
3320                            }
3321                            finally {
3322                                    closeSession(session);
3323                            }
3324                    }
3325    
3326                    return count.intValue();
3327            }
3328    
3329            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3330            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3331                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
3332                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
3333                            new String[] { Long.class.getName(), String.class.getName() },
3334                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
3335                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
3336            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3337                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
3338                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
3339                            new String[] { Long.class.getName(), String.class.getName() });
3340    
3341            /**
3342             * Returns the asset vocabulary where groupId = &#63; and name = &#63; or throws a {@link NoSuchVocabularyException} if it could not be found.
3343             *
3344             * @param groupId the group ID
3345             * @param name the name
3346             * @return the matching asset vocabulary
3347             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
3348             */
3349            @Override
3350            public AssetVocabulary findByG_N(long groupId, String name)
3351                    throws NoSuchVocabularyException {
3352                    AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
3353    
3354                    if (assetVocabulary == null) {
3355                            StringBundler msg = new StringBundler(6);
3356    
3357                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3358    
3359                            msg.append("groupId=");
3360                            msg.append(groupId);
3361    
3362                            msg.append(", name=");
3363                            msg.append(name);
3364    
3365                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3366    
3367                            if (_log.isWarnEnabled()) {
3368                                    _log.warn(msg.toString());
3369                            }
3370    
3371                            throw new NoSuchVocabularyException(msg.toString());
3372                    }
3373    
3374                    return assetVocabulary;
3375            }
3376    
3377            /**
3378             * Returns the asset vocabulary where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
3379             *
3380             * @param groupId the group ID
3381             * @param name the name
3382             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3383             */
3384            @Override
3385            public AssetVocabulary fetchByG_N(long groupId, String name) {
3386                    return fetchByG_N(groupId, name, true);
3387            }
3388    
3389            /**
3390             * Returns the asset vocabulary where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
3391             *
3392             * @param groupId the group ID
3393             * @param name the name
3394             * @param retrieveFromCache whether to retrieve from the finder cache
3395             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3396             */
3397            @Override
3398            public AssetVocabulary fetchByG_N(long groupId, String name,
3399                    boolean retrieveFromCache) {
3400                    Object[] finderArgs = new Object[] { groupId, name };
3401    
3402                    Object result = null;
3403    
3404                    if (retrieveFromCache) {
3405                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_N,
3406                                            finderArgs, this);
3407                    }
3408    
3409                    if (result instanceof AssetVocabulary) {
3410                            AssetVocabulary assetVocabulary = (AssetVocabulary)result;
3411    
3412                            if ((groupId != assetVocabulary.getGroupId()) ||
3413                                            !Validator.equals(name, assetVocabulary.getName())) {
3414                                    result = null;
3415                            }
3416                    }
3417    
3418                    if (result == null) {
3419                            StringBundler query = new StringBundler(4);
3420    
3421                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
3422    
3423                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3424    
3425                            boolean bindName = false;
3426    
3427                            if (name == null) {
3428                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
3429                            }
3430                            else if (name.equals(StringPool.BLANK)) {
3431                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
3432                            }
3433                            else {
3434                                    bindName = true;
3435    
3436                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
3437                            }
3438    
3439                            String sql = query.toString();
3440    
3441                            Session session = null;
3442    
3443                            try {
3444                                    session = openSession();
3445    
3446                                    Query q = session.createQuery(sql);
3447    
3448                                    QueryPos qPos = QueryPos.getInstance(q);
3449    
3450                                    qPos.add(groupId);
3451    
3452                                    if (bindName) {
3453                                            qPos.add(name);
3454                                    }
3455    
3456                                    List<AssetVocabulary> list = q.list();
3457    
3458                                    if (list.isEmpty()) {
3459                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_N, finderArgs,
3460                                                    list);
3461                                    }
3462                                    else {
3463                                            AssetVocabulary assetVocabulary = list.get(0);
3464    
3465                                            result = assetVocabulary;
3466    
3467                                            cacheResult(assetVocabulary);
3468    
3469                                            if ((assetVocabulary.getGroupId() != groupId) ||
3470                                                            (assetVocabulary.getName() == null) ||
3471                                                            !assetVocabulary.getName().equals(name)) {
3472                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_N,
3473                                                            finderArgs, assetVocabulary);
3474                                            }
3475                                    }
3476                            }
3477                            catch (Exception e) {
3478                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_N, finderArgs);
3479    
3480                                    throw processException(e);
3481                            }
3482                            finally {
3483                                    closeSession(session);
3484                            }
3485                    }
3486    
3487                    if (result instanceof List<?>) {
3488                            return null;
3489                    }
3490                    else {
3491                            return (AssetVocabulary)result;
3492                    }
3493            }
3494    
3495            /**
3496             * Removes the asset vocabulary where groupId = &#63; and name = &#63; from the database.
3497             *
3498             * @param groupId the group ID
3499             * @param name the name
3500             * @return the asset vocabulary that was removed
3501             */
3502            @Override
3503            public AssetVocabulary removeByG_N(long groupId, String name)
3504                    throws NoSuchVocabularyException {
3505                    AssetVocabulary assetVocabulary = findByG_N(groupId, name);
3506    
3507                    return remove(assetVocabulary);
3508            }
3509    
3510            /**
3511             * Returns the number of asset vocabularies where groupId = &#63; and name = &#63;.
3512             *
3513             * @param groupId the group ID
3514             * @param name the name
3515             * @return the number of matching asset vocabularies
3516             */
3517            @Override
3518            public int countByG_N(long groupId, String name) {
3519                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_N;
3520    
3521                    Object[] finderArgs = new Object[] { groupId, name };
3522    
3523                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3524    
3525                    if (count == null) {
3526                            StringBundler query = new StringBundler(3);
3527    
3528                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
3529    
3530                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
3531    
3532                            boolean bindName = false;
3533    
3534                            if (name == null) {
3535                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
3536                            }
3537                            else if (name.equals(StringPool.BLANK)) {
3538                                    query.append(_FINDER_COLUMN_G_N_NAME_3);
3539                            }
3540                            else {
3541                                    bindName = true;
3542    
3543                                    query.append(_FINDER_COLUMN_G_N_NAME_2);
3544                            }
3545    
3546                            String sql = query.toString();
3547    
3548                            Session session = null;
3549    
3550                            try {
3551                                    session = openSession();
3552    
3553                                    Query q = session.createQuery(sql);
3554    
3555                                    QueryPos qPos = QueryPos.getInstance(q);
3556    
3557                                    qPos.add(groupId);
3558    
3559                                    if (bindName) {
3560                                            qPos.add(name);
3561                                    }
3562    
3563                                    count = (Long)q.uniqueResult();
3564    
3565                                    finderCache.putResult(finderPath, finderArgs, count);
3566                            }
3567                            catch (Exception e) {
3568                                    finderCache.removeResult(finderPath, finderArgs);
3569    
3570                                    throw processException(e);
3571                            }
3572                            finally {
3573                                    closeSession(session);
3574                            }
3575                    }
3576    
3577                    return count.intValue();
3578            }
3579    
3580            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3581            private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3582            private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3583            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = '')";
3584            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3585                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
3586                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
3587                            "findByG_LikeN",
3588                            new String[] {
3589                                    Long.class.getName(), String.class.getName(),
3590                                    
3591                            Integer.class.getName(), Integer.class.getName(),
3592                                    OrderByComparator.class.getName()
3593                            });
3594            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
3595                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
3596                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN",
3597                            new String[] { Long.class.getName(), String.class.getName() });
3598    
3599            /**
3600             * Returns all the asset vocabularies where groupId = &#63; and name LIKE &#63;.
3601             *
3602             * @param groupId the group ID
3603             * @param name the name
3604             * @return the matching asset vocabularies
3605             */
3606            @Override
3607            public List<AssetVocabulary> findByG_LikeN(long groupId, String name) {
3608                    return findByG_LikeN(groupId, name, QueryUtil.ALL_POS,
3609                            QueryUtil.ALL_POS, null);
3610            }
3611    
3612            /**
3613             * Returns a range of all the asset vocabularies where groupId = &#63; and name LIKE &#63;.
3614             *
3615             * <p>
3616             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
3617             * </p>
3618             *
3619             * @param groupId the group ID
3620             * @param name the name
3621             * @param start the lower bound of the range of asset vocabularies
3622             * @param end the upper bound of the range of asset vocabularies (not inclusive)
3623             * @return the range of matching asset vocabularies
3624             */
3625            @Override
3626            public List<AssetVocabulary> findByG_LikeN(long groupId, String name,
3627                    int start, int end) {
3628                    return findByG_LikeN(groupId, name, start, end, null);
3629            }
3630    
3631            /**
3632             * Returns an ordered range of all the asset vocabularies where groupId = &#63; and name LIKE &#63;.
3633             *
3634             * <p>
3635             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
3636             * </p>
3637             *
3638             * @param groupId the group ID
3639             * @param name the name
3640             * @param start the lower bound of the range of asset vocabularies
3641             * @param end the upper bound of the range of asset vocabularies (not inclusive)
3642             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3643             * @return the ordered range of matching asset vocabularies
3644             */
3645            @Override
3646            public List<AssetVocabulary> findByG_LikeN(long groupId, String name,
3647                    int start, int end, OrderByComparator<AssetVocabulary> orderByComparator) {
3648                    return findByG_LikeN(groupId, name, start, end, orderByComparator, true);
3649            }
3650    
3651            /**
3652             * Returns an ordered range of all the asset vocabularies where groupId = &#63; and name LIKE &#63;.
3653             *
3654             * <p>
3655             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
3656             * </p>
3657             *
3658             * @param groupId the group ID
3659             * @param name the name
3660             * @param start the lower bound of the range of asset vocabularies
3661             * @param end the upper bound of the range of asset vocabularies (not inclusive)
3662             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3663             * @param retrieveFromCache whether to retrieve from the finder cache
3664             * @return the ordered range of matching asset vocabularies
3665             */
3666            @Override
3667            public List<AssetVocabulary> findByG_LikeN(long groupId, String name,
3668                    int start, int end,
3669                    OrderByComparator<AssetVocabulary> orderByComparator,
3670                    boolean retrieveFromCache) {
3671                    boolean pagination = true;
3672                    FinderPath finderPath = null;
3673                    Object[] finderArgs = null;
3674    
3675                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN;
3676                    finderArgs = new Object[] { groupId, name, start, end, orderByComparator };
3677    
3678                    List<AssetVocabulary> list = null;
3679    
3680                    if (retrieveFromCache) {
3681                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
3682                                            finderArgs, this);
3683    
3684                            if ((list != null) && !list.isEmpty()) {
3685                                    for (AssetVocabulary assetVocabulary : list) {
3686                                            if ((groupId != assetVocabulary.getGroupId()) ||
3687                                                            !StringUtil.wildcardMatches(
3688                                                                    assetVocabulary.getName(), name,
3689                                                                    CharPool.UNDERLINE, CharPool.PERCENT,
3690                                                                    CharPool.BACK_SLASH, false)) {
3691                                                    list = null;
3692    
3693                                                    break;
3694                                            }
3695                                    }
3696                            }
3697                    }
3698    
3699                    if (list == null) {
3700                            StringBundler query = null;
3701    
3702                            if (orderByComparator != null) {
3703                                    query = new StringBundler(4 +
3704                                                    (orderByComparator.getOrderByFields().length * 3));
3705                            }
3706                            else {
3707                                    query = new StringBundler(4);
3708                            }
3709    
3710                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
3711    
3712                            query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
3713    
3714                            boolean bindName = false;
3715    
3716                            if (name == null) {
3717                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
3718                            }
3719                            else if (name.equals(StringPool.BLANK)) {
3720                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
3721                            }
3722                            else {
3723                                    bindName = true;
3724    
3725                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
3726                            }
3727    
3728                            if (orderByComparator != null) {
3729                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3730                                            orderByComparator);
3731                            }
3732                            else
3733                             if (pagination) {
3734                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
3735                            }
3736    
3737                            String sql = query.toString();
3738    
3739                            Session session = null;
3740    
3741                            try {
3742                                    session = openSession();
3743    
3744                                    Query q = session.createQuery(sql);
3745    
3746                                    QueryPos qPos = QueryPos.getInstance(q);
3747    
3748                                    qPos.add(groupId);
3749    
3750                                    if (bindName) {
3751                                            qPos.add(StringUtil.toLowerCase(name));
3752                                    }
3753    
3754                                    if (!pagination) {
3755                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
3756                                                            getDialect(), start, end, false);
3757    
3758                                            Collections.sort(list);
3759    
3760                                            list = Collections.unmodifiableList(list);
3761                                    }
3762                                    else {
3763                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
3764                                                            getDialect(), start, end);
3765                                    }
3766    
3767                                    cacheResult(list);
3768    
3769                                    finderCache.putResult(finderPath, finderArgs, list);
3770                            }
3771                            catch (Exception e) {
3772                                    finderCache.removeResult(finderPath, finderArgs);
3773    
3774                                    throw processException(e);
3775                            }
3776                            finally {
3777                                    closeSession(session);
3778                            }
3779                    }
3780    
3781                    return list;
3782            }
3783    
3784            /**
3785             * Returns the first asset vocabulary in the ordered set where groupId = &#63; and name LIKE &#63;.
3786             *
3787             * @param groupId the group ID
3788             * @param name the name
3789             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3790             * @return the first matching asset vocabulary
3791             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
3792             */
3793            @Override
3794            public AssetVocabulary findByG_LikeN_First(long groupId, String name,
3795                    OrderByComparator<AssetVocabulary> orderByComparator)
3796                    throws NoSuchVocabularyException {
3797                    AssetVocabulary assetVocabulary = fetchByG_LikeN_First(groupId, name,
3798                                    orderByComparator);
3799    
3800                    if (assetVocabulary != null) {
3801                            return assetVocabulary;
3802                    }
3803    
3804                    StringBundler msg = new StringBundler(6);
3805    
3806                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3807    
3808                    msg.append("groupId=");
3809                    msg.append(groupId);
3810    
3811                    msg.append(", name=");
3812                    msg.append(name);
3813    
3814                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3815    
3816                    throw new NoSuchVocabularyException(msg.toString());
3817            }
3818    
3819            /**
3820             * Returns the first asset vocabulary in the ordered set where groupId = &#63; and name LIKE &#63;.
3821             *
3822             * @param groupId the group ID
3823             * @param name the name
3824             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3825             * @return the first matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3826             */
3827            @Override
3828            public AssetVocabulary fetchByG_LikeN_First(long groupId, String name,
3829                    OrderByComparator<AssetVocabulary> orderByComparator) {
3830                    List<AssetVocabulary> list = findByG_LikeN(groupId, name, 0, 1,
3831                                    orderByComparator);
3832    
3833                    if (!list.isEmpty()) {
3834                            return list.get(0);
3835                    }
3836    
3837                    return null;
3838            }
3839    
3840            /**
3841             * Returns the last asset vocabulary in the ordered set where groupId = &#63; and name LIKE &#63;.
3842             *
3843             * @param groupId the group ID
3844             * @param name the name
3845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3846             * @return the last matching asset vocabulary
3847             * @throws NoSuchVocabularyException if a matching asset vocabulary could not be found
3848             */
3849            @Override
3850            public AssetVocabulary findByG_LikeN_Last(long groupId, String name,
3851                    OrderByComparator<AssetVocabulary> orderByComparator)
3852                    throws NoSuchVocabularyException {
3853                    AssetVocabulary assetVocabulary = fetchByG_LikeN_Last(groupId, name,
3854                                    orderByComparator);
3855    
3856                    if (assetVocabulary != null) {
3857                            return assetVocabulary;
3858                    }
3859    
3860                    StringBundler msg = new StringBundler(6);
3861    
3862                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3863    
3864                    msg.append("groupId=");
3865                    msg.append(groupId);
3866    
3867                    msg.append(", name=");
3868                    msg.append(name);
3869    
3870                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3871    
3872                    throw new NoSuchVocabularyException(msg.toString());
3873            }
3874    
3875            /**
3876             * Returns the last asset vocabulary in the ordered set where groupId = &#63; and name LIKE &#63;.
3877             *
3878             * @param groupId the group ID
3879             * @param name the name
3880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3881             * @return the last matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
3882             */
3883            @Override
3884            public AssetVocabulary fetchByG_LikeN_Last(long groupId, String name,
3885                    OrderByComparator<AssetVocabulary> orderByComparator) {
3886                    int count = countByG_LikeN(groupId, name);
3887    
3888                    if (count == 0) {
3889                            return null;
3890                    }
3891    
3892                    List<AssetVocabulary> list = findByG_LikeN(groupId, name, count - 1,
3893                                    count, orderByComparator);
3894    
3895                    if (!list.isEmpty()) {
3896                            return list.get(0);
3897                    }
3898    
3899                    return null;
3900            }
3901    
3902            /**
3903             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where groupId = &#63; and name LIKE &#63;.
3904             *
3905             * @param vocabularyId the primary key of the current asset vocabulary
3906             * @param groupId the group ID
3907             * @param name the name
3908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3909             * @return the previous, current, and next asset vocabulary
3910             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
3911             */
3912            @Override
3913            public AssetVocabulary[] findByG_LikeN_PrevAndNext(long vocabularyId,
3914                    long groupId, String name,
3915                    OrderByComparator<AssetVocabulary> orderByComparator)
3916                    throws NoSuchVocabularyException {
3917                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
3918    
3919                    Session session = null;
3920    
3921                    try {
3922                            session = openSession();
3923    
3924                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
3925    
3926                            array[0] = getByG_LikeN_PrevAndNext(session, assetVocabulary,
3927                                            groupId, name, orderByComparator, true);
3928    
3929                            array[1] = assetVocabulary;
3930    
3931                            array[2] = getByG_LikeN_PrevAndNext(session, assetVocabulary,
3932                                            groupId, name, orderByComparator, false);
3933    
3934                            return array;
3935                    }
3936                    catch (Exception e) {
3937                            throw processException(e);
3938                    }
3939                    finally {
3940                            closeSession(session);
3941                    }
3942            }
3943    
3944            protected AssetVocabulary getByG_LikeN_PrevAndNext(Session session,
3945                    AssetVocabulary assetVocabulary, long groupId, String name,
3946                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
3947                    StringBundler query = null;
3948    
3949                    if (orderByComparator != null) {
3950                            query = new StringBundler(6 +
3951                                            (orderByComparator.getOrderByFields().length * 6));
3952                    }
3953                    else {
3954                            query = new StringBundler(3);
3955                    }
3956    
3957                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
3958    
3959                    query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
3960    
3961                    boolean bindName = false;
3962    
3963                    if (name == null) {
3964                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
3965                    }
3966                    else if (name.equals(StringPool.BLANK)) {
3967                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
3968                    }
3969                    else {
3970                            bindName = true;
3971    
3972                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
3973                    }
3974    
3975                    if (orderByComparator != null) {
3976                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3977    
3978                            if (orderByConditionFields.length > 0) {
3979                                    query.append(WHERE_AND);
3980                            }
3981    
3982                            for (int i = 0; i < orderByConditionFields.length; i++) {
3983                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3984                                    query.append(orderByConditionFields[i]);
3985    
3986                                    if ((i + 1) < orderByConditionFields.length) {
3987                                            if (orderByComparator.isAscending() ^ previous) {
3988                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3989                                            }
3990                                            else {
3991                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3992                                            }
3993                                    }
3994                                    else {
3995                                            if (orderByComparator.isAscending() ^ previous) {
3996                                                    query.append(WHERE_GREATER_THAN);
3997                                            }
3998                                            else {
3999                                                    query.append(WHERE_LESSER_THAN);
4000                                            }
4001                                    }
4002                            }
4003    
4004                            query.append(ORDER_BY_CLAUSE);
4005    
4006                            String[] orderByFields = orderByComparator.getOrderByFields();
4007    
4008                            for (int i = 0; i < orderByFields.length; i++) {
4009                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4010                                    query.append(orderByFields[i]);
4011    
4012                                    if ((i + 1) < orderByFields.length) {
4013                                            if (orderByComparator.isAscending() ^ previous) {
4014                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4015                                            }
4016                                            else {
4017                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4018                                            }
4019                                    }
4020                                    else {
4021                                            if (orderByComparator.isAscending() ^ previous) {
4022                                                    query.append(ORDER_BY_ASC);
4023                                            }
4024                                            else {
4025                                                    query.append(ORDER_BY_DESC);
4026                                            }
4027                                    }
4028                            }
4029                    }
4030                    else {
4031                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
4032                    }
4033    
4034                    String sql = query.toString();
4035    
4036                    Query q = session.createQuery(sql);
4037    
4038                    q.setFirstResult(0);
4039                    q.setMaxResults(2);
4040    
4041                    QueryPos qPos = QueryPos.getInstance(q);
4042    
4043                    qPos.add(groupId);
4044    
4045                    if (bindName) {
4046                            qPos.add(StringUtil.toLowerCase(name));
4047                    }
4048    
4049                    if (orderByComparator != null) {
4050                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
4051    
4052                            for (Object value : values) {
4053                                    qPos.add(value);
4054                            }
4055                    }
4056    
4057                    List<AssetVocabulary> list = q.list();
4058    
4059                    if (list.size() == 2) {
4060                            return list.get(1);
4061                    }
4062                    else {
4063                            return null;
4064                    }
4065            }
4066    
4067            /**
4068             * Returns all the asset vocabularies that the user has permission to view where groupId = &#63; and name LIKE &#63;.
4069             *
4070             * @param groupId the group ID
4071             * @param name the name
4072             * @return the matching asset vocabularies that the user has permission to view
4073             */
4074            @Override
4075            public List<AssetVocabulary> filterFindByG_LikeN(long groupId, String name) {
4076                    return filterFindByG_LikeN(groupId, name, QueryUtil.ALL_POS,
4077                            QueryUtil.ALL_POS, null);
4078            }
4079    
4080            /**
4081             * Returns a range of all the asset vocabularies that the user has permission to view where groupId = &#63; and name LIKE &#63;.
4082             *
4083             * <p>
4084             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
4085             * </p>
4086             *
4087             * @param groupId the group ID
4088             * @param name the name
4089             * @param start the lower bound of the range of asset vocabularies
4090             * @param end the upper bound of the range of asset vocabularies (not inclusive)
4091             * @return the range of matching asset vocabularies that the user has permission to view
4092             */
4093            @Override
4094            public List<AssetVocabulary> filterFindByG_LikeN(long groupId, String name,
4095                    int start, int end) {
4096                    return filterFindByG_LikeN(groupId, name, start, end, null);
4097            }
4098    
4099            /**
4100             * Returns an ordered range of all the asset vocabularies that the user has permissions to view where groupId = &#63; and name LIKE &#63;.
4101             *
4102             * <p>
4103             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
4104             * </p>
4105             *
4106             * @param groupId the group ID
4107             * @param name the name
4108             * @param start the lower bound of the range of asset vocabularies
4109             * @param end the upper bound of the range of asset vocabularies (not inclusive)
4110             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4111             * @return the ordered range of matching asset vocabularies that the user has permission to view
4112             */
4113            @Override
4114            public List<AssetVocabulary> filterFindByG_LikeN(long groupId, String name,
4115                    int start, int end, OrderByComparator<AssetVocabulary> orderByComparator) {
4116                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4117                            return findByG_LikeN(groupId, name, start, end, orderByComparator);
4118                    }
4119    
4120                    StringBundler query = null;
4121    
4122                    if (orderByComparator != null) {
4123                            query = new StringBundler(4 +
4124                                            (orderByComparator.getOrderByFields().length * 3));
4125                    }
4126                    else {
4127                            query = new StringBundler(4);
4128                    }
4129    
4130                    if (getDB().isSupportsInlineDistinct()) {
4131                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
4132                    }
4133                    else {
4134                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
4135                    }
4136    
4137                    query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
4138    
4139                    boolean bindName = false;
4140    
4141                    if (name == null) {
4142                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
4143                    }
4144                    else if (name.equals(StringPool.BLANK)) {
4145                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
4146                    }
4147                    else {
4148                            bindName = true;
4149    
4150                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
4151                    }
4152    
4153                    if (!getDB().isSupportsInlineDistinct()) {
4154                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
4155                    }
4156    
4157                    if (orderByComparator != null) {
4158                            if (getDB().isSupportsInlineDistinct()) {
4159                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4160                                            orderByComparator, true);
4161                            }
4162                            else {
4163                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4164                                            orderByComparator, true);
4165                            }
4166                    }
4167                    else {
4168                            if (getDB().isSupportsInlineDistinct()) {
4169                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
4170                            }
4171                            else {
4172                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
4173                            }
4174                    }
4175    
4176                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4177                                    AssetVocabulary.class.getName(),
4178                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4179    
4180                    Session session = null;
4181    
4182                    try {
4183                            session = openSession();
4184    
4185                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4186    
4187                            if (getDB().isSupportsInlineDistinct()) {
4188                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
4189                            }
4190                            else {
4191                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
4192                            }
4193    
4194                            QueryPos qPos = QueryPos.getInstance(q);
4195    
4196                            qPos.add(groupId);
4197    
4198                            if (bindName) {
4199                                    qPos.add(StringUtil.toLowerCase(name));
4200                            }
4201    
4202                            return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
4203                                    start, end);
4204                    }
4205                    catch (Exception e) {
4206                            throw processException(e);
4207                    }
4208                    finally {
4209                            closeSession(session);
4210                    }
4211            }
4212    
4213            /**
4214             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set of asset vocabularies that the user has permission to view where groupId = &#63; and name LIKE &#63;.
4215             *
4216             * @param vocabularyId the primary key of the current asset vocabulary
4217             * @param groupId the group ID
4218             * @param name the name
4219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4220             * @return the previous, current, and next asset vocabulary
4221             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
4222             */
4223            @Override
4224            public AssetVocabulary[] filterFindByG_LikeN_PrevAndNext(
4225                    long vocabularyId, long groupId, String name,
4226                    OrderByComparator<AssetVocabulary> orderByComparator)
4227                    throws NoSuchVocabularyException {
4228                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4229                            return findByG_LikeN_PrevAndNext(vocabularyId, groupId, name,
4230                                    orderByComparator);
4231                    }
4232    
4233                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
4234    
4235                    Session session = null;
4236    
4237                    try {
4238                            session = openSession();
4239    
4240                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
4241    
4242                            array[0] = filterGetByG_LikeN_PrevAndNext(session, assetVocabulary,
4243                                            groupId, name, orderByComparator, true);
4244    
4245                            array[1] = assetVocabulary;
4246    
4247                            array[2] = filterGetByG_LikeN_PrevAndNext(session, assetVocabulary,
4248                                            groupId, name, orderByComparator, false);
4249    
4250                            return array;
4251                    }
4252                    catch (Exception e) {
4253                            throw processException(e);
4254                    }
4255                    finally {
4256                            closeSession(session);
4257                    }
4258            }
4259    
4260            protected AssetVocabulary filterGetByG_LikeN_PrevAndNext(Session session,
4261                    AssetVocabulary assetVocabulary, long groupId, String name,
4262                    OrderByComparator<AssetVocabulary> orderByComparator, boolean previous) {
4263                    StringBundler query = null;
4264    
4265                    if (orderByComparator != null) {
4266                            query = new StringBundler(6 +
4267                                            (orderByComparator.getOrderByFields().length * 6));
4268                    }
4269                    else {
4270                            query = new StringBundler(3);
4271                    }
4272    
4273                    if (getDB().isSupportsInlineDistinct()) {
4274                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
4275                    }
4276                    else {
4277                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
4278                    }
4279    
4280                    query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
4281    
4282                    boolean bindName = false;
4283    
4284                    if (name == null) {
4285                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
4286                    }
4287                    else if (name.equals(StringPool.BLANK)) {
4288                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
4289                    }
4290                    else {
4291                            bindName = true;
4292    
4293                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
4294                    }
4295    
4296                    if (!getDB().isSupportsInlineDistinct()) {
4297                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
4298                    }
4299    
4300                    if (orderByComparator != null) {
4301                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4302    
4303                            if (orderByConditionFields.length > 0) {
4304                                    query.append(WHERE_AND);
4305                            }
4306    
4307                            for (int i = 0; i < orderByConditionFields.length; i++) {
4308                                    if (getDB().isSupportsInlineDistinct()) {
4309                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4310                                    }
4311                                    else {
4312                                            query.append(_ORDER_BY_ENTITY_TABLE);
4313                                    }
4314    
4315                                    query.append(orderByConditionFields[i]);
4316    
4317                                    if ((i + 1) < orderByConditionFields.length) {
4318                                            if (orderByComparator.isAscending() ^ previous) {
4319                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4320                                            }
4321                                            else {
4322                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4323                                            }
4324                                    }
4325                                    else {
4326                                            if (orderByComparator.isAscending() ^ previous) {
4327                                                    query.append(WHERE_GREATER_THAN);
4328                                            }
4329                                            else {
4330                                                    query.append(WHERE_LESSER_THAN);
4331                                            }
4332                                    }
4333                            }
4334    
4335                            query.append(ORDER_BY_CLAUSE);
4336    
4337                            String[] orderByFields = orderByComparator.getOrderByFields();
4338    
4339                            for (int i = 0; i < orderByFields.length; i++) {
4340                                    if (getDB().isSupportsInlineDistinct()) {
4341                                            query.append(_ORDER_BY_ENTITY_ALIAS);
4342                                    }
4343                                    else {
4344                                            query.append(_ORDER_BY_ENTITY_TABLE);
4345                                    }
4346    
4347                                    query.append(orderByFields[i]);
4348    
4349                                    if ((i + 1) < orderByFields.length) {
4350                                            if (orderByComparator.isAscending() ^ previous) {
4351                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4352                                            }
4353                                            else {
4354                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4355                                            }
4356                                    }
4357                                    else {
4358                                            if (orderByComparator.isAscending() ^ previous) {
4359                                                    query.append(ORDER_BY_ASC);
4360                                            }
4361                                            else {
4362                                                    query.append(ORDER_BY_DESC);
4363                                            }
4364                                    }
4365                            }
4366                    }
4367                    else {
4368                            if (getDB().isSupportsInlineDistinct()) {
4369                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
4370                            }
4371                            else {
4372                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
4373                            }
4374                    }
4375    
4376                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4377                                    AssetVocabulary.class.getName(),
4378                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4379    
4380                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
4381    
4382                    q.setFirstResult(0);
4383                    q.setMaxResults(2);
4384    
4385                    if (getDB().isSupportsInlineDistinct()) {
4386                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
4387                    }
4388                    else {
4389                            q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
4390                    }
4391    
4392                    QueryPos qPos = QueryPos.getInstance(q);
4393    
4394                    qPos.add(groupId);
4395    
4396                    if (bindName) {
4397                            qPos.add(StringUtil.toLowerCase(name));
4398                    }
4399    
4400                    if (orderByComparator != null) {
4401                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
4402    
4403                            for (Object value : values) {
4404                                    qPos.add(value);
4405                            }
4406                    }
4407    
4408                    List<AssetVocabulary> list = q.list();
4409    
4410                    if (list.size() == 2) {
4411                            return list.get(1);
4412                    }
4413                    else {
4414                            return null;
4415                    }
4416            }
4417    
4418            /**
4419             * Removes all the asset vocabularies where groupId = &#63; and name LIKE &#63; from the database.
4420             *
4421             * @param groupId the group ID
4422             * @param name the name
4423             */
4424            @Override
4425            public void removeByG_LikeN(long groupId, String name) {
4426                    for (AssetVocabulary assetVocabulary : findByG_LikeN(groupId, name,
4427                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
4428                            remove(assetVocabulary);
4429                    }
4430            }
4431    
4432            /**
4433             * Returns the number of asset vocabularies where groupId = &#63; and name LIKE &#63;.
4434             *
4435             * @param groupId the group ID
4436             * @param name the name
4437             * @return the number of matching asset vocabularies
4438             */
4439            @Override
4440            public int countByG_LikeN(long groupId, String name) {
4441                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN;
4442    
4443                    Object[] finderArgs = new Object[] { groupId, name };
4444    
4445                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
4446    
4447                    if (count == null) {
4448                            StringBundler query = new StringBundler(3);
4449    
4450                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
4451    
4452                            query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
4453    
4454                            boolean bindName = false;
4455    
4456                            if (name == null) {
4457                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
4458                            }
4459                            else if (name.equals(StringPool.BLANK)) {
4460                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
4461                            }
4462                            else {
4463                                    bindName = true;
4464    
4465                                    query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
4466                            }
4467    
4468                            String sql = query.toString();
4469    
4470                            Session session = null;
4471    
4472                            try {
4473                                    session = openSession();
4474    
4475                                    Query q = session.createQuery(sql);
4476    
4477                                    QueryPos qPos = QueryPos.getInstance(q);
4478    
4479                                    qPos.add(groupId);
4480    
4481                                    if (bindName) {
4482                                            qPos.add(StringUtil.toLowerCase(name));
4483                                    }
4484    
4485                                    count = (Long)q.uniqueResult();
4486    
4487                                    finderCache.putResult(finderPath, finderArgs, count);
4488                            }
4489                            catch (Exception e) {
4490                                    finderCache.removeResult(finderPath, finderArgs);
4491    
4492                                    throw processException(e);
4493                            }
4494                            finally {
4495                                    closeSession(session);
4496                            }
4497                    }
4498    
4499                    return count.intValue();
4500            }
4501    
4502            /**
4503             * Returns the number of asset vocabularies that the user has permission to view where groupId = &#63; and name LIKE &#63;.
4504             *
4505             * @param groupId the group ID
4506             * @param name the name
4507             * @return the number of matching asset vocabularies that the user has permission to view
4508             */
4509            @Override
4510            public int filterCountByG_LikeN(long groupId, String name) {
4511                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4512                            return countByG_LikeN(groupId, name);
4513                    }
4514    
4515                    StringBundler query = new StringBundler(3);
4516    
4517                    query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
4518    
4519                    query.append(_FINDER_COLUMN_G_LIKEN_GROUPID_2);
4520    
4521                    boolean bindName = false;
4522    
4523                    if (name == null) {
4524                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_1);
4525                    }
4526                    else if (name.equals(StringPool.BLANK)) {
4527                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_3);
4528                    }
4529                    else {
4530                            bindName = true;
4531    
4532                            query.append(_FINDER_COLUMN_G_LIKEN_NAME_2);
4533                    }
4534    
4535                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4536                                    AssetVocabulary.class.getName(),
4537                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4538    
4539                    Session session = null;
4540    
4541                    try {
4542                            session = openSession();
4543    
4544                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
4545    
4546                            q.addScalar(COUNT_COLUMN_NAME,
4547                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
4548    
4549                            QueryPos qPos = QueryPos.getInstance(q);
4550    
4551                            qPos.add(groupId);
4552    
4553                            if (bindName) {
4554                                    qPos.add(StringUtil.toLowerCase(name));
4555                            }
4556    
4557                            Long count = (Long)q.uniqueResult();
4558    
4559                            return count.intValue();
4560                    }
4561                    catch (Exception e) {
4562                            throw processException(e);
4563                    }
4564                    finally {
4565                            closeSession(session);
4566                    }
4567            }
4568    
4569            private static final String _FINDER_COLUMN_G_LIKEN_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
4570            private static final String _FINDER_COLUMN_G_LIKEN_NAME_1 = "assetVocabulary.name IS NULL";
4571            private static final String _FINDER_COLUMN_G_LIKEN_NAME_2 = "lower(assetVocabulary.name) LIKE ?";
4572            private static final String _FINDER_COLUMN_G_LIKEN_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name LIKE '')";
4573    
4574            public AssetVocabularyPersistenceImpl() {
4575                    setModelClass(AssetVocabulary.class);
4576            }
4577    
4578            /**
4579             * Caches the asset vocabulary in the entity cache if it is enabled.
4580             *
4581             * @param assetVocabulary the asset vocabulary
4582             */
4583            @Override
4584            public void cacheResult(AssetVocabulary assetVocabulary) {
4585                    entityCache.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
4586                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
4587                            assetVocabulary);
4588    
4589                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
4590                            new Object[] { assetVocabulary.getUuid(), assetVocabulary.getGroupId() },
4591                            assetVocabulary);
4592    
4593                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_N,
4594                            new Object[] { assetVocabulary.getGroupId(), assetVocabulary.getName() },
4595                            assetVocabulary);
4596    
4597                    assetVocabulary.resetOriginalValues();
4598            }
4599    
4600            /**
4601             * Caches the asset vocabularies in the entity cache if it is enabled.
4602             *
4603             * @param assetVocabularies the asset vocabularies
4604             */
4605            @Override
4606            public void cacheResult(List<AssetVocabulary> assetVocabularies) {
4607                    for (AssetVocabulary assetVocabulary : assetVocabularies) {
4608                            if (entityCache.getResult(
4609                                                    AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
4610                                                    AssetVocabularyImpl.class,
4611                                                    assetVocabulary.getPrimaryKey()) == null) {
4612                                    cacheResult(assetVocabulary);
4613                            }
4614                            else {
4615                                    assetVocabulary.resetOriginalValues();
4616                            }
4617                    }
4618            }
4619    
4620            /**
4621             * Clears the cache for all asset vocabularies.
4622             *
4623             * <p>
4624             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
4625             * </p>
4626             */
4627            @Override
4628            public void clearCache() {
4629                    entityCache.clearCache(AssetVocabularyImpl.class);
4630    
4631                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
4632                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4633                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4634            }
4635    
4636            /**
4637             * Clears the cache for the asset vocabulary.
4638             *
4639             * <p>
4640             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
4641             * </p>
4642             */
4643            @Override
4644            public void clearCache(AssetVocabulary assetVocabulary) {
4645                    entityCache.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
4646                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
4647    
4648                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4649                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4650    
4651                    clearUniqueFindersCache((AssetVocabularyModelImpl)assetVocabulary);
4652            }
4653    
4654            @Override
4655            public void clearCache(List<AssetVocabulary> assetVocabularies) {
4656                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4657                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4658    
4659                    for (AssetVocabulary assetVocabulary : assetVocabularies) {
4660                            entityCache.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
4661                                    AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
4662    
4663                            clearUniqueFindersCache((AssetVocabularyModelImpl)assetVocabulary);
4664                    }
4665            }
4666    
4667            protected void cacheUniqueFindersCache(
4668                    AssetVocabularyModelImpl assetVocabularyModelImpl, boolean isNew) {
4669                    if (isNew) {
4670                            Object[] args = new Object[] {
4671                                            assetVocabularyModelImpl.getUuid(),
4672                                            assetVocabularyModelImpl.getGroupId()
4673                                    };
4674    
4675                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4676                                    Long.valueOf(1));
4677                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4678                                    assetVocabularyModelImpl);
4679    
4680                            args = new Object[] {
4681                                            assetVocabularyModelImpl.getGroupId(),
4682                                            assetVocabularyModelImpl.getName()
4683                                    };
4684    
4685                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4686                                    Long.valueOf(1));
4687                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_N, args,
4688                                    assetVocabularyModelImpl);
4689                    }
4690                    else {
4691                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4692                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4693                                    Object[] args = new Object[] {
4694                                                    assetVocabularyModelImpl.getUuid(),
4695                                                    assetVocabularyModelImpl.getGroupId()
4696                                            };
4697    
4698                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
4699                                            Long.valueOf(1));
4700                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
4701                                            assetVocabularyModelImpl);
4702                            }
4703    
4704                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4705                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4706                                    Object[] args = new Object[] {
4707                                                    assetVocabularyModelImpl.getGroupId(),
4708                                                    assetVocabularyModelImpl.getName()
4709                                            };
4710    
4711                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_N, args,
4712                                            Long.valueOf(1));
4713                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_N, args,
4714                                            assetVocabularyModelImpl);
4715                            }
4716                    }
4717            }
4718    
4719            protected void clearUniqueFindersCache(
4720                    AssetVocabularyModelImpl assetVocabularyModelImpl) {
4721                    Object[] args = new Object[] {
4722                                    assetVocabularyModelImpl.getUuid(),
4723                                    assetVocabularyModelImpl.getGroupId()
4724                            };
4725    
4726                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4727                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4728    
4729                    if ((assetVocabularyModelImpl.getColumnBitmask() &
4730                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
4731                            args = new Object[] {
4732                                            assetVocabularyModelImpl.getOriginalUuid(),
4733                                            assetVocabularyModelImpl.getOriginalGroupId()
4734                                    };
4735    
4736                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
4737                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
4738                    }
4739    
4740                    args = new Object[] {
4741                                    assetVocabularyModelImpl.getGroupId(),
4742                                    assetVocabularyModelImpl.getName()
4743                            };
4744    
4745                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4746                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4747    
4748                    if ((assetVocabularyModelImpl.getColumnBitmask() &
4749                                    FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
4750                            args = new Object[] {
4751                                            assetVocabularyModelImpl.getOriginalGroupId(),
4752                                            assetVocabularyModelImpl.getOriginalName()
4753                                    };
4754    
4755                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
4756                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
4757                    }
4758            }
4759    
4760            /**
4761             * Creates a new asset vocabulary with the primary key. Does not add the asset vocabulary to the database.
4762             *
4763             * @param vocabularyId the primary key for the new asset vocabulary
4764             * @return the new asset vocabulary
4765             */
4766            @Override
4767            public AssetVocabulary create(long vocabularyId) {
4768                    AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
4769    
4770                    assetVocabulary.setNew(true);
4771                    assetVocabulary.setPrimaryKey(vocabularyId);
4772    
4773                    String uuid = PortalUUIDUtil.generate();
4774    
4775                    assetVocabulary.setUuid(uuid);
4776    
4777                    assetVocabulary.setCompanyId(companyProvider.getCompanyId());
4778    
4779                    return assetVocabulary;
4780            }
4781    
4782            /**
4783             * Removes the asset vocabulary with the primary key from the database. Also notifies the appropriate model listeners.
4784             *
4785             * @param vocabularyId the primary key of the asset vocabulary
4786             * @return the asset vocabulary that was removed
4787             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
4788             */
4789            @Override
4790            public AssetVocabulary remove(long vocabularyId)
4791                    throws NoSuchVocabularyException {
4792                    return remove((Serializable)vocabularyId);
4793            }
4794    
4795            /**
4796             * Removes the asset vocabulary with the primary key from the database. Also notifies the appropriate model listeners.
4797             *
4798             * @param primaryKey the primary key of the asset vocabulary
4799             * @return the asset vocabulary that was removed
4800             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
4801             */
4802            @Override
4803            public AssetVocabulary remove(Serializable primaryKey)
4804                    throws NoSuchVocabularyException {
4805                    Session session = null;
4806    
4807                    try {
4808                            session = openSession();
4809    
4810                            AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
4811                                            primaryKey);
4812    
4813                            if (assetVocabulary == null) {
4814                                    if (_log.isWarnEnabled()) {
4815                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
4816                                    }
4817    
4818                                    throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
4819                                            primaryKey);
4820                            }
4821    
4822                            return remove(assetVocabulary);
4823                    }
4824                    catch (NoSuchVocabularyException nsee) {
4825                            throw nsee;
4826                    }
4827                    catch (Exception e) {
4828                            throw processException(e);
4829                    }
4830                    finally {
4831                            closeSession(session);
4832                    }
4833            }
4834    
4835            @Override
4836            protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary) {
4837                    assetVocabulary = toUnwrappedModel(assetVocabulary);
4838    
4839                    Session session = null;
4840    
4841                    try {
4842                            session = openSession();
4843    
4844                            if (!session.contains(assetVocabulary)) {
4845                                    assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
4846                                                    assetVocabulary.getPrimaryKeyObj());
4847                            }
4848    
4849                            if (assetVocabulary != null) {
4850                                    session.delete(assetVocabulary);
4851                            }
4852                    }
4853                    catch (Exception e) {
4854                            throw processException(e);
4855                    }
4856                    finally {
4857                            closeSession(session);
4858                    }
4859    
4860                    if (assetVocabulary != null) {
4861                            clearCache(assetVocabulary);
4862                    }
4863    
4864                    return assetVocabulary;
4865            }
4866    
4867            @Override
4868            public AssetVocabulary updateImpl(AssetVocabulary assetVocabulary) {
4869                    assetVocabulary = toUnwrappedModel(assetVocabulary);
4870    
4871                    boolean isNew = assetVocabulary.isNew();
4872    
4873                    AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
4874    
4875                    if (Validator.isNull(assetVocabulary.getUuid())) {
4876                            String uuid = PortalUUIDUtil.generate();
4877    
4878                            assetVocabulary.setUuid(uuid);
4879                    }
4880    
4881                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
4882    
4883                    Date now = new Date();
4884    
4885                    if (isNew && (assetVocabulary.getCreateDate() == null)) {
4886                            if (serviceContext == null) {
4887                                    assetVocabulary.setCreateDate(now);
4888                            }
4889                            else {
4890                                    assetVocabulary.setCreateDate(serviceContext.getCreateDate(now));
4891                            }
4892                    }
4893    
4894                    if (!assetVocabularyModelImpl.hasSetModifiedDate()) {
4895                            if (serviceContext == null) {
4896                                    assetVocabulary.setModifiedDate(now);
4897                            }
4898                            else {
4899                                    assetVocabulary.setModifiedDate(serviceContext.getModifiedDate(
4900                                                    now));
4901                            }
4902                    }
4903    
4904                    Session session = null;
4905    
4906                    try {
4907                            session = openSession();
4908    
4909                            if (assetVocabulary.isNew()) {
4910                                    session.save(assetVocabulary);
4911    
4912                                    assetVocabulary.setNew(false);
4913                            }
4914                            else {
4915                                    assetVocabulary = (AssetVocabulary)session.merge(assetVocabulary);
4916                            }
4917                    }
4918                    catch (Exception e) {
4919                            throw processException(e);
4920                    }
4921                    finally {
4922                            closeSession(session);
4923                    }
4924    
4925                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4926    
4927                    if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
4928                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4929                    }
4930    
4931                    else {
4932                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4933                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
4934                                    Object[] args = new Object[] {
4935                                                    assetVocabularyModelImpl.getOriginalUuid()
4936                                            };
4937    
4938                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4939                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4940                                            args);
4941    
4942                                    args = new Object[] { assetVocabularyModelImpl.getUuid() };
4943    
4944                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
4945                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
4946                                            args);
4947                            }
4948    
4949                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4950                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
4951                                    Object[] args = new Object[] {
4952                                                    assetVocabularyModelImpl.getOriginalUuid(),
4953                                                    assetVocabularyModelImpl.getOriginalCompanyId()
4954                                            };
4955    
4956                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4957                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4958                                            args);
4959    
4960                                    args = new Object[] {
4961                                                    assetVocabularyModelImpl.getUuid(),
4962                                                    assetVocabularyModelImpl.getCompanyId()
4963                                            };
4964    
4965                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
4966                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
4967                                            args);
4968                            }
4969    
4970                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4971                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
4972                                    Object[] args = new Object[] {
4973                                                    assetVocabularyModelImpl.getOriginalGroupId()
4974                                            };
4975    
4976                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4977                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4978                                            args);
4979    
4980                                    args = new Object[] { assetVocabularyModelImpl.getGroupId() };
4981    
4982                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
4983                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
4984                                            args);
4985                            }
4986    
4987                            if ((assetVocabularyModelImpl.getColumnBitmask() &
4988                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
4989                                    Object[] args = new Object[] {
4990                                                    assetVocabularyModelImpl.getOriginalCompanyId()
4991                                            };
4992    
4993                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
4994                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
4995                                            args);
4996    
4997                                    args = new Object[] { assetVocabularyModelImpl.getCompanyId() };
4998    
4999                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_COMPANYID, args);
5000                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
5001                                            args);
5002                            }
5003                    }
5004    
5005                    entityCache.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5006                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
5007                            assetVocabulary, false);
5008    
5009                    clearUniqueFindersCache(assetVocabularyModelImpl);
5010                    cacheUniqueFindersCache(assetVocabularyModelImpl, isNew);
5011    
5012                    assetVocabulary.resetOriginalValues();
5013    
5014                    return assetVocabulary;
5015            }
5016    
5017            protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
5018                    if (assetVocabulary instanceof AssetVocabularyImpl) {
5019                            return assetVocabulary;
5020                    }
5021    
5022                    AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
5023    
5024                    assetVocabularyImpl.setNew(assetVocabulary.isNew());
5025                    assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
5026    
5027                    assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
5028                    assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
5029                    assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
5030                    assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
5031                    assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
5032                    assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
5033                    assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
5034                    assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
5035                    assetVocabularyImpl.setName(assetVocabulary.getName());
5036                    assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
5037                    assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
5038                    assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
5039                    assetVocabularyImpl.setLastPublishDate(assetVocabulary.getLastPublishDate());
5040    
5041                    return assetVocabularyImpl;
5042            }
5043    
5044            /**
5045             * Returns the asset vocabulary with the primary key or throws a {@link com.liferay.portal.exception.NoSuchModelException} if it could not be found.
5046             *
5047             * @param primaryKey the primary key of the asset vocabulary
5048             * @return the asset vocabulary
5049             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
5050             */
5051            @Override
5052            public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
5053                    throws NoSuchVocabularyException {
5054                    AssetVocabulary assetVocabulary = fetchByPrimaryKey(primaryKey);
5055    
5056                    if (assetVocabulary == null) {
5057                            if (_log.isWarnEnabled()) {
5058                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
5059                            }
5060    
5061                            throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
5062                                    primaryKey);
5063                    }
5064    
5065                    return assetVocabulary;
5066            }
5067    
5068            /**
5069             * Returns the asset vocabulary with the primary key or throws a {@link NoSuchVocabularyException} if it could not be found.
5070             *
5071             * @param vocabularyId the primary key of the asset vocabulary
5072             * @return the asset vocabulary
5073             * @throws NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
5074             */
5075            @Override
5076            public AssetVocabulary findByPrimaryKey(long vocabularyId)
5077                    throws NoSuchVocabularyException {
5078                    return findByPrimaryKey((Serializable)vocabularyId);
5079            }
5080    
5081            /**
5082             * Returns the asset vocabulary with the primary key or returns <code>null</code> if it could not be found.
5083             *
5084             * @param primaryKey the primary key of the asset vocabulary
5085             * @return the asset vocabulary, or <code>null</code> if a asset vocabulary with the primary key could not be found
5086             */
5087            @Override
5088            public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey) {
5089                    AssetVocabulary assetVocabulary = (AssetVocabulary)entityCache.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5090                                    AssetVocabularyImpl.class, primaryKey);
5091    
5092                    if (assetVocabulary == _nullAssetVocabulary) {
5093                            return null;
5094                    }
5095    
5096                    if (assetVocabulary == null) {
5097                            Session session = null;
5098    
5099                            try {
5100                                    session = openSession();
5101    
5102                                    assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
5103                                                    primaryKey);
5104    
5105                                    if (assetVocabulary != null) {
5106                                            cacheResult(assetVocabulary);
5107                                    }
5108                                    else {
5109                                            entityCache.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5110                                                    AssetVocabularyImpl.class, primaryKey,
5111                                                    _nullAssetVocabulary);
5112                                    }
5113                            }
5114                            catch (Exception e) {
5115                                    entityCache.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5116                                            AssetVocabularyImpl.class, primaryKey);
5117    
5118                                    throw processException(e);
5119                            }
5120                            finally {
5121                                    closeSession(session);
5122                            }
5123                    }
5124    
5125                    return assetVocabulary;
5126            }
5127    
5128            /**
5129             * Returns the asset vocabulary with the primary key or returns <code>null</code> if it could not be found.
5130             *
5131             * @param vocabularyId the primary key of the asset vocabulary
5132             * @return the asset vocabulary, or <code>null</code> if a asset vocabulary with the primary key could not be found
5133             */
5134            @Override
5135            public AssetVocabulary fetchByPrimaryKey(long vocabularyId) {
5136                    return fetchByPrimaryKey((Serializable)vocabularyId);
5137            }
5138    
5139            @Override
5140            public Map<Serializable, AssetVocabulary> fetchByPrimaryKeys(
5141                    Set<Serializable> primaryKeys) {
5142                    if (primaryKeys.isEmpty()) {
5143                            return Collections.emptyMap();
5144                    }
5145    
5146                    Map<Serializable, AssetVocabulary> map = new HashMap<Serializable, AssetVocabulary>();
5147    
5148                    if (primaryKeys.size() == 1) {
5149                            Iterator<Serializable> iterator = primaryKeys.iterator();
5150    
5151                            Serializable primaryKey = iterator.next();
5152    
5153                            AssetVocabulary assetVocabulary = fetchByPrimaryKey(primaryKey);
5154    
5155                            if (assetVocabulary != null) {
5156                                    map.put(primaryKey, assetVocabulary);
5157                            }
5158    
5159                            return map;
5160                    }
5161    
5162                    Set<Serializable> uncachedPrimaryKeys = null;
5163    
5164                    for (Serializable primaryKey : primaryKeys) {
5165                            AssetVocabulary assetVocabulary = (AssetVocabulary)entityCache.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5166                                            AssetVocabularyImpl.class, primaryKey);
5167    
5168                            if (assetVocabulary == null) {
5169                                    if (uncachedPrimaryKeys == null) {
5170                                            uncachedPrimaryKeys = new HashSet<Serializable>();
5171                                    }
5172    
5173                                    uncachedPrimaryKeys.add(primaryKey);
5174                            }
5175                            else {
5176                                    map.put(primaryKey, assetVocabulary);
5177                            }
5178                    }
5179    
5180                    if (uncachedPrimaryKeys == null) {
5181                            return map;
5182                    }
5183    
5184                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
5185                                    1);
5186    
5187                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE_PKS_IN);
5188    
5189                    for (Serializable primaryKey : uncachedPrimaryKeys) {
5190                            query.append(String.valueOf(primaryKey));
5191    
5192                            query.append(StringPool.COMMA);
5193                    }
5194    
5195                    query.setIndex(query.index() - 1);
5196    
5197                    query.append(StringPool.CLOSE_PARENTHESIS);
5198    
5199                    String sql = query.toString();
5200    
5201                    Session session = null;
5202    
5203                    try {
5204                            session = openSession();
5205    
5206                            Query q = session.createQuery(sql);
5207    
5208                            for (AssetVocabulary assetVocabulary : (List<AssetVocabulary>)q.list()) {
5209                                    map.put(assetVocabulary.getPrimaryKeyObj(), assetVocabulary);
5210    
5211                                    cacheResult(assetVocabulary);
5212    
5213                                    uncachedPrimaryKeys.remove(assetVocabulary.getPrimaryKeyObj());
5214                            }
5215    
5216                            for (Serializable primaryKey : uncachedPrimaryKeys) {
5217                                    entityCache.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
5218                                            AssetVocabularyImpl.class, primaryKey, _nullAssetVocabulary);
5219                            }
5220                    }
5221                    catch (Exception e) {
5222                            throw processException(e);
5223                    }
5224                    finally {
5225                            closeSession(session);
5226                    }
5227    
5228                    return map;
5229            }
5230    
5231            /**
5232             * Returns all the asset vocabularies.
5233             *
5234             * @return the asset vocabularies
5235             */
5236            @Override
5237            public List<AssetVocabulary> findAll() {
5238                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5239            }
5240    
5241            /**
5242             * Returns a range of all the asset vocabularies.
5243             *
5244             * <p>
5245             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
5246             * </p>
5247             *
5248             * @param start the lower bound of the range of asset vocabularies
5249             * @param end the upper bound of the range of asset vocabularies (not inclusive)
5250             * @return the range of asset vocabularies
5251             */
5252            @Override
5253            public List<AssetVocabulary> findAll(int start, int end) {
5254                    return findAll(start, end, null);
5255            }
5256    
5257            /**
5258             * Returns an ordered range of all the asset vocabularies.
5259             *
5260             * <p>
5261             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
5262             * </p>
5263             *
5264             * @param start the lower bound of the range of asset vocabularies
5265             * @param end the upper bound of the range of asset vocabularies (not inclusive)
5266             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5267             * @return the ordered range of asset vocabularies
5268             */
5269            @Override
5270            public List<AssetVocabulary> findAll(int start, int end,
5271                    OrderByComparator<AssetVocabulary> orderByComparator) {
5272                    return findAll(start, end, orderByComparator, true);
5273            }
5274    
5275            /**
5276             * Returns an ordered range of all the asset vocabularies.
5277             *
5278             * <p>
5279             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link AssetVocabularyModelImpl}. 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.
5280             * </p>
5281             *
5282             * @param start the lower bound of the range of asset vocabularies
5283             * @param end the upper bound of the range of asset vocabularies (not inclusive)
5284             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5285             * @param retrieveFromCache whether to retrieve from the finder cache
5286             * @return the ordered range of asset vocabularies
5287             */
5288            @Override
5289            public List<AssetVocabulary> findAll(int start, int end,
5290                    OrderByComparator<AssetVocabulary> orderByComparator,
5291                    boolean retrieveFromCache) {
5292                    boolean pagination = true;
5293                    FinderPath finderPath = null;
5294                    Object[] finderArgs = null;
5295    
5296                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5297                                    (orderByComparator == null)) {
5298                            pagination = false;
5299                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
5300                            finderArgs = FINDER_ARGS_EMPTY;
5301                    }
5302                    else {
5303                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
5304                            finderArgs = new Object[] { start, end, orderByComparator };
5305                    }
5306    
5307                    List<AssetVocabulary> list = null;
5308    
5309                    if (retrieveFromCache) {
5310                            list = (List<AssetVocabulary>)finderCache.getResult(finderPath,
5311                                            finderArgs, this);
5312                    }
5313    
5314                    if (list == null) {
5315                            StringBundler query = null;
5316                            String sql = null;
5317    
5318                            if (orderByComparator != null) {
5319                                    query = new StringBundler(2 +
5320                                                    (orderByComparator.getOrderByFields().length * 3));
5321    
5322                                    query.append(_SQL_SELECT_ASSETVOCABULARY);
5323    
5324                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5325                                            orderByComparator);
5326    
5327                                    sql = query.toString();
5328                            }
5329                            else {
5330                                    sql = _SQL_SELECT_ASSETVOCABULARY;
5331    
5332                                    if (pagination) {
5333                                            sql = sql.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
5334                                    }
5335                            }
5336    
5337                            Session session = null;
5338    
5339                            try {
5340                                    session = openSession();
5341    
5342                                    Query q = session.createQuery(sql);
5343    
5344                                    if (!pagination) {
5345                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
5346                                                            getDialect(), start, end, false);
5347    
5348                                            Collections.sort(list);
5349    
5350                                            list = Collections.unmodifiableList(list);
5351                                    }
5352                                    else {
5353                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
5354                                                            getDialect(), start, end);
5355                                    }
5356    
5357                                    cacheResult(list);
5358    
5359                                    finderCache.putResult(finderPath, finderArgs, list);
5360                            }
5361                            catch (Exception e) {
5362                                    finderCache.removeResult(finderPath, finderArgs);
5363    
5364                                    throw processException(e);
5365                            }
5366                            finally {
5367                                    closeSession(session);
5368                            }
5369                    }
5370    
5371                    return list;
5372            }
5373    
5374            /**
5375             * Removes all the asset vocabularies from the database.
5376             *
5377             */
5378            @Override
5379            public void removeAll() {
5380                    for (AssetVocabulary assetVocabulary : findAll()) {
5381                            remove(assetVocabulary);
5382                    }
5383            }
5384    
5385            /**
5386             * Returns the number of asset vocabularies.
5387             *
5388             * @return the number of asset vocabularies
5389             */
5390            @Override
5391            public int countAll() {
5392                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
5393                                    FINDER_ARGS_EMPTY, this);
5394    
5395                    if (count == null) {
5396                            Session session = null;
5397    
5398                            try {
5399                                    session = openSession();
5400    
5401                                    Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
5402    
5403                                    count = (Long)q.uniqueResult();
5404    
5405                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
5406                                            count);
5407                            }
5408                            catch (Exception e) {
5409                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
5410                                            FINDER_ARGS_EMPTY);
5411    
5412                                    throw processException(e);
5413                            }
5414                            finally {
5415                                    closeSession(session);
5416                            }
5417                    }
5418    
5419                    return count.intValue();
5420            }
5421    
5422            @Override
5423            public Set<String> getBadColumnNames() {
5424                    return _badColumnNames;
5425            }
5426    
5427            @Override
5428            protected Map<String, Integer> getTableColumnsMap() {
5429                    return AssetVocabularyModelImpl.TABLE_COLUMNS_MAP;
5430            }
5431    
5432            /**
5433             * Initializes the asset vocabulary persistence.
5434             */
5435            public void afterPropertiesSet() {
5436            }
5437    
5438            public void destroy() {
5439                    entityCache.removeCache(AssetVocabularyImpl.class.getName());
5440                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
5441                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
5442                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5443            }
5444    
5445            @BeanReference(type = CompanyProviderWrapper.class)
5446            protected CompanyProvider companyProvider;
5447            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
5448            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
5449            private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
5450            private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE_PKS_IN = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE vocabularyId IN (";
5451            private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
5452            private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
5453            private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
5454            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
5455            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
5456            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
5457                    "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
5458            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
5459                    ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
5460            private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
5461            private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
5462            private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
5463            private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
5464            private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
5465            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
5466            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
5467            private static final Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
5468            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
5469                                    "uuid", "settings"
5470                            });
5471            private static final AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
5472                            @Override
5473                            public Object clone() {
5474                                    return this;
5475                            }
5476    
5477                            @Override
5478                            public CacheModel<AssetVocabulary> toCacheModel() {
5479                                    return _nullAssetVocabularyCacheModel;
5480                            }
5481                    };
5482    
5483            private static final CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel =
5484                    new CacheModel<AssetVocabulary>() {
5485                            @Override
5486                            public AssetVocabulary toEntityModel() {
5487                                    return _nullAssetVocabulary;
5488                            }
5489                    };
5490    }