001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.bean.BeanReference;
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.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
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.model.ModelListener;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.persistence.BatchSessionUtil;
043    import com.liferay.portal.service.persistence.GroupPersistence;
044    import com.liferay.portal.service.persistence.ResourcePersistence;
045    import com.liferay.portal.service.persistence.UserPersistence;
046    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
047    
048    import com.liferay.portlet.asset.NoSuchVocabularyException;
049    import com.liferay.portlet.asset.model.AssetVocabulary;
050    import com.liferay.portlet.asset.model.impl.AssetVocabularyImpl;
051    import com.liferay.portlet.asset.model.impl.AssetVocabularyModelImpl;
052    
053    import java.io.Serializable;
054    
055    import java.util.ArrayList;
056    import java.util.Collections;
057    import java.util.List;
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    public class AssetVocabularyPersistenceImpl extends BasePersistenceImpl<AssetVocabulary>
072            implements AssetVocabularyPersistence {
073            /*
074             * NOTE FOR DEVELOPERS:
075             *
076             * 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.
077             */
078            public static final String FINDER_CLASS_NAME_ENTITY = AssetVocabularyImpl.class.getName();
079            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080                    ".List1";
081            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082                    ".List2";
083            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
084                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
085                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
086                            "findByUuid",
087                            new String[] {
088                                    String.class.getName(),
089                                    
090                            "java.lang.Integer", "java.lang.Integer",
091                                    "com.liferay.portal.kernel.util.OrderByComparator"
092                            });
093            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
094                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
095                            AssetVocabularyImpl.class,
096                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
097                            new String[] { String.class.getName() },
098                            AssetVocabularyModelImpl.UUID_COLUMN_BITMASK);
099            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
100                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
102                            new String[] { String.class.getName() });
103            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
104                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
105                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY,
106                            "fetchByUUID_G",
107                            new String[] { String.class.getName(), Long.class.getName() },
108                            AssetVocabularyModelImpl.UUID_COLUMN_BITMASK |
109                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
110            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
111                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
112                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
113                            new String[] { String.class.getName(), Long.class.getName() });
114            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
115                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
116                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
117                            "findByGroupId",
118                            new String[] {
119                                    Long.class.getName(),
120                                    
121                            "java.lang.Integer", "java.lang.Integer",
122                                    "com.liferay.portal.kernel.util.OrderByComparator"
123                            });
124            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
125                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
126                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
127                            AssetVocabularyImpl.class,
128                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
129                            new String[] { Long.class.getName() },
130                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK);
131            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
132                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
133                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
134                            new String[] { Long.class.getName() });
135            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
136                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
137                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
138                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
139                            "findByCompanyId",
140                            new String[] {
141                                    Long.class.getName(),
142                                    
143                            "java.lang.Integer", "java.lang.Integer",
144                                    "com.liferay.portal.kernel.util.OrderByComparator"
145                            });
146            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
147                    new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
148                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
149                            AssetVocabularyImpl.class,
150                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
151                            new String[] { Long.class.getName() },
152                            AssetVocabularyModelImpl.COMPANYID_COLUMN_BITMASK);
153            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
154                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
155                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
156                            new String[] { Long.class.getName() });
157            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
158                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
159                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
160                            new String[] { Long.class.getName(), String.class.getName() },
161                            AssetVocabularyModelImpl.GROUPID_COLUMN_BITMASK |
162                            AssetVocabularyModelImpl.NAME_COLUMN_BITMASK);
163            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
164                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
166                            new String[] { Long.class.getName(), String.class.getName() });
167            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
168                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
169                            AssetVocabularyImpl.class,
170                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
171            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
172                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED,
173                            AssetVocabularyImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
174                            "findAll", new String[0]);
175            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
176                            AssetVocabularyModelImpl.FINDER_CACHE_ENABLED, Long.class,
177                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
178    
179            /**
180             * Caches the asset vocabulary in the entity cache if it is enabled.
181             *
182             * @param assetVocabulary the asset vocabulary
183             */
184            public void cacheResult(AssetVocabulary assetVocabulary) {
185                    EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
186                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
187                            assetVocabulary);
188    
189                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
190                            new Object[] {
191                                    assetVocabulary.getUuid(),
192                                    Long.valueOf(assetVocabulary.getGroupId())
193                            }, assetVocabulary);
194    
195                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
196                            new Object[] {
197                                    Long.valueOf(assetVocabulary.getGroupId()),
198                                    
199                            assetVocabulary.getName()
200                            }, assetVocabulary);
201    
202                    assetVocabulary.resetOriginalValues();
203            }
204    
205            /**
206             * Caches the asset vocabularies in the entity cache if it is enabled.
207             *
208             * @param assetVocabularies the asset vocabularies
209             */
210            public void cacheResult(List<AssetVocabulary> assetVocabularies) {
211                    for (AssetVocabulary assetVocabulary : assetVocabularies) {
212                            if (EntityCacheUtil.getResult(
213                                                    AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
214                                                    AssetVocabularyImpl.class,
215                                                    assetVocabulary.getPrimaryKey()) == null) {
216                                    cacheResult(assetVocabulary);
217                            }
218                            else {
219                                    assetVocabulary.resetOriginalValues();
220                            }
221                    }
222            }
223    
224            /**
225             * Clears the cache for all asset vocabularies.
226             *
227             * <p>
228             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
229             * </p>
230             */
231            @Override
232            public void clearCache() {
233                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
234                            CacheRegistryUtil.clear(AssetVocabularyImpl.class.getName());
235                    }
236    
237                    EntityCacheUtil.clearCache(AssetVocabularyImpl.class.getName());
238    
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
242            }
243    
244            /**
245             * Clears the cache for the asset vocabulary.
246             *
247             * <p>
248             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
249             * </p>
250             */
251            @Override
252            public void clearCache(AssetVocabulary assetVocabulary) {
253                    EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
254                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
255    
256                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258    
259                    clearUniqueFindersCache(assetVocabulary);
260            }
261    
262            @Override
263            public void clearCache(List<AssetVocabulary> assetVocabularies) {
264                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
265                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
266    
267                    for (AssetVocabulary assetVocabulary : assetVocabularies) {
268                            EntityCacheUtil.removeResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
269                                    AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey());
270    
271                            clearUniqueFindersCache(assetVocabulary);
272                    }
273            }
274    
275            protected void clearUniqueFindersCache(AssetVocabulary assetVocabulary) {
276                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
277                            new Object[] {
278                                    assetVocabulary.getUuid(),
279                                    Long.valueOf(assetVocabulary.getGroupId())
280                            });
281    
282                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
283                            new Object[] {
284                                    Long.valueOf(assetVocabulary.getGroupId()),
285                                    
286                            assetVocabulary.getName()
287                            });
288            }
289    
290            /**
291             * Creates a new asset vocabulary with the primary key. Does not add the asset vocabulary to the database.
292             *
293             * @param vocabularyId the primary key for the new asset vocabulary
294             * @return the new asset vocabulary
295             */
296            public AssetVocabulary create(long vocabularyId) {
297                    AssetVocabulary assetVocabulary = new AssetVocabularyImpl();
298    
299                    assetVocabulary.setNew(true);
300                    assetVocabulary.setPrimaryKey(vocabularyId);
301    
302                    String uuid = PortalUUIDUtil.generate();
303    
304                    assetVocabulary.setUuid(uuid);
305    
306                    return assetVocabulary;
307            }
308    
309            /**
310             * Removes the asset vocabulary with the primary key from the database. Also notifies the appropriate model listeners.
311             *
312             * @param vocabularyId the primary key of the asset vocabulary
313             * @return the asset vocabulary that was removed
314             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
315             * @throws SystemException if a system exception occurred
316             */
317            public AssetVocabulary remove(long vocabularyId)
318                    throws NoSuchVocabularyException, SystemException {
319                    return remove(Long.valueOf(vocabularyId));
320            }
321    
322            /**
323             * Removes the asset vocabulary with the primary key from the database. Also notifies the appropriate model listeners.
324             *
325             * @param primaryKey the primary key of the asset vocabulary
326             * @return the asset vocabulary that was removed
327             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
328             * @throws SystemException if a system exception occurred
329             */
330            @Override
331            public AssetVocabulary remove(Serializable primaryKey)
332                    throws NoSuchVocabularyException, SystemException {
333                    Session session = null;
334    
335                    try {
336                            session = openSession();
337    
338                            AssetVocabulary assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
339                                            primaryKey);
340    
341                            if (assetVocabulary == null) {
342                                    if (_log.isWarnEnabled()) {
343                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
344                                    }
345    
346                                    throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
347                                            primaryKey);
348                            }
349    
350                            return remove(assetVocabulary);
351                    }
352                    catch (NoSuchVocabularyException nsee) {
353                            throw nsee;
354                    }
355                    catch (Exception e) {
356                            throw processException(e);
357                    }
358                    finally {
359                            closeSession(session);
360                    }
361            }
362    
363            @Override
364            protected AssetVocabulary removeImpl(AssetVocabulary assetVocabulary)
365                    throws SystemException {
366                    assetVocabulary = toUnwrappedModel(assetVocabulary);
367    
368                    Session session = null;
369    
370                    try {
371                            session = openSession();
372    
373                            BatchSessionUtil.delete(session, assetVocabulary);
374                    }
375                    catch (Exception e) {
376                            throw processException(e);
377                    }
378                    finally {
379                            closeSession(session);
380                    }
381    
382                    clearCache(assetVocabulary);
383    
384                    return assetVocabulary;
385            }
386    
387            @Override
388            public AssetVocabulary updateImpl(
389                    com.liferay.portlet.asset.model.AssetVocabulary assetVocabulary,
390                    boolean merge) throws SystemException {
391                    assetVocabulary = toUnwrappedModel(assetVocabulary);
392    
393                    boolean isNew = assetVocabulary.isNew();
394    
395                    AssetVocabularyModelImpl assetVocabularyModelImpl = (AssetVocabularyModelImpl)assetVocabulary;
396    
397                    if (Validator.isNull(assetVocabulary.getUuid())) {
398                            String uuid = PortalUUIDUtil.generate();
399    
400                            assetVocabulary.setUuid(uuid);
401                    }
402    
403                    Session session = null;
404    
405                    try {
406                            session = openSession();
407    
408                            BatchSessionUtil.update(session, assetVocabulary, merge);
409    
410                            assetVocabulary.setNew(false);
411                    }
412                    catch (Exception e) {
413                            throw processException(e);
414                    }
415                    finally {
416                            closeSession(session);
417                    }
418    
419                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
420    
421                    if (isNew || !AssetVocabularyModelImpl.COLUMN_BITMASK_ENABLED) {
422                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
423                    }
424    
425                    else {
426                            if ((assetVocabularyModelImpl.getColumnBitmask() &
427                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
428                                    Object[] args = new Object[] {
429                                                    assetVocabularyModelImpl.getOriginalUuid()
430                                            };
431    
432                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
433                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
434                                            args);
435    
436                                    args = new Object[] { assetVocabularyModelImpl.getUuid() };
437    
438                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
439                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
440                                            args);
441                            }
442    
443                            if ((assetVocabularyModelImpl.getColumnBitmask() &
444                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
445                                    Object[] args = new Object[] {
446                                                    Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
447                                            };
448    
449                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
450                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
451                                            args);
452    
453                                    args = new Object[] {
454                                                    Long.valueOf(assetVocabularyModelImpl.getGroupId())
455                                            };
456    
457                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
458                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
459                                            args);
460                            }
461    
462                            if ((assetVocabularyModelImpl.getColumnBitmask() &
463                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
464                                    Object[] args = new Object[] {
465                                                    Long.valueOf(assetVocabularyModelImpl.getOriginalCompanyId())
466                                            };
467    
468                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
469                                            args);
470                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
471                                            args);
472    
473                                    args = new Object[] {
474                                                    Long.valueOf(assetVocabularyModelImpl.getCompanyId())
475                                            };
476    
477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
478                                            args);
479                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
480                                            args);
481                            }
482                    }
483    
484                    EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
485                            AssetVocabularyImpl.class, assetVocabulary.getPrimaryKey(),
486                            assetVocabulary);
487    
488                    if (isNew) {
489                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
490                                    new Object[] {
491                                            assetVocabulary.getUuid(),
492                                            Long.valueOf(assetVocabulary.getGroupId())
493                                    }, assetVocabulary);
494    
495                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
496                                    new Object[] {
497                                            Long.valueOf(assetVocabulary.getGroupId()),
498                                            
499                                    assetVocabulary.getName()
500                                    }, assetVocabulary);
501                    }
502                    else {
503                            if ((assetVocabularyModelImpl.getColumnBitmask() &
504                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
505                                    Object[] args = new Object[] {
506                                                    assetVocabularyModelImpl.getOriginalUuid(),
507                                                    Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId())
508                                            };
509    
510                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
511                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
512    
513                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
514                                            new Object[] {
515                                                    assetVocabulary.getUuid(),
516                                                    Long.valueOf(assetVocabulary.getGroupId())
517                                            }, assetVocabulary);
518                            }
519    
520                            if ((assetVocabularyModelImpl.getColumnBitmask() &
521                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
522                                    Object[] args = new Object[] {
523                                                    Long.valueOf(assetVocabularyModelImpl.getOriginalGroupId()),
524                                                    
525                                                    assetVocabularyModelImpl.getOriginalName()
526                                            };
527    
528                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
529                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
530    
531                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
532                                            new Object[] {
533                                                    Long.valueOf(assetVocabulary.getGroupId()),
534                                                    
535                                            assetVocabulary.getName()
536                                            }, assetVocabulary);
537                            }
538                    }
539    
540                    return assetVocabulary;
541            }
542    
543            protected AssetVocabulary toUnwrappedModel(AssetVocabulary assetVocabulary) {
544                    if (assetVocabulary instanceof AssetVocabularyImpl) {
545                            return assetVocabulary;
546                    }
547    
548                    AssetVocabularyImpl assetVocabularyImpl = new AssetVocabularyImpl();
549    
550                    assetVocabularyImpl.setNew(assetVocabulary.isNew());
551                    assetVocabularyImpl.setPrimaryKey(assetVocabulary.getPrimaryKey());
552    
553                    assetVocabularyImpl.setUuid(assetVocabulary.getUuid());
554                    assetVocabularyImpl.setVocabularyId(assetVocabulary.getVocabularyId());
555                    assetVocabularyImpl.setGroupId(assetVocabulary.getGroupId());
556                    assetVocabularyImpl.setCompanyId(assetVocabulary.getCompanyId());
557                    assetVocabularyImpl.setUserId(assetVocabulary.getUserId());
558                    assetVocabularyImpl.setUserName(assetVocabulary.getUserName());
559                    assetVocabularyImpl.setCreateDate(assetVocabulary.getCreateDate());
560                    assetVocabularyImpl.setModifiedDate(assetVocabulary.getModifiedDate());
561                    assetVocabularyImpl.setName(assetVocabulary.getName());
562                    assetVocabularyImpl.setTitle(assetVocabulary.getTitle());
563                    assetVocabularyImpl.setDescription(assetVocabulary.getDescription());
564                    assetVocabularyImpl.setSettings(assetVocabulary.getSettings());
565    
566                    return assetVocabularyImpl;
567            }
568    
569            /**
570             * Returns the asset vocabulary with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
571             *
572             * @param primaryKey the primary key of the asset vocabulary
573             * @return the asset vocabulary
574             * @throws com.liferay.portal.NoSuchModelException if a asset vocabulary with the primary key could not be found
575             * @throws SystemException if a system exception occurred
576             */
577            @Override
578            public AssetVocabulary findByPrimaryKey(Serializable primaryKey)
579                    throws NoSuchModelException, SystemException {
580                    return findByPrimaryKey(((Long)primaryKey).longValue());
581            }
582    
583            /**
584             * Returns the asset vocabulary with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchVocabularyException} if it could not be found.
585             *
586             * @param vocabularyId the primary key of the asset vocabulary
587             * @return the asset vocabulary
588             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
589             * @throws SystemException if a system exception occurred
590             */
591            public AssetVocabulary findByPrimaryKey(long vocabularyId)
592                    throws NoSuchVocabularyException, SystemException {
593                    AssetVocabulary assetVocabulary = fetchByPrimaryKey(vocabularyId);
594    
595                    if (assetVocabulary == null) {
596                            if (_log.isWarnEnabled()) {
597                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + vocabularyId);
598                            }
599    
600                            throw new NoSuchVocabularyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
601                                    vocabularyId);
602                    }
603    
604                    return assetVocabulary;
605            }
606    
607            /**
608             * Returns the asset vocabulary with the primary key or returns <code>null</code> if it could not be found.
609             *
610             * @param primaryKey the primary key of the asset vocabulary
611             * @return the asset vocabulary, or <code>null</code> if a asset vocabulary with the primary key could not be found
612             * @throws SystemException if a system exception occurred
613             */
614            @Override
615            public AssetVocabulary fetchByPrimaryKey(Serializable primaryKey)
616                    throws SystemException {
617                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
618            }
619    
620            /**
621             * Returns the asset vocabulary with the primary key or returns <code>null</code> if it could not be found.
622             *
623             * @param vocabularyId the primary key of the asset vocabulary
624             * @return the asset vocabulary, or <code>null</code> if a asset vocabulary with the primary key could not be found
625             * @throws SystemException if a system exception occurred
626             */
627            public AssetVocabulary fetchByPrimaryKey(long vocabularyId)
628                    throws SystemException {
629                    AssetVocabulary assetVocabulary = (AssetVocabulary)EntityCacheUtil.getResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
630                                    AssetVocabularyImpl.class, vocabularyId);
631    
632                    if (assetVocabulary == _nullAssetVocabulary) {
633                            return null;
634                    }
635    
636                    if (assetVocabulary == null) {
637                            Session session = null;
638    
639                            boolean hasException = false;
640    
641                            try {
642                                    session = openSession();
643    
644                                    assetVocabulary = (AssetVocabulary)session.get(AssetVocabularyImpl.class,
645                                                    Long.valueOf(vocabularyId));
646                            }
647                            catch (Exception e) {
648                                    hasException = true;
649    
650                                    throw processException(e);
651                            }
652                            finally {
653                                    if (assetVocabulary != null) {
654                                            cacheResult(assetVocabulary);
655                                    }
656                                    else if (!hasException) {
657                                            EntityCacheUtil.putResult(AssetVocabularyModelImpl.ENTITY_CACHE_ENABLED,
658                                                    AssetVocabularyImpl.class, vocabularyId,
659                                                    _nullAssetVocabulary);
660                                    }
661    
662                                    closeSession(session);
663                            }
664                    }
665    
666                    return assetVocabulary;
667            }
668    
669            /**
670             * Returns all the asset vocabularies where uuid = &#63;.
671             *
672             * @param uuid the uuid
673             * @return the matching asset vocabularies
674             * @throws SystemException if a system exception occurred
675             */
676            public List<AssetVocabulary> findByUuid(String uuid)
677                    throws SystemException {
678                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
679            }
680    
681            /**
682             * Returns a range of all the asset vocabularies where uuid = &#63;.
683             *
684             * <p>
685             * 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.
686             * </p>
687             *
688             * @param uuid the uuid
689             * @param start the lower bound of the range of asset vocabularies
690             * @param end the upper bound of the range of asset vocabularies (not inclusive)
691             * @return the range of matching asset vocabularies
692             * @throws SystemException if a system exception occurred
693             */
694            public List<AssetVocabulary> findByUuid(String uuid, int start, int end)
695                    throws SystemException {
696                    return findByUuid(uuid, start, end, null);
697            }
698    
699            /**
700             * Returns an ordered range of all the asset vocabularies where uuid = &#63;.
701             *
702             * <p>
703             * 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.
704             * </p>
705             *
706             * @param uuid the uuid
707             * @param start the lower bound of the range of asset vocabularies
708             * @param end the upper bound of the range of asset vocabularies (not inclusive)
709             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
710             * @return the ordered range of matching asset vocabularies
711             * @throws SystemException if a system exception occurred
712             */
713            public List<AssetVocabulary> findByUuid(String uuid, int start, int end,
714                    OrderByComparator orderByComparator) throws SystemException {
715                    FinderPath finderPath = null;
716                    Object[] finderArgs = null;
717    
718                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
719                                    (orderByComparator == null)) {
720                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
721                            finderArgs = new Object[] { uuid };
722                    }
723                    else {
724                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
725                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
726                    }
727    
728                    List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
729                                    finderArgs, this);
730    
731                    if (list == null) {
732                            StringBundler query = null;
733    
734                            if (orderByComparator != null) {
735                                    query = new StringBundler(3 +
736                                                    (orderByComparator.getOrderByFields().length * 3));
737                            }
738                            else {
739                                    query = new StringBundler(3);
740                            }
741    
742                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
743    
744                            if (uuid == null) {
745                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
746                            }
747                            else {
748                                    if (uuid.equals(StringPool.BLANK)) {
749                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
750                                    }
751                                    else {
752                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
753                                    }
754                            }
755    
756                            if (orderByComparator != null) {
757                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
758                                            orderByComparator);
759                            }
760    
761                            else {
762                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
763                            }
764    
765                            String sql = query.toString();
766    
767                            Session session = null;
768    
769                            try {
770                                    session = openSession();
771    
772                                    Query q = session.createQuery(sql);
773    
774                                    QueryPos qPos = QueryPos.getInstance(q);
775    
776                                    if (uuid != null) {
777                                            qPos.add(uuid);
778                                    }
779    
780                                    list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
781                                                    start, end);
782                            }
783                            catch (Exception e) {
784                                    throw processException(e);
785                            }
786                            finally {
787                                    if (list == null) {
788                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
789                                    }
790                                    else {
791                                            cacheResult(list);
792    
793                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
794                                    }
795    
796                                    closeSession(session);
797                            }
798                    }
799    
800                    return list;
801            }
802    
803            /**
804             * Returns the first asset vocabulary in the ordered set where uuid = &#63;.
805             *
806             * <p>
807             * 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.
808             * </p>
809             *
810             * @param uuid the uuid
811             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
812             * @return the first matching asset vocabulary
813             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
814             * @throws SystemException if a system exception occurred
815             */
816            public AssetVocabulary findByUuid_First(String uuid,
817                    OrderByComparator orderByComparator)
818                    throws NoSuchVocabularyException, SystemException {
819                    List<AssetVocabulary> list = findByUuid(uuid, 0, 1, orderByComparator);
820    
821                    if (list.isEmpty()) {
822                            StringBundler msg = new StringBundler(4);
823    
824                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
825    
826                            msg.append("uuid=");
827                            msg.append(uuid);
828    
829                            msg.append(StringPool.CLOSE_CURLY_BRACE);
830    
831                            throw new NoSuchVocabularyException(msg.toString());
832                    }
833                    else {
834                            return list.get(0);
835                    }
836            }
837    
838            /**
839             * Returns the last asset vocabulary in the ordered set where uuid = &#63;.
840             *
841             * <p>
842             * 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.
843             * </p>
844             *
845             * @param uuid the uuid
846             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
847             * @return the last matching asset vocabulary
848             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
849             * @throws SystemException if a system exception occurred
850             */
851            public AssetVocabulary findByUuid_Last(String uuid,
852                    OrderByComparator orderByComparator)
853                    throws NoSuchVocabularyException, SystemException {
854                    int count = countByUuid(uuid);
855    
856                    List<AssetVocabulary> list = findByUuid(uuid, count - 1, count,
857                                    orderByComparator);
858    
859                    if (list.isEmpty()) {
860                            StringBundler msg = new StringBundler(4);
861    
862                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
863    
864                            msg.append("uuid=");
865                            msg.append(uuid);
866    
867                            msg.append(StringPool.CLOSE_CURLY_BRACE);
868    
869                            throw new NoSuchVocabularyException(msg.toString());
870                    }
871                    else {
872                            return list.get(0);
873                    }
874            }
875    
876            /**
877             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where uuid = &#63;.
878             *
879             * <p>
880             * 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.
881             * </p>
882             *
883             * @param vocabularyId the primary key of the current asset vocabulary
884             * @param uuid the uuid
885             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
886             * @return the previous, current, and next asset vocabulary
887             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
888             * @throws SystemException if a system exception occurred
889             */
890            public AssetVocabulary[] findByUuid_PrevAndNext(long vocabularyId,
891                    String uuid, OrderByComparator orderByComparator)
892                    throws NoSuchVocabularyException, SystemException {
893                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
894    
895                    Session session = null;
896    
897                    try {
898                            session = openSession();
899    
900                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
901    
902                            array[0] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
903                                            orderByComparator, true);
904    
905                            array[1] = assetVocabulary;
906    
907                            array[2] = getByUuid_PrevAndNext(session, assetVocabulary, uuid,
908                                            orderByComparator, false);
909    
910                            return array;
911                    }
912                    catch (Exception e) {
913                            throw processException(e);
914                    }
915                    finally {
916                            closeSession(session);
917                    }
918            }
919    
920            protected AssetVocabulary getByUuid_PrevAndNext(Session session,
921                    AssetVocabulary assetVocabulary, String uuid,
922                    OrderByComparator orderByComparator, boolean previous) {
923                    StringBundler query = null;
924    
925                    if (orderByComparator != null) {
926                            query = new StringBundler(6 +
927                                            (orderByComparator.getOrderByFields().length * 6));
928                    }
929                    else {
930                            query = new StringBundler(3);
931                    }
932    
933                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
934    
935                    if (uuid == null) {
936                            query.append(_FINDER_COLUMN_UUID_UUID_1);
937                    }
938                    else {
939                            if (uuid.equals(StringPool.BLANK)) {
940                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
941                            }
942                            else {
943                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
944                            }
945                    }
946    
947                    if (orderByComparator != null) {
948                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
949    
950                            if (orderByConditionFields.length > 0) {
951                                    query.append(WHERE_AND);
952                            }
953    
954                            for (int i = 0; i < orderByConditionFields.length; i++) {
955                                    query.append(_ORDER_BY_ENTITY_ALIAS);
956                                    query.append(orderByConditionFields[i]);
957    
958                                    if ((i + 1) < orderByConditionFields.length) {
959                                            if (orderByComparator.isAscending() ^ previous) {
960                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
961                                            }
962                                            else {
963                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
964                                            }
965                                    }
966                                    else {
967                                            if (orderByComparator.isAscending() ^ previous) {
968                                                    query.append(WHERE_GREATER_THAN);
969                                            }
970                                            else {
971                                                    query.append(WHERE_LESSER_THAN);
972                                            }
973                                    }
974                            }
975    
976                            query.append(ORDER_BY_CLAUSE);
977    
978                            String[] orderByFields = orderByComparator.getOrderByFields();
979    
980                            for (int i = 0; i < orderByFields.length; i++) {
981                                    query.append(_ORDER_BY_ENTITY_ALIAS);
982                                    query.append(orderByFields[i]);
983    
984                                    if ((i + 1) < orderByFields.length) {
985                                            if (orderByComparator.isAscending() ^ previous) {
986                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
987                                            }
988                                            else {
989                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
990                                            }
991                                    }
992                                    else {
993                                            if (orderByComparator.isAscending() ^ previous) {
994                                                    query.append(ORDER_BY_ASC);
995                                            }
996                                            else {
997                                                    query.append(ORDER_BY_DESC);
998                                            }
999                                    }
1000                            }
1001                    }
1002    
1003                    else {
1004                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1005                    }
1006    
1007                    String sql = query.toString();
1008    
1009                    Query q = session.createQuery(sql);
1010    
1011                    q.setFirstResult(0);
1012                    q.setMaxResults(2);
1013    
1014                    QueryPos qPos = QueryPos.getInstance(q);
1015    
1016                    if (uuid != null) {
1017                            qPos.add(uuid);
1018                    }
1019    
1020                    if (orderByComparator != null) {
1021                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1022    
1023                            for (Object value : values) {
1024                                    qPos.add(value);
1025                            }
1026                    }
1027    
1028                    List<AssetVocabulary> list = q.list();
1029    
1030                    if (list.size() == 2) {
1031                            return list.get(1);
1032                    }
1033                    else {
1034                            return null;
1035                    }
1036            }
1037    
1038            /**
1039             * 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.
1040             *
1041             * @param uuid the uuid
1042             * @param groupId the group ID
1043             * @return the matching asset vocabulary
1044             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
1045             * @throws SystemException if a system exception occurred
1046             */
1047            public AssetVocabulary findByUUID_G(String uuid, long groupId)
1048                    throws NoSuchVocabularyException, SystemException {
1049                    AssetVocabulary assetVocabulary = fetchByUUID_G(uuid, groupId);
1050    
1051                    if (assetVocabulary == null) {
1052                            StringBundler msg = new StringBundler(6);
1053    
1054                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1055    
1056                            msg.append("uuid=");
1057                            msg.append(uuid);
1058    
1059                            msg.append(", groupId=");
1060                            msg.append(groupId);
1061    
1062                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1063    
1064                            if (_log.isWarnEnabled()) {
1065                                    _log.warn(msg.toString());
1066                            }
1067    
1068                            throw new NoSuchVocabularyException(msg.toString());
1069                    }
1070    
1071                    return assetVocabulary;
1072            }
1073    
1074            /**
1075             * 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.
1076             *
1077             * @param uuid the uuid
1078             * @param groupId the group ID
1079             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1080             * @throws SystemException if a system exception occurred
1081             */
1082            public AssetVocabulary fetchByUUID_G(String uuid, long groupId)
1083                    throws SystemException {
1084                    return fetchByUUID_G(uuid, groupId, true);
1085            }
1086    
1087            /**
1088             * 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.
1089             *
1090             * @param uuid the uuid
1091             * @param groupId the group ID
1092             * @param retrieveFromCache whether to use the finder cache
1093             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
1094             * @throws SystemException if a system exception occurred
1095             */
1096            public AssetVocabulary fetchByUUID_G(String uuid, long groupId,
1097                    boolean retrieveFromCache) throws SystemException {
1098                    Object[] finderArgs = new Object[] { uuid, groupId };
1099    
1100                    Object result = null;
1101    
1102                    if (retrieveFromCache) {
1103                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1104                                            finderArgs, this);
1105                    }
1106    
1107                    if (result == null) {
1108                            StringBundler query = new StringBundler(4);
1109    
1110                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1111    
1112                            if (uuid == null) {
1113                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1114                            }
1115                            else {
1116                                    if (uuid.equals(StringPool.BLANK)) {
1117                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1118                                    }
1119                                    else {
1120                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1121                                    }
1122                            }
1123    
1124                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1125    
1126                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1127    
1128                            String sql = query.toString();
1129    
1130                            Session session = null;
1131    
1132                            try {
1133                                    session = openSession();
1134    
1135                                    Query q = session.createQuery(sql);
1136    
1137                                    QueryPos qPos = QueryPos.getInstance(q);
1138    
1139                                    if (uuid != null) {
1140                                            qPos.add(uuid);
1141                                    }
1142    
1143                                    qPos.add(groupId);
1144    
1145                                    List<AssetVocabulary> list = q.list();
1146    
1147                                    result = list;
1148    
1149                                    AssetVocabulary assetVocabulary = null;
1150    
1151                                    if (list.isEmpty()) {
1152                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1153                                                    finderArgs, list);
1154                                    }
1155                                    else {
1156                                            assetVocabulary = list.get(0);
1157    
1158                                            cacheResult(assetVocabulary);
1159    
1160                                            if ((assetVocabulary.getUuid() == null) ||
1161                                                            !assetVocabulary.getUuid().equals(uuid) ||
1162                                                            (assetVocabulary.getGroupId() != groupId)) {
1163                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1164                                                            finderArgs, assetVocabulary);
1165                                            }
1166                                    }
1167    
1168                                    return assetVocabulary;
1169                            }
1170                            catch (Exception e) {
1171                                    throw processException(e);
1172                            }
1173                            finally {
1174                                    if (result == null) {
1175                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1176                                                    finderArgs);
1177                                    }
1178    
1179                                    closeSession(session);
1180                            }
1181                    }
1182                    else {
1183                            if (result instanceof List<?>) {
1184                                    return null;
1185                            }
1186                            else {
1187                                    return (AssetVocabulary)result;
1188                            }
1189                    }
1190            }
1191    
1192            /**
1193             * Returns all the asset vocabularies where groupId = &#63;.
1194             *
1195             * @param groupId the group ID
1196             * @return the matching asset vocabularies
1197             * @throws SystemException if a system exception occurred
1198             */
1199            public List<AssetVocabulary> findByGroupId(long groupId)
1200                    throws SystemException {
1201                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1202            }
1203    
1204            /**
1205             * Returns a range of all the asset vocabularies where groupId = &#63;.
1206             *
1207             * <p>
1208             * 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.
1209             * </p>
1210             *
1211             * @param groupId the group ID
1212             * @param start the lower bound of the range of asset vocabularies
1213             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1214             * @return the range of matching asset vocabularies
1215             * @throws SystemException if a system exception occurred
1216             */
1217            public List<AssetVocabulary> findByGroupId(long groupId, int start, int end)
1218                    throws SystemException {
1219                    return findByGroupId(groupId, start, end, null);
1220            }
1221    
1222            /**
1223             * Returns an ordered range of all the asset vocabularies where groupId = &#63;.
1224             *
1225             * <p>
1226             * 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.
1227             * </p>
1228             *
1229             * @param groupId the group ID
1230             * @param start the lower bound of the range of asset vocabularies
1231             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1232             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1233             * @return the ordered range of matching asset vocabularies
1234             * @throws SystemException if a system exception occurred
1235             */
1236            public List<AssetVocabulary> findByGroupId(long groupId, int start,
1237                    int end, OrderByComparator orderByComparator) throws SystemException {
1238                    FinderPath finderPath = null;
1239                    Object[] finderArgs = null;
1240    
1241                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1242                                    (orderByComparator == null)) {
1243                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1244                            finderArgs = new Object[] { groupId };
1245                    }
1246                    else {
1247                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1248                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1249                    }
1250    
1251                    List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1252                                    finderArgs, this);
1253    
1254                    if (list == null) {
1255                            StringBundler query = null;
1256    
1257                            if (orderByComparator != null) {
1258                                    query = new StringBundler(3 +
1259                                                    (orderByComparator.getOrderByFields().length * 3));
1260                            }
1261                            else {
1262                                    query = new StringBundler(3);
1263                            }
1264    
1265                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1266    
1267                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1268    
1269                            if (orderByComparator != null) {
1270                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1271                                            orderByComparator);
1272                            }
1273    
1274                            else {
1275                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1276                            }
1277    
1278                            String sql = query.toString();
1279    
1280                            Session session = null;
1281    
1282                            try {
1283                                    session = openSession();
1284    
1285                                    Query q = session.createQuery(sql);
1286    
1287                                    QueryPos qPos = QueryPos.getInstance(q);
1288    
1289                                    qPos.add(groupId);
1290    
1291                                    list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1292                                                    start, end);
1293                            }
1294                            catch (Exception e) {
1295                                    throw processException(e);
1296                            }
1297                            finally {
1298                                    if (list == null) {
1299                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1300                                    }
1301                                    else {
1302                                            cacheResult(list);
1303    
1304                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1305                                    }
1306    
1307                                    closeSession(session);
1308                            }
1309                    }
1310    
1311                    return list;
1312            }
1313    
1314            /**
1315             * Returns the first asset vocabulary in the ordered set where groupId = &#63;.
1316             *
1317             * <p>
1318             * 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.
1319             * </p>
1320             *
1321             * @param groupId the group ID
1322             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1323             * @return the first matching asset vocabulary
1324             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
1325             * @throws SystemException if a system exception occurred
1326             */
1327            public AssetVocabulary findByGroupId_First(long groupId,
1328                    OrderByComparator orderByComparator)
1329                    throws NoSuchVocabularyException, SystemException {
1330                    List<AssetVocabulary> list = findByGroupId(groupId, 0, 1,
1331                                    orderByComparator);
1332    
1333                    if (list.isEmpty()) {
1334                            StringBundler msg = new StringBundler(4);
1335    
1336                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1337    
1338                            msg.append("groupId=");
1339                            msg.append(groupId);
1340    
1341                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1342    
1343                            throw new NoSuchVocabularyException(msg.toString());
1344                    }
1345                    else {
1346                            return list.get(0);
1347                    }
1348            }
1349    
1350            /**
1351             * Returns the last asset vocabulary in the ordered set where groupId = &#63;.
1352             *
1353             * <p>
1354             * 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.
1355             * </p>
1356             *
1357             * @param groupId the group ID
1358             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1359             * @return the last matching asset vocabulary
1360             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
1361             * @throws SystemException if a system exception occurred
1362             */
1363            public AssetVocabulary findByGroupId_Last(long groupId,
1364                    OrderByComparator orderByComparator)
1365                    throws NoSuchVocabularyException, SystemException {
1366                    int count = countByGroupId(groupId);
1367    
1368                    List<AssetVocabulary> list = findByGroupId(groupId, count - 1, count,
1369                                    orderByComparator);
1370    
1371                    if (list.isEmpty()) {
1372                            StringBundler msg = new StringBundler(4);
1373    
1374                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1375    
1376                            msg.append("groupId=");
1377                            msg.append(groupId);
1378    
1379                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1380    
1381                            throw new NoSuchVocabularyException(msg.toString());
1382                    }
1383                    else {
1384                            return list.get(0);
1385                    }
1386            }
1387    
1388            /**
1389             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where groupId = &#63;.
1390             *
1391             * <p>
1392             * 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.
1393             * </p>
1394             *
1395             * @param vocabularyId the primary key of the current asset vocabulary
1396             * @param groupId the group ID
1397             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1398             * @return the previous, current, and next asset vocabulary
1399             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
1400             * @throws SystemException if a system exception occurred
1401             */
1402            public AssetVocabulary[] findByGroupId_PrevAndNext(long vocabularyId,
1403                    long groupId, OrderByComparator orderByComparator)
1404                    throws NoSuchVocabularyException, SystemException {
1405                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1406    
1407                    Session session = null;
1408    
1409                    try {
1410                            session = openSession();
1411    
1412                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
1413    
1414                            array[0] = getByGroupId_PrevAndNext(session, assetVocabulary,
1415                                            groupId, orderByComparator, true);
1416    
1417                            array[1] = assetVocabulary;
1418    
1419                            array[2] = getByGroupId_PrevAndNext(session, assetVocabulary,
1420                                            groupId, orderByComparator, false);
1421    
1422                            return array;
1423                    }
1424                    catch (Exception e) {
1425                            throw processException(e);
1426                    }
1427                    finally {
1428                            closeSession(session);
1429                    }
1430            }
1431    
1432            protected AssetVocabulary getByGroupId_PrevAndNext(Session session,
1433                    AssetVocabulary assetVocabulary, long groupId,
1434                    OrderByComparator orderByComparator, boolean previous) {
1435                    StringBundler query = null;
1436    
1437                    if (orderByComparator != null) {
1438                            query = new StringBundler(6 +
1439                                            (orderByComparator.getOrderByFields().length * 6));
1440                    }
1441                    else {
1442                            query = new StringBundler(3);
1443                    }
1444    
1445                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1446    
1447                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1448    
1449                    if (orderByComparator != null) {
1450                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1451    
1452                            if (orderByConditionFields.length > 0) {
1453                                    query.append(WHERE_AND);
1454                            }
1455    
1456                            for (int i = 0; i < orderByConditionFields.length; i++) {
1457                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1458                                    query.append(orderByConditionFields[i]);
1459    
1460                                    if ((i + 1) < orderByConditionFields.length) {
1461                                            if (orderByComparator.isAscending() ^ previous) {
1462                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1463                                            }
1464                                            else {
1465                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1466                                            }
1467                                    }
1468                                    else {
1469                                            if (orderByComparator.isAscending() ^ previous) {
1470                                                    query.append(WHERE_GREATER_THAN);
1471                                            }
1472                                            else {
1473                                                    query.append(WHERE_LESSER_THAN);
1474                                            }
1475                                    }
1476                            }
1477    
1478                            query.append(ORDER_BY_CLAUSE);
1479    
1480                            String[] orderByFields = orderByComparator.getOrderByFields();
1481    
1482                            for (int i = 0; i < orderByFields.length; i++) {
1483                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1484                                    query.append(orderByFields[i]);
1485    
1486                                    if ((i + 1) < orderByFields.length) {
1487                                            if (orderByComparator.isAscending() ^ previous) {
1488                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1489                                            }
1490                                            else {
1491                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1492                                            }
1493                                    }
1494                                    else {
1495                                            if (orderByComparator.isAscending() ^ previous) {
1496                                                    query.append(ORDER_BY_ASC);
1497                                            }
1498                                            else {
1499                                                    query.append(ORDER_BY_DESC);
1500                                            }
1501                                    }
1502                            }
1503                    }
1504    
1505                    else {
1506                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1507                    }
1508    
1509                    String sql = query.toString();
1510    
1511                    Query q = session.createQuery(sql);
1512    
1513                    q.setFirstResult(0);
1514                    q.setMaxResults(2);
1515    
1516                    QueryPos qPos = QueryPos.getInstance(q);
1517    
1518                    qPos.add(groupId);
1519    
1520                    if (orderByComparator != null) {
1521                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1522    
1523                            for (Object value : values) {
1524                                    qPos.add(value);
1525                            }
1526                    }
1527    
1528                    List<AssetVocabulary> list = q.list();
1529    
1530                    if (list.size() == 2) {
1531                            return list.get(1);
1532                    }
1533                    else {
1534                            return null;
1535                    }
1536            }
1537    
1538            /**
1539             * Returns all the asset vocabularies that the user has permission to view where groupId = &#63;.
1540             *
1541             * @param groupId the group ID
1542             * @return the matching asset vocabularies that the user has permission to view
1543             * @throws SystemException if a system exception occurred
1544             */
1545            public List<AssetVocabulary> filterFindByGroupId(long groupId)
1546                    throws SystemException {
1547                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1548                            QueryUtil.ALL_POS, null);
1549            }
1550    
1551            /**
1552             * Returns a range of all the asset vocabularies that the user has permission to view where groupId = &#63;.
1553             *
1554             * <p>
1555             * 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.
1556             * </p>
1557             *
1558             * @param groupId the group ID
1559             * @param start the lower bound of the range of asset vocabularies
1560             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1561             * @return the range of matching asset vocabularies that the user has permission to view
1562             * @throws SystemException if a system exception occurred
1563             */
1564            public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1565                    int end) throws SystemException {
1566                    return filterFindByGroupId(groupId, start, end, null);
1567            }
1568    
1569            /**
1570             * Returns an ordered range of all the asset vocabularies that the user has permissions to view where groupId = &#63;.
1571             *
1572             * <p>
1573             * 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.
1574             * </p>
1575             *
1576             * @param groupId the group ID
1577             * @param start the lower bound of the range of asset vocabularies
1578             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1579             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1580             * @return the ordered range of matching asset vocabularies that the user has permission to view
1581             * @throws SystemException if a system exception occurred
1582             */
1583            public List<AssetVocabulary> filterFindByGroupId(long groupId, int start,
1584                    int end, OrderByComparator orderByComparator) throws SystemException {
1585                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1586                            return findByGroupId(groupId, start, end, orderByComparator);
1587                    }
1588    
1589                    StringBundler query = null;
1590    
1591                    if (orderByComparator != null) {
1592                            query = new StringBundler(3 +
1593                                            (orderByComparator.getOrderByFields().length * 3));
1594                    }
1595                    else {
1596                            query = new StringBundler(3);
1597                    }
1598    
1599                    if (getDB().isSupportsInlineDistinct()) {
1600                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1601                    }
1602                    else {
1603                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1604                    }
1605    
1606                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1607    
1608                    if (!getDB().isSupportsInlineDistinct()) {
1609                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1610                    }
1611    
1612                    if (orderByComparator != null) {
1613                            if (getDB().isSupportsInlineDistinct()) {
1614                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1615                                            orderByComparator);
1616                            }
1617                            else {
1618                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1619                                            orderByComparator);
1620                            }
1621                    }
1622    
1623                    else {
1624                            if (getDB().isSupportsInlineDistinct()) {
1625                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1626                            }
1627                            else {
1628                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1629                            }
1630                    }
1631    
1632                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1633                                    AssetVocabulary.class.getName(),
1634                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1635    
1636                    Session session = null;
1637    
1638                    try {
1639                            session = openSession();
1640    
1641                            SQLQuery q = session.createSQLQuery(sql);
1642    
1643                            if (getDB().isSupportsInlineDistinct()) {
1644                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1645                            }
1646                            else {
1647                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1648                            }
1649    
1650                            QueryPos qPos = QueryPos.getInstance(q);
1651    
1652                            qPos.add(groupId);
1653    
1654                            return (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1655                                    start, end);
1656                    }
1657                    catch (Exception e) {
1658                            throw processException(e);
1659                    }
1660                    finally {
1661                            closeSession(session);
1662                    }
1663            }
1664    
1665            /**
1666             * 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;.
1667             *
1668             * @param vocabularyId the primary key of the current asset vocabulary
1669             * @param groupId the group ID
1670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1671             * @return the previous, current, and next asset vocabulary
1672             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
1673             * @throws SystemException if a system exception occurred
1674             */
1675            public AssetVocabulary[] filterFindByGroupId_PrevAndNext(
1676                    long vocabularyId, long groupId, OrderByComparator orderByComparator)
1677                    throws NoSuchVocabularyException, SystemException {
1678                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1679                            return findByGroupId_PrevAndNext(vocabularyId, groupId,
1680                                    orderByComparator);
1681                    }
1682    
1683                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
1684    
1685                    Session session = null;
1686    
1687                    try {
1688                            session = openSession();
1689    
1690                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
1691    
1692                            array[0] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1693                                            groupId, orderByComparator, true);
1694    
1695                            array[1] = assetVocabulary;
1696    
1697                            array[2] = filterGetByGroupId_PrevAndNext(session, assetVocabulary,
1698                                            groupId, orderByComparator, false);
1699    
1700                            return array;
1701                    }
1702                    catch (Exception e) {
1703                            throw processException(e);
1704                    }
1705                    finally {
1706                            closeSession(session);
1707                    }
1708            }
1709    
1710            protected AssetVocabulary filterGetByGroupId_PrevAndNext(Session session,
1711                    AssetVocabulary assetVocabulary, long groupId,
1712                    OrderByComparator orderByComparator, boolean previous) {
1713                    StringBundler query = null;
1714    
1715                    if (orderByComparator != null) {
1716                            query = new StringBundler(6 +
1717                                            (orderByComparator.getOrderByFields().length * 6));
1718                    }
1719                    else {
1720                            query = new StringBundler(3);
1721                    }
1722    
1723                    if (getDB().isSupportsInlineDistinct()) {
1724                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE);
1725                    }
1726                    else {
1727                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1);
1728                    }
1729    
1730                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1731    
1732                    if (!getDB().isSupportsInlineDistinct()) {
1733                            query.append(_FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2);
1734                    }
1735    
1736                    if (orderByComparator != null) {
1737                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1738    
1739                            if (orderByConditionFields.length > 0) {
1740                                    query.append(WHERE_AND);
1741                            }
1742    
1743                            for (int i = 0; i < orderByConditionFields.length; i++) {
1744                                    if (getDB().isSupportsInlineDistinct()) {
1745                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1746                                    }
1747                                    else {
1748                                            query.append(_ORDER_BY_ENTITY_TABLE);
1749                                    }
1750    
1751                                    query.append(orderByConditionFields[i]);
1752    
1753                                    if ((i + 1) < orderByConditionFields.length) {
1754                                            if (orderByComparator.isAscending() ^ previous) {
1755                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1756                                            }
1757                                            else {
1758                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1759                                            }
1760                                    }
1761                                    else {
1762                                            if (orderByComparator.isAscending() ^ previous) {
1763                                                    query.append(WHERE_GREATER_THAN);
1764                                            }
1765                                            else {
1766                                                    query.append(WHERE_LESSER_THAN);
1767                                            }
1768                                    }
1769                            }
1770    
1771                            query.append(ORDER_BY_CLAUSE);
1772    
1773                            String[] orderByFields = orderByComparator.getOrderByFields();
1774    
1775                            for (int i = 0; i < orderByFields.length; i++) {
1776                                    if (getDB().isSupportsInlineDistinct()) {
1777                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1778                                    }
1779                                    else {
1780                                            query.append(_ORDER_BY_ENTITY_TABLE);
1781                                    }
1782    
1783                                    query.append(orderByFields[i]);
1784    
1785                                    if ((i + 1) < orderByFields.length) {
1786                                            if (orderByComparator.isAscending() ^ previous) {
1787                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1788                                            }
1789                                            else {
1790                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1791                                            }
1792                                    }
1793                                    else {
1794                                            if (orderByComparator.isAscending() ^ previous) {
1795                                                    query.append(ORDER_BY_ASC);
1796                                            }
1797                                            else {
1798                                                    query.append(ORDER_BY_DESC);
1799                                            }
1800                                    }
1801                            }
1802                    }
1803    
1804                    else {
1805                            if (getDB().isSupportsInlineDistinct()) {
1806                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1807                            }
1808                            else {
1809                                    query.append(AssetVocabularyModelImpl.ORDER_BY_SQL);
1810                            }
1811                    }
1812    
1813                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1814                                    AssetVocabulary.class.getName(),
1815                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1816    
1817                    SQLQuery q = session.createSQLQuery(sql);
1818    
1819                    q.setFirstResult(0);
1820                    q.setMaxResults(2);
1821    
1822                    if (getDB().isSupportsInlineDistinct()) {
1823                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetVocabularyImpl.class);
1824                    }
1825                    else {
1826                            q.addEntity(_FILTER_ENTITY_TABLE, AssetVocabularyImpl.class);
1827                    }
1828    
1829                    QueryPos qPos = QueryPos.getInstance(q);
1830    
1831                    qPos.add(groupId);
1832    
1833                    if (orderByComparator != null) {
1834                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
1835    
1836                            for (Object value : values) {
1837                                    qPos.add(value);
1838                            }
1839                    }
1840    
1841                    List<AssetVocabulary> list = q.list();
1842    
1843                    if (list.size() == 2) {
1844                            return list.get(1);
1845                    }
1846                    else {
1847                            return null;
1848                    }
1849            }
1850    
1851            /**
1852             * Returns all the asset vocabularies where companyId = &#63;.
1853             *
1854             * @param companyId the company ID
1855             * @return the matching asset vocabularies
1856             * @throws SystemException if a system exception occurred
1857             */
1858            public List<AssetVocabulary> findByCompanyId(long companyId)
1859                    throws SystemException {
1860                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1861                            null);
1862            }
1863    
1864            /**
1865             * Returns a range of all the asset vocabularies where companyId = &#63;.
1866             *
1867             * <p>
1868             * 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.
1869             * </p>
1870             *
1871             * @param companyId the company ID
1872             * @param start the lower bound of the range of asset vocabularies
1873             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1874             * @return the range of matching asset vocabularies
1875             * @throws SystemException if a system exception occurred
1876             */
1877            public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1878                    int end) throws SystemException {
1879                    return findByCompanyId(companyId, start, end, null);
1880            }
1881    
1882            /**
1883             * Returns an ordered range of all the asset vocabularies where companyId = &#63;.
1884             *
1885             * <p>
1886             * 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.
1887             * </p>
1888             *
1889             * @param companyId the company ID
1890             * @param start the lower bound of the range of asset vocabularies
1891             * @param end the upper bound of the range of asset vocabularies (not inclusive)
1892             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1893             * @return the ordered range of matching asset vocabularies
1894             * @throws SystemException if a system exception occurred
1895             */
1896            public List<AssetVocabulary> findByCompanyId(long companyId, int start,
1897                    int end, OrderByComparator orderByComparator) throws SystemException {
1898                    FinderPath finderPath = null;
1899                    Object[] finderArgs = null;
1900    
1901                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1902                                    (orderByComparator == null)) {
1903                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1904                            finderArgs = new Object[] { companyId };
1905                    }
1906                    else {
1907                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1908                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
1909                    }
1910    
1911                    List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
1912                                    finderArgs, this);
1913    
1914                    if (list == null) {
1915                            StringBundler query = null;
1916    
1917                            if (orderByComparator != null) {
1918                                    query = new StringBundler(3 +
1919                                                    (orderByComparator.getOrderByFields().length * 3));
1920                            }
1921                            else {
1922                                    query = new StringBundler(3);
1923                            }
1924    
1925                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
1926    
1927                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1928    
1929                            if (orderByComparator != null) {
1930                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1931                                            orderByComparator);
1932                            }
1933    
1934                            else {
1935                                    query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
1936                            }
1937    
1938                            String sql = query.toString();
1939    
1940                            Session session = null;
1941    
1942                            try {
1943                                    session = openSession();
1944    
1945                                    Query q = session.createQuery(sql);
1946    
1947                                    QueryPos qPos = QueryPos.getInstance(q);
1948    
1949                                    qPos.add(companyId);
1950    
1951                                    list = (List<AssetVocabulary>)QueryUtil.list(q, getDialect(),
1952                                                    start, end);
1953                            }
1954                            catch (Exception e) {
1955                                    throw processException(e);
1956                            }
1957                            finally {
1958                                    if (list == null) {
1959                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1960                                    }
1961                                    else {
1962                                            cacheResult(list);
1963    
1964                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1965                                    }
1966    
1967                                    closeSession(session);
1968                            }
1969                    }
1970    
1971                    return list;
1972            }
1973    
1974            /**
1975             * Returns the first asset vocabulary in the ordered set where companyId = &#63;.
1976             *
1977             * <p>
1978             * 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.
1979             * </p>
1980             *
1981             * @param companyId the company ID
1982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1983             * @return the first matching asset vocabulary
1984             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
1985             * @throws SystemException if a system exception occurred
1986             */
1987            public AssetVocabulary findByCompanyId_First(long companyId,
1988                    OrderByComparator orderByComparator)
1989                    throws NoSuchVocabularyException, SystemException {
1990                    List<AssetVocabulary> list = findByCompanyId(companyId, 0, 1,
1991                                    orderByComparator);
1992    
1993                    if (list.isEmpty()) {
1994                            StringBundler msg = new StringBundler(4);
1995    
1996                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1997    
1998                            msg.append("companyId=");
1999                            msg.append(companyId);
2000    
2001                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2002    
2003                            throw new NoSuchVocabularyException(msg.toString());
2004                    }
2005                    else {
2006                            return list.get(0);
2007                    }
2008            }
2009    
2010            /**
2011             * Returns the last asset vocabulary in the ordered set where companyId = &#63;.
2012             *
2013             * <p>
2014             * 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.
2015             * </p>
2016             *
2017             * @param companyId the company ID
2018             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2019             * @return the last matching asset vocabulary
2020             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
2021             * @throws SystemException if a system exception occurred
2022             */
2023            public AssetVocabulary findByCompanyId_Last(long companyId,
2024                    OrderByComparator orderByComparator)
2025                    throws NoSuchVocabularyException, SystemException {
2026                    int count = countByCompanyId(companyId);
2027    
2028                    List<AssetVocabulary> list = findByCompanyId(companyId, count - 1,
2029                                    count, orderByComparator);
2030    
2031                    if (list.isEmpty()) {
2032                            StringBundler msg = new StringBundler(4);
2033    
2034                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2035    
2036                            msg.append("companyId=");
2037                            msg.append(companyId);
2038    
2039                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2040    
2041                            throw new NoSuchVocabularyException(msg.toString());
2042                    }
2043                    else {
2044                            return list.get(0);
2045                    }
2046            }
2047    
2048            /**
2049             * Returns the asset vocabularies before and after the current asset vocabulary in the ordered set where companyId = &#63;.
2050             *
2051             * <p>
2052             * 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.
2053             * </p>
2054             *
2055             * @param vocabularyId the primary key of the current asset vocabulary
2056             * @param companyId the company ID
2057             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2058             * @return the previous, current, and next asset vocabulary
2059             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a asset vocabulary with the primary key could not be found
2060             * @throws SystemException if a system exception occurred
2061             */
2062            public AssetVocabulary[] findByCompanyId_PrevAndNext(long vocabularyId,
2063                    long companyId, OrderByComparator orderByComparator)
2064                    throws NoSuchVocabularyException, SystemException {
2065                    AssetVocabulary assetVocabulary = findByPrimaryKey(vocabularyId);
2066    
2067                    Session session = null;
2068    
2069                    try {
2070                            session = openSession();
2071    
2072                            AssetVocabulary[] array = new AssetVocabularyImpl[3];
2073    
2074                            array[0] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2075                                            companyId, orderByComparator, true);
2076    
2077                            array[1] = assetVocabulary;
2078    
2079                            array[2] = getByCompanyId_PrevAndNext(session, assetVocabulary,
2080                                            companyId, orderByComparator, false);
2081    
2082                            return array;
2083                    }
2084                    catch (Exception e) {
2085                            throw processException(e);
2086                    }
2087                    finally {
2088                            closeSession(session);
2089                    }
2090            }
2091    
2092            protected AssetVocabulary getByCompanyId_PrevAndNext(Session session,
2093                    AssetVocabulary assetVocabulary, long companyId,
2094                    OrderByComparator orderByComparator, boolean previous) {
2095                    StringBundler query = null;
2096    
2097                    if (orderByComparator != null) {
2098                            query = new StringBundler(6 +
2099                                            (orderByComparator.getOrderByFields().length * 6));
2100                    }
2101                    else {
2102                            query = new StringBundler(3);
2103                    }
2104    
2105                    query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2106    
2107                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2108    
2109                    if (orderByComparator != null) {
2110                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2111    
2112                            if (orderByConditionFields.length > 0) {
2113                                    query.append(WHERE_AND);
2114                            }
2115    
2116                            for (int i = 0; i < orderByConditionFields.length; i++) {
2117                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2118                                    query.append(orderByConditionFields[i]);
2119    
2120                                    if ((i + 1) < orderByConditionFields.length) {
2121                                            if (orderByComparator.isAscending() ^ previous) {
2122                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2123                                            }
2124                                            else {
2125                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2126                                            }
2127                                    }
2128                                    else {
2129                                            if (orderByComparator.isAscending() ^ previous) {
2130                                                    query.append(WHERE_GREATER_THAN);
2131                                            }
2132                                            else {
2133                                                    query.append(WHERE_LESSER_THAN);
2134                                            }
2135                                    }
2136                            }
2137    
2138                            query.append(ORDER_BY_CLAUSE);
2139    
2140                            String[] orderByFields = orderByComparator.getOrderByFields();
2141    
2142                            for (int i = 0; i < orderByFields.length; i++) {
2143                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2144                                    query.append(orderByFields[i]);
2145    
2146                                    if ((i + 1) < orderByFields.length) {
2147                                            if (orderByComparator.isAscending() ^ previous) {
2148                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2149                                            }
2150                                            else {
2151                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2152                                            }
2153                                    }
2154                                    else {
2155                                            if (orderByComparator.isAscending() ^ previous) {
2156                                                    query.append(ORDER_BY_ASC);
2157                                            }
2158                                            else {
2159                                                    query.append(ORDER_BY_DESC);
2160                                            }
2161                                    }
2162                            }
2163                    }
2164    
2165                    else {
2166                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2167                    }
2168    
2169                    String sql = query.toString();
2170    
2171                    Query q = session.createQuery(sql);
2172    
2173                    q.setFirstResult(0);
2174                    q.setMaxResults(2);
2175    
2176                    QueryPos qPos = QueryPos.getInstance(q);
2177    
2178                    qPos.add(companyId);
2179    
2180                    if (orderByComparator != null) {
2181                            Object[] values = orderByComparator.getOrderByConditionValues(assetVocabulary);
2182    
2183                            for (Object value : values) {
2184                                    qPos.add(value);
2185                            }
2186                    }
2187    
2188                    List<AssetVocabulary> list = q.list();
2189    
2190                    if (list.size() == 2) {
2191                            return list.get(1);
2192                    }
2193                    else {
2194                            return null;
2195                    }
2196            }
2197    
2198            /**
2199             * 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.
2200             *
2201             * @param groupId the group ID
2202             * @param name the name
2203             * @return the matching asset vocabulary
2204             * @throws com.liferay.portlet.asset.NoSuchVocabularyException if a matching asset vocabulary could not be found
2205             * @throws SystemException if a system exception occurred
2206             */
2207            public AssetVocabulary findByG_N(long groupId, String name)
2208                    throws NoSuchVocabularyException, SystemException {
2209                    AssetVocabulary assetVocabulary = fetchByG_N(groupId, name);
2210    
2211                    if (assetVocabulary == null) {
2212                            StringBundler msg = new StringBundler(6);
2213    
2214                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2215    
2216                            msg.append("groupId=");
2217                            msg.append(groupId);
2218    
2219                            msg.append(", name=");
2220                            msg.append(name);
2221    
2222                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2223    
2224                            if (_log.isWarnEnabled()) {
2225                                    _log.warn(msg.toString());
2226                            }
2227    
2228                            throw new NoSuchVocabularyException(msg.toString());
2229                    }
2230    
2231                    return assetVocabulary;
2232            }
2233    
2234            /**
2235             * 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.
2236             *
2237             * @param groupId the group ID
2238             * @param name the name
2239             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
2240             * @throws SystemException if a system exception occurred
2241             */
2242            public AssetVocabulary fetchByG_N(long groupId, String name)
2243                    throws SystemException {
2244                    return fetchByG_N(groupId, name, true);
2245            }
2246    
2247            /**
2248             * 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.
2249             *
2250             * @param groupId the group ID
2251             * @param name the name
2252             * @param retrieveFromCache whether to use the finder cache
2253             * @return the matching asset vocabulary, or <code>null</code> if a matching asset vocabulary could not be found
2254             * @throws SystemException if a system exception occurred
2255             */
2256            public AssetVocabulary fetchByG_N(long groupId, String name,
2257                    boolean retrieveFromCache) throws SystemException {
2258                    Object[] finderArgs = new Object[] { groupId, name };
2259    
2260                    Object result = null;
2261    
2262                    if (retrieveFromCache) {
2263                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2264                                            finderArgs, this);
2265                    }
2266    
2267                    if (result == null) {
2268                            StringBundler query = new StringBundler(4);
2269    
2270                            query.append(_SQL_SELECT_ASSETVOCABULARY_WHERE);
2271    
2272                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2273    
2274                            if (name == null) {
2275                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
2276                            }
2277                            else {
2278                                    if (name.equals(StringPool.BLANK)) {
2279                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
2280                                    }
2281                                    else {
2282                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
2283                                    }
2284                            }
2285    
2286                            query.append(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2287    
2288                            String sql = query.toString();
2289    
2290                            Session session = null;
2291    
2292                            try {
2293                                    session = openSession();
2294    
2295                                    Query q = session.createQuery(sql);
2296    
2297                                    QueryPos qPos = QueryPos.getInstance(q);
2298    
2299                                    qPos.add(groupId);
2300    
2301                                    if (name != null) {
2302                                            qPos.add(name);
2303                                    }
2304    
2305                                    List<AssetVocabulary> list = q.list();
2306    
2307                                    result = list;
2308    
2309                                    AssetVocabulary assetVocabulary = null;
2310    
2311                                    if (list.isEmpty()) {
2312                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2313                                                    finderArgs, list);
2314                                    }
2315                                    else {
2316                                            assetVocabulary = list.get(0);
2317    
2318                                            cacheResult(assetVocabulary);
2319    
2320                                            if ((assetVocabulary.getGroupId() != groupId) ||
2321                                                            (assetVocabulary.getName() == null) ||
2322                                                            !assetVocabulary.getName().equals(name)) {
2323                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2324                                                            finderArgs, assetVocabulary);
2325                                            }
2326                                    }
2327    
2328                                    return assetVocabulary;
2329                            }
2330                            catch (Exception e) {
2331                                    throw processException(e);
2332                            }
2333                            finally {
2334                                    if (result == null) {
2335                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2336                                                    finderArgs);
2337                                    }
2338    
2339                                    closeSession(session);
2340                            }
2341                    }
2342                    else {
2343                            if (result instanceof List<?>) {
2344                                    return null;
2345                            }
2346                            else {
2347                                    return (AssetVocabulary)result;
2348                            }
2349                    }
2350            }
2351    
2352            /**
2353             * Returns all the asset vocabularies.
2354             *
2355             * @return the asset vocabularies
2356             * @throws SystemException if a system exception occurred
2357             */
2358            public List<AssetVocabulary> findAll() throws SystemException {
2359                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2360            }
2361    
2362            /**
2363             * Returns a range of all the asset vocabularies.
2364             *
2365             * <p>
2366             * 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.
2367             * </p>
2368             *
2369             * @param start the lower bound of the range of asset vocabularies
2370             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2371             * @return the range of asset vocabularies
2372             * @throws SystemException if a system exception occurred
2373             */
2374            public List<AssetVocabulary> findAll(int start, int end)
2375                    throws SystemException {
2376                    return findAll(start, end, null);
2377            }
2378    
2379            /**
2380             * Returns an ordered range of all the asset vocabularies.
2381             *
2382             * <p>
2383             * 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.
2384             * </p>
2385             *
2386             * @param start the lower bound of the range of asset vocabularies
2387             * @param end the upper bound of the range of asset vocabularies (not inclusive)
2388             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2389             * @return the ordered range of asset vocabularies
2390             * @throws SystemException if a system exception occurred
2391             */
2392            public List<AssetVocabulary> findAll(int start, int end,
2393                    OrderByComparator orderByComparator) throws SystemException {
2394                    FinderPath finderPath = null;
2395                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2396    
2397                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2398                                    (orderByComparator == null)) {
2399                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2400                            finderArgs = FINDER_ARGS_EMPTY;
2401                    }
2402                    else {
2403                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2404                            finderArgs = new Object[] { start, end, orderByComparator };
2405                    }
2406    
2407                    List<AssetVocabulary> list = (List<AssetVocabulary>)FinderCacheUtil.getResult(finderPath,
2408                                    finderArgs, this);
2409    
2410                    if (list == null) {
2411                            StringBundler query = null;
2412                            String sql = null;
2413    
2414                            if (orderByComparator != null) {
2415                                    query = new StringBundler(2 +
2416                                                    (orderByComparator.getOrderByFields().length * 3));
2417    
2418                                    query.append(_SQL_SELECT_ASSETVOCABULARY);
2419    
2420                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2421                                            orderByComparator);
2422    
2423                                    sql = query.toString();
2424                            }
2425                            else {
2426                                    sql = _SQL_SELECT_ASSETVOCABULARY.concat(AssetVocabularyModelImpl.ORDER_BY_JPQL);
2427                            }
2428    
2429                            Session session = null;
2430    
2431                            try {
2432                                    session = openSession();
2433    
2434                                    Query q = session.createQuery(sql);
2435    
2436                                    if (orderByComparator == null) {
2437                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2438                                                            getDialect(), start, end, false);
2439    
2440                                            Collections.sort(list);
2441                                    }
2442                                    else {
2443                                            list = (List<AssetVocabulary>)QueryUtil.list(q,
2444                                                            getDialect(), start, end);
2445                                    }
2446                            }
2447                            catch (Exception e) {
2448                                    throw processException(e);
2449                            }
2450                            finally {
2451                                    if (list == null) {
2452                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2453                                    }
2454                                    else {
2455                                            cacheResult(list);
2456    
2457                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2458                                    }
2459    
2460                                    closeSession(session);
2461                            }
2462                    }
2463    
2464                    return list;
2465            }
2466    
2467            /**
2468             * Removes all the asset vocabularies where uuid = &#63; from the database.
2469             *
2470             * @param uuid the uuid
2471             * @throws SystemException if a system exception occurred
2472             */
2473            public void removeByUuid(String uuid) throws SystemException {
2474                    for (AssetVocabulary assetVocabulary : findByUuid(uuid)) {
2475                            remove(assetVocabulary);
2476                    }
2477            }
2478    
2479            /**
2480             * Removes the asset vocabulary where uuid = &#63; and groupId = &#63; from the database.
2481             *
2482             * @param uuid the uuid
2483             * @param groupId the group ID
2484             * @throws SystemException if a system exception occurred
2485             */
2486            public void removeByUUID_G(String uuid, long groupId)
2487                    throws NoSuchVocabularyException, SystemException {
2488                    AssetVocabulary assetVocabulary = findByUUID_G(uuid, groupId);
2489    
2490                    remove(assetVocabulary);
2491            }
2492    
2493            /**
2494             * Removes all the asset vocabularies where groupId = &#63; from the database.
2495             *
2496             * @param groupId the group ID
2497             * @throws SystemException if a system exception occurred
2498             */
2499            public void removeByGroupId(long groupId) throws SystemException {
2500                    for (AssetVocabulary assetVocabulary : findByGroupId(groupId)) {
2501                            remove(assetVocabulary);
2502                    }
2503            }
2504    
2505            /**
2506             * Removes all the asset vocabularies where companyId = &#63; from the database.
2507             *
2508             * @param companyId the company ID
2509             * @throws SystemException if a system exception occurred
2510             */
2511            public void removeByCompanyId(long companyId) throws SystemException {
2512                    for (AssetVocabulary assetVocabulary : findByCompanyId(companyId)) {
2513                            remove(assetVocabulary);
2514                    }
2515            }
2516    
2517            /**
2518             * Removes the asset vocabulary where groupId = &#63; and name = &#63; from the database.
2519             *
2520             * @param groupId the group ID
2521             * @param name the name
2522             * @throws SystemException if a system exception occurred
2523             */
2524            public void removeByG_N(long groupId, String name)
2525                    throws NoSuchVocabularyException, SystemException {
2526                    AssetVocabulary assetVocabulary = findByG_N(groupId, name);
2527    
2528                    remove(assetVocabulary);
2529            }
2530    
2531            /**
2532             * Removes all the asset vocabularies from the database.
2533             *
2534             * @throws SystemException if a system exception occurred
2535             */
2536            public void removeAll() throws SystemException {
2537                    for (AssetVocabulary assetVocabulary : findAll()) {
2538                            remove(assetVocabulary);
2539                    }
2540            }
2541    
2542            /**
2543             * Returns the number of asset vocabularies where uuid = &#63;.
2544             *
2545             * @param uuid the uuid
2546             * @return the number of matching asset vocabularies
2547             * @throws SystemException if a system exception occurred
2548             */
2549            public int countByUuid(String uuid) throws SystemException {
2550                    Object[] finderArgs = new Object[] { uuid };
2551    
2552                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2553                                    finderArgs, this);
2554    
2555                    if (count == null) {
2556                            StringBundler query = new StringBundler(2);
2557    
2558                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2559    
2560                            if (uuid == null) {
2561                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
2562                            }
2563                            else {
2564                                    if (uuid.equals(StringPool.BLANK)) {
2565                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
2566                                    }
2567                                    else {
2568                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
2569                                    }
2570                            }
2571    
2572                            String sql = query.toString();
2573    
2574                            Session session = null;
2575    
2576                            try {
2577                                    session = openSession();
2578    
2579                                    Query q = session.createQuery(sql);
2580    
2581                                    QueryPos qPos = QueryPos.getInstance(q);
2582    
2583                                    if (uuid != null) {
2584                                            qPos.add(uuid);
2585                                    }
2586    
2587                                    count = (Long)q.uniqueResult();
2588                            }
2589                            catch (Exception e) {
2590                                    throw processException(e);
2591                            }
2592                            finally {
2593                                    if (count == null) {
2594                                            count = Long.valueOf(0);
2595                                    }
2596    
2597                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2598                                            finderArgs, count);
2599    
2600                                    closeSession(session);
2601                            }
2602                    }
2603    
2604                    return count.intValue();
2605            }
2606    
2607            /**
2608             * Returns the number of asset vocabularies where uuid = &#63; and groupId = &#63;.
2609             *
2610             * @param uuid the uuid
2611             * @param groupId the group ID
2612             * @return the number of matching asset vocabularies
2613             * @throws SystemException if a system exception occurred
2614             */
2615            public int countByUUID_G(String uuid, long groupId)
2616                    throws SystemException {
2617                    Object[] finderArgs = new Object[] { uuid, groupId };
2618    
2619                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2620                                    finderArgs, this);
2621    
2622                    if (count == null) {
2623                            StringBundler query = new StringBundler(3);
2624    
2625                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2626    
2627                            if (uuid == null) {
2628                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2629                            }
2630                            else {
2631                                    if (uuid.equals(StringPool.BLANK)) {
2632                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2633                                    }
2634                                    else {
2635                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2636                                    }
2637                            }
2638    
2639                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2640    
2641                            String sql = query.toString();
2642    
2643                            Session session = null;
2644    
2645                            try {
2646                                    session = openSession();
2647    
2648                                    Query q = session.createQuery(sql);
2649    
2650                                    QueryPos qPos = QueryPos.getInstance(q);
2651    
2652                                    if (uuid != null) {
2653                                            qPos.add(uuid);
2654                                    }
2655    
2656                                    qPos.add(groupId);
2657    
2658                                    count = (Long)q.uniqueResult();
2659                            }
2660                            catch (Exception e) {
2661                                    throw processException(e);
2662                            }
2663                            finally {
2664                                    if (count == null) {
2665                                            count = Long.valueOf(0);
2666                                    }
2667    
2668                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2669                                            finderArgs, count);
2670    
2671                                    closeSession(session);
2672                            }
2673                    }
2674    
2675                    return count.intValue();
2676            }
2677    
2678            /**
2679             * Returns the number of asset vocabularies where groupId = &#63;.
2680             *
2681             * @param groupId the group ID
2682             * @return the number of matching asset vocabularies
2683             * @throws SystemException if a system exception occurred
2684             */
2685            public int countByGroupId(long groupId) throws SystemException {
2686                    Object[] finderArgs = new Object[] { groupId };
2687    
2688                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2689                                    finderArgs, this);
2690    
2691                    if (count == null) {
2692                            StringBundler query = new StringBundler(2);
2693    
2694                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2695    
2696                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2697    
2698                            String sql = query.toString();
2699    
2700                            Session session = null;
2701    
2702                            try {
2703                                    session = openSession();
2704    
2705                                    Query q = session.createQuery(sql);
2706    
2707                                    QueryPos qPos = QueryPos.getInstance(q);
2708    
2709                                    qPos.add(groupId);
2710    
2711                                    count = (Long)q.uniqueResult();
2712                            }
2713                            catch (Exception e) {
2714                                    throw processException(e);
2715                            }
2716                            finally {
2717                                    if (count == null) {
2718                                            count = Long.valueOf(0);
2719                                    }
2720    
2721                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2722                                            finderArgs, count);
2723    
2724                                    closeSession(session);
2725                            }
2726                    }
2727    
2728                    return count.intValue();
2729            }
2730    
2731            /**
2732             * Returns the number of asset vocabularies that the user has permission to view where groupId = &#63;.
2733             *
2734             * @param groupId the group ID
2735             * @return the number of matching asset vocabularies that the user has permission to view
2736             * @throws SystemException if a system exception occurred
2737             */
2738            public int filterCountByGroupId(long groupId) throws SystemException {
2739                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2740                            return countByGroupId(groupId);
2741                    }
2742    
2743                    StringBundler query = new StringBundler(2);
2744    
2745                    query.append(_FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE);
2746    
2747                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2748    
2749                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2750                                    AssetVocabulary.class.getName(),
2751                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2752    
2753                    Session session = null;
2754    
2755                    try {
2756                            session = openSession();
2757    
2758                            SQLQuery q = session.createSQLQuery(sql);
2759    
2760                            q.addScalar(COUNT_COLUMN_NAME,
2761                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2762    
2763                            QueryPos qPos = QueryPos.getInstance(q);
2764    
2765                            qPos.add(groupId);
2766    
2767                            Long count = (Long)q.uniqueResult();
2768    
2769                            return count.intValue();
2770                    }
2771                    catch (Exception e) {
2772                            throw processException(e);
2773                    }
2774                    finally {
2775                            closeSession(session);
2776                    }
2777            }
2778    
2779            /**
2780             * Returns the number of asset vocabularies where companyId = &#63;.
2781             *
2782             * @param companyId the company ID
2783             * @return the number of matching asset vocabularies
2784             * @throws SystemException if a system exception occurred
2785             */
2786            public int countByCompanyId(long companyId) throws SystemException {
2787                    Object[] finderArgs = new Object[] { companyId };
2788    
2789                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2790                                    finderArgs, this);
2791    
2792                    if (count == null) {
2793                            StringBundler query = new StringBundler(2);
2794    
2795                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2796    
2797                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2798    
2799                            String sql = query.toString();
2800    
2801                            Session session = null;
2802    
2803                            try {
2804                                    session = openSession();
2805    
2806                                    Query q = session.createQuery(sql);
2807    
2808                                    QueryPos qPos = QueryPos.getInstance(q);
2809    
2810                                    qPos.add(companyId);
2811    
2812                                    count = (Long)q.uniqueResult();
2813                            }
2814                            catch (Exception e) {
2815                                    throw processException(e);
2816                            }
2817                            finally {
2818                                    if (count == null) {
2819                                            count = Long.valueOf(0);
2820                                    }
2821    
2822                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2823                                            finderArgs, count);
2824    
2825                                    closeSession(session);
2826                            }
2827                    }
2828    
2829                    return count.intValue();
2830            }
2831    
2832            /**
2833             * Returns the number of asset vocabularies where groupId = &#63; and name = &#63;.
2834             *
2835             * @param groupId the group ID
2836             * @param name the name
2837             * @return the number of matching asset vocabularies
2838             * @throws SystemException if a system exception occurred
2839             */
2840            public int countByG_N(long groupId, String name) throws SystemException {
2841                    Object[] finderArgs = new Object[] { groupId, name };
2842    
2843                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2844                                    finderArgs, this);
2845    
2846                    if (count == null) {
2847                            StringBundler query = new StringBundler(3);
2848    
2849                            query.append(_SQL_COUNT_ASSETVOCABULARY_WHERE);
2850    
2851                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2852    
2853                            if (name == null) {
2854                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
2855                            }
2856                            else {
2857                                    if (name.equals(StringPool.BLANK)) {
2858                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
2859                                    }
2860                                    else {
2861                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
2862                                    }
2863                            }
2864    
2865                            String sql = query.toString();
2866    
2867                            Session session = null;
2868    
2869                            try {
2870                                    session = openSession();
2871    
2872                                    Query q = session.createQuery(sql);
2873    
2874                                    QueryPos qPos = QueryPos.getInstance(q);
2875    
2876                                    qPos.add(groupId);
2877    
2878                                    if (name != null) {
2879                                            qPos.add(name);
2880                                    }
2881    
2882                                    count = (Long)q.uniqueResult();
2883                            }
2884                            catch (Exception e) {
2885                                    throw processException(e);
2886                            }
2887                            finally {
2888                                    if (count == null) {
2889                                            count = Long.valueOf(0);
2890                                    }
2891    
2892                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2893                                            count);
2894    
2895                                    closeSession(session);
2896                            }
2897                    }
2898    
2899                    return count.intValue();
2900            }
2901    
2902            /**
2903             * Returns the number of asset vocabularies.
2904             *
2905             * @return the number of asset vocabularies
2906             * @throws SystemException if a system exception occurred
2907             */
2908            public int countAll() throws SystemException {
2909                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2910                                    FINDER_ARGS_EMPTY, this);
2911    
2912                    if (count == null) {
2913                            Session session = null;
2914    
2915                            try {
2916                                    session = openSession();
2917    
2918                                    Query q = session.createQuery(_SQL_COUNT_ASSETVOCABULARY);
2919    
2920                                    count = (Long)q.uniqueResult();
2921                            }
2922                            catch (Exception e) {
2923                                    throw processException(e);
2924                            }
2925                            finally {
2926                                    if (count == null) {
2927                                            count = Long.valueOf(0);
2928                                    }
2929    
2930                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2931                                            FINDER_ARGS_EMPTY, count);
2932    
2933                                    closeSession(session);
2934                            }
2935                    }
2936    
2937                    return count.intValue();
2938            }
2939    
2940            /**
2941             * Initializes the asset vocabulary persistence.
2942             */
2943            public void afterPropertiesSet() {
2944                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2945                                            com.liferay.portal.util.PropsUtil.get(
2946                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetVocabulary")));
2947    
2948                    if (listenerClassNames.length > 0) {
2949                            try {
2950                                    List<ModelListener<AssetVocabulary>> listenersList = new ArrayList<ModelListener<AssetVocabulary>>();
2951    
2952                                    for (String listenerClassName : listenerClassNames) {
2953                                            listenersList.add((ModelListener<AssetVocabulary>)InstanceFactory.newInstance(
2954                                                            listenerClassName));
2955                                    }
2956    
2957                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2958                            }
2959                            catch (Exception e) {
2960                                    _log.error(e);
2961                            }
2962                    }
2963            }
2964    
2965            public void destroy() {
2966                    EntityCacheUtil.removeCache(AssetVocabularyImpl.class.getName());
2967                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2968                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2969            }
2970    
2971            @BeanReference(type = AssetCategoryPersistence.class)
2972            protected AssetCategoryPersistence assetCategoryPersistence;
2973            @BeanReference(type = AssetCategoryPropertyPersistence.class)
2974            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2975            @BeanReference(type = AssetEntryPersistence.class)
2976            protected AssetEntryPersistence assetEntryPersistence;
2977            @BeanReference(type = AssetLinkPersistence.class)
2978            protected AssetLinkPersistence assetLinkPersistence;
2979            @BeanReference(type = AssetTagPersistence.class)
2980            protected AssetTagPersistence assetTagPersistence;
2981            @BeanReference(type = AssetTagPropertyPersistence.class)
2982            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2983            @BeanReference(type = AssetTagStatsPersistence.class)
2984            protected AssetTagStatsPersistence assetTagStatsPersistence;
2985            @BeanReference(type = AssetVocabularyPersistence.class)
2986            protected AssetVocabularyPersistence assetVocabularyPersistence;
2987            @BeanReference(type = GroupPersistence.class)
2988            protected GroupPersistence groupPersistence;
2989            @BeanReference(type = ResourcePersistence.class)
2990            protected ResourcePersistence resourcePersistence;
2991            @BeanReference(type = UserPersistence.class)
2992            protected UserPersistence userPersistence;
2993            private static final String _SQL_SELECT_ASSETVOCABULARY = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary";
2994            private static final String _SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT assetVocabulary FROM AssetVocabulary assetVocabulary WHERE ";
2995            private static final String _SQL_COUNT_ASSETVOCABULARY = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary";
2996            private static final String _SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(assetVocabulary) FROM AssetVocabulary assetVocabulary WHERE ";
2997            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetVocabulary.uuid IS NULL";
2998            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetVocabulary.uuid = ?";
2999            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?)";
3000            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetVocabulary.uuid IS NULL AND ";
3001            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetVocabulary.uuid = ? AND ";
3002            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetVocabulary.uuid IS NULL OR assetVocabulary.uuid = ?) AND ";
3003            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetVocabulary.groupId = ?";
3004            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetVocabulary.groupId = ?";
3005            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetVocabulary.companyId = ?";
3006            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "assetVocabulary.groupId = ? AND ";
3007            private static final String _FINDER_COLUMN_G_N_NAME_1 = "assetVocabulary.name IS NULL";
3008            private static final String _FINDER_COLUMN_G_N_NAME_2 = "assetVocabulary.name = ?";
3009            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(assetVocabulary.name IS NULL OR assetVocabulary.name = ?)";
3010            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetVocabulary.vocabularyId";
3011            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_WHERE = "SELECT DISTINCT {assetVocabulary.*} FROM AssetVocabulary assetVocabulary WHERE ";
3012            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_1 =
3013                    "SELECT {AssetVocabulary.*} FROM (SELECT DISTINCT assetVocabulary.vocabularyId FROM AssetVocabulary assetVocabulary WHERE ";
3014            private static final String _FILTER_SQL_SELECT_ASSETVOCABULARY_NO_INLINE_DISTINCT_WHERE_2 =
3015                    ") TEMP_TABLE INNER JOIN AssetVocabulary ON TEMP_TABLE.vocabularyId = AssetVocabulary.vocabularyId";
3016            private static final String _FILTER_SQL_COUNT_ASSETVOCABULARY_WHERE = "SELECT COUNT(DISTINCT assetVocabulary.vocabularyId) AS COUNT_VALUE FROM AssetVocabulary assetVocabulary WHERE ";
3017            private static final String _FILTER_ENTITY_ALIAS = "assetVocabulary";
3018            private static final String _FILTER_ENTITY_TABLE = "AssetVocabulary";
3019            private static final String _ORDER_BY_ENTITY_ALIAS = "assetVocabulary.";
3020            private static final String _ORDER_BY_ENTITY_TABLE = "AssetVocabulary.";
3021            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetVocabulary exists with the primary key ";
3022            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetVocabulary exists with the key {";
3023            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3024            private static Log _log = LogFactoryUtil.getLog(AssetVocabularyPersistenceImpl.class);
3025            private static AssetVocabulary _nullAssetVocabulary = new AssetVocabularyImpl() {
3026                            @Override
3027                            public Object clone() {
3028                                    return this;
3029                            }
3030    
3031                            @Override
3032                            public CacheModel<AssetVocabulary> toCacheModel() {
3033                                    return _nullAssetVocabularyCacheModel;
3034                            }
3035                    };
3036    
3037            private static CacheModel<AssetVocabulary> _nullAssetVocabularyCacheModel = new CacheModel<AssetVocabulary>() {
3038                            public AssetVocabulary toEntityModel() {
3039                                    return _nullAssetVocabulary;
3040                            }
3041                    };
3042    }