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