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