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