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.jdbc.MappingSqlQuery;
021    import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022    import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027    import com.liferay.portal.kernel.dao.orm.FinderPath;
028    import com.liferay.portal.kernel.dao.orm.Query;
029    import com.liferay.portal.kernel.dao.orm.QueryPos;
030    import com.liferay.portal.kernel.dao.orm.QueryUtil;
031    import com.liferay.portal.kernel.dao.orm.SQLQuery;
032    import com.liferay.portal.kernel.dao.orm.Session;
033    import com.liferay.portal.kernel.exception.SystemException;
034    import com.liferay.portal.kernel.log.Log;
035    import com.liferay.portal.kernel.log.LogFactoryUtil;
036    import com.liferay.portal.kernel.util.GetterUtil;
037    import com.liferay.portal.kernel.util.InstanceFactory;
038    import com.liferay.portal.kernel.util.OrderByComparator;
039    import com.liferay.portal.kernel.util.SetUtil;
040    import com.liferay.portal.kernel.util.StringBundler;
041    import com.liferay.portal.kernel.util.StringPool;
042    import com.liferay.portal.kernel.util.StringUtil;
043    import com.liferay.portal.kernel.util.Validator;
044    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045    import com.liferay.portal.model.CacheModel;
046    import com.liferay.portal.model.ModelListener;
047    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048    import com.liferay.portal.service.persistence.BatchSessionUtil;
049    import com.liferay.portal.service.persistence.ResourcePersistence;
050    import com.liferay.portal.service.persistence.UserPersistence;
051    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052    
053    import com.liferay.portlet.asset.NoSuchCategoryException;
054    import com.liferay.portlet.asset.model.AssetCategory;
055    import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
056    import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
057    
058    import java.io.Serializable;
059    
060    import java.util.ArrayList;
061    import java.util.Collections;
062    import java.util.List;
063    import java.util.Set;
064    
065    /**
066     * The persistence implementation for the asset category service.
067     *
068     * <p>
069     * Caching information and settings can be found in <code>portal.properties</code>
070     * </p>
071     *
072     * @author Brian Wing Shun Chan
073     * @see AssetCategoryPersistence
074     * @see AssetCategoryUtil
075     * @generated
076     */
077    public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
078            implements AssetCategoryPersistence {
079            /*
080             * NOTE FOR DEVELOPERS:
081             *
082             * Never modify or reference this class directly. Always use {@link AssetCategoryUtil} to access the asset category persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
083             */
084            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
085            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
086                    ".List1";
087            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
088                    ".List2";
089            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
090                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
091                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
092                            "findByUuid",
093                            new String[] {
094                                    String.class.getName(),
095                                    
096                            "java.lang.Integer", "java.lang.Integer",
097                                    "com.liferay.portal.kernel.util.OrderByComparator"
098                            });
099            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
100                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
101                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
102                            "findByUuid", new String[] { String.class.getName() },
103                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
105                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107                            new String[] { String.class.getName() });
108            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
109                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
110                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
111                            new String[] { String.class.getName(), Long.class.getName() },
112                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
113                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
114            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
115                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
117                            new String[] { String.class.getName(), Long.class.getName() });
118            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
119                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
120                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
121                            "findByGroupId",
122                            new String[] {
123                                    Long.class.getName(),
124                                    
125                            "java.lang.Integer", "java.lang.Integer",
126                                    "com.liferay.portal.kernel.util.OrderByComparator"
127                            });
128            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
129                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
130                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
131                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
132                            "findByGroupId", new String[] { Long.class.getName() },
133                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
134            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
135                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
137                            new String[] { Long.class.getName() });
138            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
139                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
140                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
141                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
142                            "findByParentCategoryId",
143                            new String[] {
144                                    Long.class.getName(),
145                                    
146                            "java.lang.Integer", "java.lang.Integer",
147                                    "com.liferay.portal.kernel.util.OrderByComparator"
148                            });
149            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
150                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
151                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
152                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
153                            "findByParentCategoryId", new String[] { Long.class.getName() },
154                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
155            public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
156                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
158                            "countByParentCategoryId", new String[] { Long.class.getName() });
159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
160                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
161                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
162                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
163                            "findByVocabularyId",
164                            new String[] {
165                                    Long.class.getName(),
166                                    
167                            "java.lang.Integer", "java.lang.Integer",
168                                    "com.liferay.portal.kernel.util.OrderByComparator"
169                            });
170            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
171                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
172                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
173                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
174                            "findByVocabularyId", new String[] { Long.class.getName() },
175                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
176            public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
177                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
178                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
179                            new String[] { Long.class.getName() });
180            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
181                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
182                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
183                            "findByG_V",
184                            new String[] {
185                                    Long.class.getName(), Long.class.getName(),
186                                    
187                            "java.lang.Integer", "java.lang.Integer",
188                                    "com.liferay.portal.kernel.util.OrderByComparator"
189                            });
190            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
191                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
192                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
193                            "findByG_V",
194                            new String[] { Long.class.getName(), Long.class.getName() },
195                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
196                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
197            public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
198                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
199                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
200                            new String[] { Long.class.getName(), Long.class.getName() });
201            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
202                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
203                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
204                            "findByP_N",
205                            new String[] {
206                                    Long.class.getName(), String.class.getName(),
207                                    
208                            "java.lang.Integer", "java.lang.Integer",
209                                    "com.liferay.portal.kernel.util.OrderByComparator"
210                            });
211            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
212                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
213                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
214                            "findByP_N",
215                            new String[] { Long.class.getName(), String.class.getName() },
216                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
217                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
218            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
219                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
220                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
221                            new String[] { Long.class.getName(), String.class.getName() });
222            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
223                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
224                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
225                            "findByP_V",
226                            new String[] {
227                                    Long.class.getName(), Long.class.getName(),
228                                    
229                            "java.lang.Integer", "java.lang.Integer",
230                                    "com.liferay.portal.kernel.util.OrderByComparator"
231                            });
232            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
233                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
234                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
235                            "findByP_V",
236                            new String[] { Long.class.getName(), Long.class.getName() },
237                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
238                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
239            public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
240                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
241                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
242                            new String[] { Long.class.getName(), Long.class.getName() });
243            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
244                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
245                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
246                            "findByN_V",
247                            new String[] {
248                                    String.class.getName(), Long.class.getName(),
249                                    
250                            "java.lang.Integer", "java.lang.Integer",
251                                    "com.liferay.portal.kernel.util.OrderByComparator"
252                            });
253            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
254                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
255                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
256                            "findByN_V",
257                            new String[] { String.class.getName(), Long.class.getName() },
258                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
259                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
260            public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
261                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
262                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
263                            new String[] { String.class.getName(), Long.class.getName() });
264            public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
265                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
266                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
267                            new String[] {
268                                    Long.class.getName(), String.class.getName(),
269                                    Long.class.getName()
270                            },
271                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
272                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
273                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
274            public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
275                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
276                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
277                            new String[] {
278                                    Long.class.getName(), String.class.getName(),
279                                    Long.class.getName()
280                            });
281            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
282                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
283                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
284                            "findAll", new String[0]);
285            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
286                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
287                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
288                            "findAll", new String[0]);
289            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
290                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
291                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
292    
293            /**
294             * Caches the asset category in the entity cache if it is enabled.
295             *
296             * @param assetCategory the asset category
297             */
298            public void cacheResult(AssetCategory assetCategory) {
299                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
300                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
301                            assetCategory);
302    
303                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
304                            new Object[] {
305                                    assetCategory.getUuid(),
306                                    Long.valueOf(assetCategory.getGroupId())
307                            }, assetCategory);
308    
309                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
310                            new Object[] {
311                                    Long.valueOf(assetCategory.getParentCategoryId()),
312                                    
313                            assetCategory.getName(),
314                                    Long.valueOf(assetCategory.getVocabularyId())
315                            }, assetCategory);
316    
317                    assetCategory.resetOriginalValues();
318            }
319    
320            /**
321             * Caches the asset categories in the entity cache if it is enabled.
322             *
323             * @param assetCategories the asset categories
324             */
325            public void cacheResult(List<AssetCategory> assetCategories) {
326                    for (AssetCategory assetCategory : assetCategories) {
327                            if (EntityCacheUtil.getResult(
328                                                    AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
329                                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
330                                    cacheResult(assetCategory);
331                            }
332                            else {
333                                    assetCategory.resetOriginalValues();
334                            }
335                    }
336            }
337    
338            /**
339             * Clears the cache for all asset categories.
340             *
341             * <p>
342             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
343             * </p>
344             */
345            @Override
346            public void clearCache() {
347                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
348                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
349                    }
350    
351                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
352    
353                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
354                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
355                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
356            }
357    
358            /**
359             * Clears the cache for the asset category.
360             *
361             * <p>
362             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
363             * </p>
364             */
365            @Override
366            public void clearCache(AssetCategory assetCategory) {
367                    EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
368                            AssetCategoryImpl.class, assetCategory.getPrimaryKey());
369    
370                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372    
373                    clearUniqueFindersCache(assetCategory);
374            }
375    
376            @Override
377            public void clearCache(List<AssetCategory> assetCategories) {
378                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
379                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
380    
381                    for (AssetCategory assetCategory : assetCategories) {
382                            EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
383                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey());
384    
385                            clearUniqueFindersCache(assetCategory);
386                    }
387            }
388    
389            protected void clearUniqueFindersCache(AssetCategory assetCategory) {
390                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
391                            new Object[] {
392                                    assetCategory.getUuid(),
393                                    Long.valueOf(assetCategory.getGroupId())
394                            });
395    
396                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
397                            new Object[] {
398                                    Long.valueOf(assetCategory.getParentCategoryId()),
399                                    
400                            assetCategory.getName(),
401                                    Long.valueOf(assetCategory.getVocabularyId())
402                            });
403            }
404    
405            /**
406             * Creates a new asset category with the primary key. Does not add the asset category to the database.
407             *
408             * @param categoryId the primary key for the new asset category
409             * @return the new asset category
410             */
411            public AssetCategory create(long categoryId) {
412                    AssetCategory assetCategory = new AssetCategoryImpl();
413    
414                    assetCategory.setNew(true);
415                    assetCategory.setPrimaryKey(categoryId);
416    
417                    String uuid = PortalUUIDUtil.generate();
418    
419                    assetCategory.setUuid(uuid);
420    
421                    return assetCategory;
422            }
423    
424            /**
425             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
426             *
427             * @param categoryId the primary key of the asset category
428             * @return the asset category that was removed
429             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
430             * @throws SystemException if a system exception occurred
431             */
432            public AssetCategory remove(long categoryId)
433                    throws NoSuchCategoryException, SystemException {
434                    return remove(Long.valueOf(categoryId));
435            }
436    
437            /**
438             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
439             *
440             * @param primaryKey the primary key of the asset category
441             * @return the asset category that was removed
442             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
443             * @throws SystemException if a system exception occurred
444             */
445            @Override
446            public AssetCategory remove(Serializable primaryKey)
447                    throws NoSuchCategoryException, SystemException {
448                    Session session = null;
449    
450                    try {
451                            session = openSession();
452    
453                            AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
454                                            primaryKey);
455    
456                            if (assetCategory == null) {
457                                    if (_log.isWarnEnabled()) {
458                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
459                                    }
460    
461                                    throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
462                                            primaryKey);
463                            }
464    
465                            return remove(assetCategory);
466                    }
467                    catch (NoSuchCategoryException nsee) {
468                            throw nsee;
469                    }
470                    catch (Exception e) {
471                            throw processException(e);
472                    }
473                    finally {
474                            closeSession(session);
475                    }
476            }
477    
478            @Override
479            protected AssetCategory removeImpl(AssetCategory assetCategory)
480                    throws SystemException {
481                    assetCategory = toUnwrappedModel(assetCategory);
482    
483                    try {
484                            clearAssetEntries.clear(assetCategory.getPrimaryKey());
485                    }
486                    catch (Exception e) {
487                            throw processException(e);
488                    }
489                    finally {
490                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
491                    }
492    
493                    shrinkTree(assetCategory);
494    
495                    Session session = null;
496    
497                    try {
498                            session = openSession();
499    
500                            BatchSessionUtil.delete(session, assetCategory);
501                    }
502                    catch (Exception e) {
503                            throw processException(e);
504                    }
505                    finally {
506                            closeSession(session);
507                    }
508    
509                    clearCache(assetCategory);
510    
511                    return assetCategory;
512            }
513    
514            @Override
515            public AssetCategory updateImpl(
516                    com.liferay.portlet.asset.model.AssetCategory assetCategory,
517                    boolean merge) throws SystemException {
518                    assetCategory = toUnwrappedModel(assetCategory);
519    
520                    boolean isNew = assetCategory.isNew();
521    
522                    AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
523    
524                    if (Validator.isNull(assetCategory.getUuid())) {
525                            String uuid = PortalUUIDUtil.generate();
526    
527                            assetCategory.setUuid(uuid);
528                    }
529    
530                    if (isNew) {
531                            expandTree(assetCategory, null);
532                    }
533                    else {
534                            if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
535                                    List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
536    
537                                    shrinkTree(assetCategory);
538                                    expandTree(assetCategory, childrenCategoryIds);
539                            }
540                    }
541    
542                    Session session = null;
543    
544                    try {
545                            session = openSession();
546    
547                            BatchSessionUtil.update(session, assetCategory, merge);
548    
549                            assetCategory.setNew(false);
550                    }
551                    catch (Exception e) {
552                            throw processException(e);
553                    }
554                    finally {
555                            closeSession(session);
556                    }
557    
558                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
559    
560                    if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
561                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
562                    }
563                    else {
564                            if ((assetCategoryModelImpl.getColumnBitmask() &
565                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
566                                    Object[] args = new Object[] {
567                                                    assetCategoryModelImpl.getOriginalUuid()
568                                            };
569    
570                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
571                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
572                                            args);
573    
574                                    args = new Object[] { assetCategoryModelImpl.getUuid() };
575    
576                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
577                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
578                                            args);
579                            }
580    
581                            if ((assetCategoryModelImpl.getColumnBitmask() &
582                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
583                                    Object[] args = new Object[] {
584                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
585                                            };
586    
587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
588                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
589                                            args);
590    
591                                    args = new Object[] {
592                                                    Long.valueOf(assetCategoryModelImpl.getGroupId())
593                                            };
594    
595                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
596                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
597                                            args);
598                            }
599    
600                            if ((assetCategoryModelImpl.getColumnBitmask() &
601                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
602                                    Object[] args = new Object[] {
603                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
604                                            };
605    
606                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
607                                            args);
608                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
609                                            args);
610    
611                                    args = new Object[] {
612                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
613                                            };
614    
615                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
616                                            args);
617                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
618                                            args);
619                            }
620    
621                            if ((assetCategoryModelImpl.getColumnBitmask() &
622                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
623                                    Object[] args = new Object[] {
624                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
625                                            };
626    
627                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
628                                            args);
629                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
630                                            args);
631    
632                                    args = new Object[] {
633                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
634                                            };
635    
636                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
637                                            args);
638                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
639                                            args);
640                            }
641    
642                            if ((assetCategoryModelImpl.getColumnBitmask() &
643                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
644                                    Object[] args = new Object[] {
645                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
646                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
647                                            };
648    
649                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
650                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
651                                            args);
652    
653                                    args = new Object[] {
654                                                    Long.valueOf(assetCategoryModelImpl.getGroupId()),
655                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
656                                            };
657    
658                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
659                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
660                                            args);
661                            }
662    
663                            if ((assetCategoryModelImpl.getColumnBitmask() &
664                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
665                                    Object[] args = new Object[] {
666                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
667                                                    
668                                                    assetCategoryModelImpl.getOriginalName()
669                                            };
670    
671                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
672                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
673                                            args);
674    
675                                    args = new Object[] {
676                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
677                                                    
678                                                    assetCategoryModelImpl.getName()
679                                            };
680    
681                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
682                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
683                                            args);
684                            }
685    
686                            if ((assetCategoryModelImpl.getColumnBitmask() &
687                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
688                                    Object[] args = new Object[] {
689                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
690                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
691                                            };
692    
693                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
694                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
695                                            args);
696    
697                                    args = new Object[] {
698                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
699                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
700                                            };
701    
702                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
703                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
704                                            args);
705                            }
706    
707                            if ((assetCategoryModelImpl.getColumnBitmask() &
708                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
709                                    Object[] args = new Object[] {
710                                                    assetCategoryModelImpl.getOriginalName(),
711                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
712                                            };
713    
714                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
715                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
716                                            args);
717    
718                                    args = new Object[] {
719                                                    assetCategoryModelImpl.getName(),
720                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
721                                            };
722    
723                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
724                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
725                                            args);
726                            }
727                    }
728    
729                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
730                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
731                            assetCategory);
732    
733                    if (isNew) {
734                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
735                                    new Object[] {
736                                            assetCategory.getUuid(),
737                                            Long.valueOf(assetCategory.getGroupId())
738                                    }, assetCategory);
739    
740                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
741                                    new Object[] {
742                                            Long.valueOf(assetCategory.getParentCategoryId()),
743                                            
744                                    assetCategory.getName(),
745                                            Long.valueOf(assetCategory.getVocabularyId())
746                                    }, assetCategory);
747                    }
748                    else {
749                            if ((assetCategoryModelImpl.getColumnBitmask() &
750                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
751                                    Object[] args = new Object[] {
752                                                    assetCategoryModelImpl.getOriginalUuid(),
753                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
754                                            };
755    
756                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
757                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
758    
759                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
760                                            new Object[] {
761                                                    assetCategory.getUuid(),
762                                                    Long.valueOf(assetCategory.getGroupId())
763                                            }, assetCategory);
764                            }
765    
766                            if ((assetCategoryModelImpl.getColumnBitmask() &
767                                            FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
768                                    Object[] args = new Object[] {
769                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
770                                                    
771                                                    assetCategoryModelImpl.getOriginalName(),
772                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
773                                            };
774    
775                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
776                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
777    
778                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
779                                            new Object[] {
780                                                    Long.valueOf(assetCategory.getParentCategoryId()),
781                                                    
782                                            assetCategory.getName(),
783                                                    Long.valueOf(assetCategory.getVocabularyId())
784                                            }, assetCategory);
785                            }
786                    }
787    
788                    return assetCategory;
789            }
790    
791            protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
792                    if (assetCategory instanceof AssetCategoryImpl) {
793                            return assetCategory;
794                    }
795    
796                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
797    
798                    assetCategoryImpl.setNew(assetCategory.isNew());
799                    assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
800    
801                    assetCategoryImpl.setUuid(assetCategory.getUuid());
802                    assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
803                    assetCategoryImpl.setGroupId(assetCategory.getGroupId());
804                    assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
805                    assetCategoryImpl.setUserId(assetCategory.getUserId());
806                    assetCategoryImpl.setUserName(assetCategory.getUserName());
807                    assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
808                    assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
809                    assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
810                    assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
811                    assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
812                    assetCategoryImpl.setName(assetCategory.getName());
813                    assetCategoryImpl.setTitle(assetCategory.getTitle());
814                    assetCategoryImpl.setDescription(assetCategory.getDescription());
815                    assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
816    
817                    return assetCategoryImpl;
818            }
819    
820            /**
821             * Returns the asset category with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
822             *
823             * @param primaryKey the primary key of the asset category
824             * @return the asset category
825             * @throws com.liferay.portal.NoSuchModelException if a asset category with the primary key could not be found
826             * @throws SystemException if a system exception occurred
827             */
828            @Override
829            public AssetCategory findByPrimaryKey(Serializable primaryKey)
830                    throws NoSuchModelException, SystemException {
831                    return findByPrimaryKey(((Long)primaryKey).longValue());
832            }
833    
834            /**
835             * Returns the asset category with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
836             *
837             * @param categoryId the primary key of the asset category
838             * @return the asset category
839             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
840             * @throws SystemException if a system exception occurred
841             */
842            public AssetCategory findByPrimaryKey(long categoryId)
843                    throws NoSuchCategoryException, SystemException {
844                    AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
845    
846                    if (assetCategory == null) {
847                            if (_log.isWarnEnabled()) {
848                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
849                            }
850    
851                            throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
852                                    categoryId);
853                    }
854    
855                    return assetCategory;
856            }
857    
858            /**
859             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
860             *
861             * @param primaryKey the primary key of the asset category
862             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
863             * @throws SystemException if a system exception occurred
864             */
865            @Override
866            public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
867                    throws SystemException {
868                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
869            }
870    
871            /**
872             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
873             *
874             * @param categoryId the primary key of the asset category
875             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
876             * @throws SystemException if a system exception occurred
877             */
878            public AssetCategory fetchByPrimaryKey(long categoryId)
879                    throws SystemException {
880                    AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
881                                    AssetCategoryImpl.class, categoryId);
882    
883                    if (assetCategory == _nullAssetCategory) {
884                            return null;
885                    }
886    
887                    if (assetCategory == null) {
888                            Session session = null;
889    
890                            boolean hasException = false;
891    
892                            try {
893                                    session = openSession();
894    
895                                    assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
896                                                    Long.valueOf(categoryId));
897                            }
898                            catch (Exception e) {
899                                    hasException = true;
900    
901                                    throw processException(e);
902                            }
903                            finally {
904                                    if (assetCategory != null) {
905                                            cacheResult(assetCategory);
906                                    }
907                                    else if (!hasException) {
908                                            EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
909                                                    AssetCategoryImpl.class, categoryId, _nullAssetCategory);
910                                    }
911    
912                                    closeSession(session);
913                            }
914                    }
915    
916                    return assetCategory;
917            }
918    
919            /**
920             * Returns all the asset categories where uuid = &#63;.
921             *
922             * @param uuid the uuid
923             * @return the matching asset categories
924             * @throws SystemException if a system exception occurred
925             */
926            public List<AssetCategory> findByUuid(String uuid)
927                    throws SystemException {
928                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
929            }
930    
931            /**
932             * Returns a range of all the asset categories where uuid = &#63;.
933             *
934             * <p>
935             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
936             * </p>
937             *
938             * @param uuid the uuid
939             * @param start the lower bound of the range of asset categories
940             * @param end the upper bound of the range of asset categories (not inclusive)
941             * @return the range of matching asset categories
942             * @throws SystemException if a system exception occurred
943             */
944            public List<AssetCategory> findByUuid(String uuid, int start, int end)
945                    throws SystemException {
946                    return findByUuid(uuid, start, end, null);
947            }
948    
949            /**
950             * Returns an ordered range of all the asset categories where uuid = &#63;.
951             *
952             * <p>
953             * 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.
954             * </p>
955             *
956             * @param uuid the uuid
957             * @param start the lower bound of the range of asset categories
958             * @param end the upper bound of the range of asset categories (not inclusive)
959             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
960             * @return the ordered range of matching asset categories
961             * @throws SystemException if a system exception occurred
962             */
963            public List<AssetCategory> findByUuid(String uuid, int start, int end,
964                    OrderByComparator orderByComparator) throws SystemException {
965                    FinderPath finderPath = null;
966                    Object[] finderArgs = null;
967    
968                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
969                                    (orderByComparator == null)) {
970                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
971                            finderArgs = new Object[] { uuid };
972                    }
973                    else {
974                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
975                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
976                    }
977    
978                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
979                                    finderArgs, this);
980    
981                    if ((list != null) && !list.isEmpty()) {
982                            for (AssetCategory assetCategory : list) {
983                                    if (!Validator.equals(uuid, assetCategory.getUuid())) {
984                                            list = null;
985    
986                                            break;
987                                    }
988                            }
989                    }
990    
991                    if (list == null) {
992                            StringBundler query = null;
993    
994                            if (orderByComparator != null) {
995                                    query = new StringBundler(3 +
996                                                    (orderByComparator.getOrderByFields().length * 3));
997                            }
998                            else {
999                                    query = new StringBundler(3);
1000                            }
1001    
1002                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1003    
1004                            if (uuid == null) {
1005                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1006                            }
1007                            else {
1008                                    if (uuid.equals(StringPool.BLANK)) {
1009                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1010                                    }
1011                                    else {
1012                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1013                                    }
1014                            }
1015    
1016                            if (orderByComparator != null) {
1017                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1018                                            orderByComparator);
1019                            }
1020    
1021                            else {
1022                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1023                            }
1024    
1025                            String sql = query.toString();
1026    
1027                            Session session = null;
1028    
1029                            try {
1030                                    session = openSession();
1031    
1032                                    Query q = session.createQuery(sql);
1033    
1034                                    QueryPos qPos = QueryPos.getInstance(q);
1035    
1036                                    if (uuid != null) {
1037                                            qPos.add(uuid);
1038                                    }
1039    
1040                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1041                                                    start, end);
1042                            }
1043                            catch (Exception e) {
1044                                    throw processException(e);
1045                            }
1046                            finally {
1047                                    if (list == null) {
1048                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1049                                    }
1050                                    else {
1051                                            cacheResult(list);
1052    
1053                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1054                                    }
1055    
1056                                    closeSession(session);
1057                            }
1058                    }
1059    
1060                    return list;
1061            }
1062    
1063            /**
1064             * Returns the first asset category in the ordered set where uuid = &#63;.
1065             *
1066             * <p>
1067             * 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.
1068             * </p>
1069             *
1070             * @param uuid the uuid
1071             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1072             * @return the first matching asset category
1073             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1074             * @throws SystemException if a system exception occurred
1075             */
1076            public AssetCategory findByUuid_First(String uuid,
1077                    OrderByComparator orderByComparator)
1078                    throws NoSuchCategoryException, SystemException {
1079                    List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1080    
1081                    if (list.isEmpty()) {
1082                            StringBundler msg = new StringBundler(4);
1083    
1084                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1085    
1086                            msg.append("uuid=");
1087                            msg.append(uuid);
1088    
1089                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1090    
1091                            throw new NoSuchCategoryException(msg.toString());
1092                    }
1093                    else {
1094                            return list.get(0);
1095                    }
1096            }
1097    
1098            /**
1099             * Returns the last asset category in the ordered set where uuid = &#63;.
1100             *
1101             * <p>
1102             * 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.
1103             * </p>
1104             *
1105             * @param uuid the uuid
1106             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1107             * @return the last matching asset category
1108             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1109             * @throws SystemException if a system exception occurred
1110             */
1111            public AssetCategory findByUuid_Last(String uuid,
1112                    OrderByComparator orderByComparator)
1113                    throws NoSuchCategoryException, SystemException {
1114                    int count = countByUuid(uuid);
1115    
1116                    List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1117                                    orderByComparator);
1118    
1119                    if (list.isEmpty()) {
1120                            StringBundler msg = new StringBundler(4);
1121    
1122                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1123    
1124                            msg.append("uuid=");
1125                            msg.append(uuid);
1126    
1127                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1128    
1129                            throw new NoSuchCategoryException(msg.toString());
1130                    }
1131                    else {
1132                            return list.get(0);
1133                    }
1134            }
1135    
1136            /**
1137             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63;.
1138             *
1139             * <p>
1140             * 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.
1141             * </p>
1142             *
1143             * @param categoryId the primary key of the current asset category
1144             * @param uuid the uuid
1145             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1146             * @return the previous, current, and next asset category
1147             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1148             * @throws SystemException if a system exception occurred
1149             */
1150            public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1151                    OrderByComparator orderByComparator)
1152                    throws NoSuchCategoryException, SystemException {
1153                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1154    
1155                    Session session = null;
1156    
1157                    try {
1158                            session = openSession();
1159    
1160                            AssetCategory[] array = new AssetCategoryImpl[3];
1161    
1162                            array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1163                                            orderByComparator, true);
1164    
1165                            array[1] = assetCategory;
1166    
1167                            array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1168                                            orderByComparator, false);
1169    
1170                            return array;
1171                    }
1172                    catch (Exception e) {
1173                            throw processException(e);
1174                    }
1175                    finally {
1176                            closeSession(session);
1177                    }
1178            }
1179    
1180            protected AssetCategory getByUuid_PrevAndNext(Session session,
1181                    AssetCategory assetCategory, String uuid,
1182                    OrderByComparator orderByComparator, boolean previous) {
1183                    StringBundler query = null;
1184    
1185                    if (orderByComparator != null) {
1186                            query = new StringBundler(6 +
1187                                            (orderByComparator.getOrderByFields().length * 6));
1188                    }
1189                    else {
1190                            query = new StringBundler(3);
1191                    }
1192    
1193                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1194    
1195                    if (uuid == null) {
1196                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1197                    }
1198                    else {
1199                            if (uuid.equals(StringPool.BLANK)) {
1200                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1201                            }
1202                            else {
1203                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1204                            }
1205                    }
1206    
1207                    if (orderByComparator != null) {
1208                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1209    
1210                            if (orderByConditionFields.length > 0) {
1211                                    query.append(WHERE_AND);
1212                            }
1213    
1214                            for (int i = 0; i < orderByConditionFields.length; i++) {
1215                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1216                                    query.append(orderByConditionFields[i]);
1217    
1218                                    if ((i + 1) < orderByConditionFields.length) {
1219                                            if (orderByComparator.isAscending() ^ previous) {
1220                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1221                                            }
1222                                            else {
1223                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1224                                            }
1225                                    }
1226                                    else {
1227                                            if (orderByComparator.isAscending() ^ previous) {
1228                                                    query.append(WHERE_GREATER_THAN);
1229                                            }
1230                                            else {
1231                                                    query.append(WHERE_LESSER_THAN);
1232                                            }
1233                                    }
1234                            }
1235    
1236                            query.append(ORDER_BY_CLAUSE);
1237    
1238                            String[] orderByFields = orderByComparator.getOrderByFields();
1239    
1240                            for (int i = 0; i < orderByFields.length; i++) {
1241                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1242                                    query.append(orderByFields[i]);
1243    
1244                                    if ((i + 1) < orderByFields.length) {
1245                                            if (orderByComparator.isAscending() ^ previous) {
1246                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1247                                            }
1248                                            else {
1249                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1250                                            }
1251                                    }
1252                                    else {
1253                                            if (orderByComparator.isAscending() ^ previous) {
1254                                                    query.append(ORDER_BY_ASC);
1255                                            }
1256                                            else {
1257                                                    query.append(ORDER_BY_DESC);
1258                                            }
1259                                    }
1260                            }
1261                    }
1262    
1263                    else {
1264                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1265                    }
1266    
1267                    String sql = query.toString();
1268    
1269                    Query q = session.createQuery(sql);
1270    
1271                    q.setFirstResult(0);
1272                    q.setMaxResults(2);
1273    
1274                    QueryPos qPos = QueryPos.getInstance(q);
1275    
1276                    if (uuid != null) {
1277                            qPos.add(uuid);
1278                    }
1279    
1280                    if (orderByComparator != null) {
1281                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1282    
1283                            for (Object value : values) {
1284                                    qPos.add(value);
1285                            }
1286                    }
1287    
1288                    List<AssetCategory> list = q.list();
1289    
1290                    if (list.size() == 2) {
1291                            return list.get(1);
1292                    }
1293                    else {
1294                            return null;
1295                    }
1296            }
1297    
1298            /**
1299             * Returns the asset category where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
1300             *
1301             * @param uuid the uuid
1302             * @param groupId the group ID
1303             * @return the matching asset category
1304             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1305             * @throws SystemException if a system exception occurred
1306             */
1307            public AssetCategory findByUUID_G(String uuid, long groupId)
1308                    throws NoSuchCategoryException, SystemException {
1309                    AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1310    
1311                    if (assetCategory == null) {
1312                            StringBundler msg = new StringBundler(6);
1313    
1314                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1315    
1316                            msg.append("uuid=");
1317                            msg.append(uuid);
1318    
1319                            msg.append(", groupId=");
1320                            msg.append(groupId);
1321    
1322                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1323    
1324                            if (_log.isWarnEnabled()) {
1325                                    _log.warn(msg.toString());
1326                            }
1327    
1328                            throw new NoSuchCategoryException(msg.toString());
1329                    }
1330    
1331                    return assetCategory;
1332            }
1333    
1334            /**
1335             * Returns the asset category where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1336             *
1337             * @param uuid the uuid
1338             * @param groupId the group ID
1339             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
1340             * @throws SystemException if a system exception occurred
1341             */
1342            public AssetCategory fetchByUUID_G(String uuid, long groupId)
1343                    throws SystemException {
1344                    return fetchByUUID_G(uuid, groupId, true);
1345            }
1346    
1347            /**
1348             * Returns the asset category where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1349             *
1350             * @param uuid the uuid
1351             * @param groupId the group ID
1352             * @param retrieveFromCache whether to use the finder cache
1353             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
1354             * @throws SystemException if a system exception occurred
1355             */
1356            public AssetCategory fetchByUUID_G(String uuid, long groupId,
1357                    boolean retrieveFromCache) throws SystemException {
1358                    Object[] finderArgs = new Object[] { uuid, groupId };
1359    
1360                    Object result = null;
1361    
1362                    if (retrieveFromCache) {
1363                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1364                                            finderArgs, this);
1365                    }
1366    
1367                    if (result instanceof AssetCategory) {
1368                            AssetCategory assetCategory = (AssetCategory)result;
1369    
1370                            if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1371                                            (groupId != assetCategory.getGroupId())) {
1372                                    result = null;
1373                            }
1374                    }
1375    
1376                    if (result == null) {
1377                            StringBundler query = new StringBundler(4);
1378    
1379                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1380    
1381                            if (uuid == null) {
1382                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1383                            }
1384                            else {
1385                                    if (uuid.equals(StringPool.BLANK)) {
1386                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1387                                    }
1388                                    else {
1389                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1390                                    }
1391                            }
1392    
1393                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1394    
1395                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1396    
1397                            String sql = query.toString();
1398    
1399                            Session session = null;
1400    
1401                            try {
1402                                    session = openSession();
1403    
1404                                    Query q = session.createQuery(sql);
1405    
1406                                    QueryPos qPos = QueryPos.getInstance(q);
1407    
1408                                    if (uuid != null) {
1409                                            qPos.add(uuid);
1410                                    }
1411    
1412                                    qPos.add(groupId);
1413    
1414                                    List<AssetCategory> list = q.list();
1415    
1416                                    result = list;
1417    
1418                                    AssetCategory assetCategory = null;
1419    
1420                                    if (list.isEmpty()) {
1421                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1422                                                    finderArgs, list);
1423                                    }
1424                                    else {
1425                                            assetCategory = list.get(0);
1426    
1427                                            cacheResult(assetCategory);
1428    
1429                                            if ((assetCategory.getUuid() == null) ||
1430                                                            !assetCategory.getUuid().equals(uuid) ||
1431                                                            (assetCategory.getGroupId() != groupId)) {
1432                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1433                                                            finderArgs, assetCategory);
1434                                            }
1435                                    }
1436    
1437                                    return assetCategory;
1438                            }
1439                            catch (Exception e) {
1440                                    throw processException(e);
1441                            }
1442                            finally {
1443                                    if (result == null) {
1444                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1445                                                    finderArgs);
1446                                    }
1447    
1448                                    closeSession(session);
1449                            }
1450                    }
1451                    else {
1452                            if (result instanceof List<?>) {
1453                                    return null;
1454                            }
1455                            else {
1456                                    return (AssetCategory)result;
1457                            }
1458                    }
1459            }
1460    
1461            /**
1462             * Returns all the asset categories where groupId = &#63;.
1463             *
1464             * @param groupId the group ID
1465             * @return the matching asset categories
1466             * @throws SystemException if a system exception occurred
1467             */
1468            public List<AssetCategory> findByGroupId(long groupId)
1469                    throws SystemException {
1470                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1471            }
1472    
1473            /**
1474             * Returns a range of all the asset categories where groupId = &#63;.
1475             *
1476             * <p>
1477             * 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.
1478             * </p>
1479             *
1480             * @param groupId the group ID
1481             * @param start the lower bound of the range of asset categories
1482             * @param end the upper bound of the range of asset categories (not inclusive)
1483             * @return the range of matching asset categories
1484             * @throws SystemException if a system exception occurred
1485             */
1486            public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1487                    throws SystemException {
1488                    return findByGroupId(groupId, start, end, null);
1489            }
1490    
1491            /**
1492             * Returns an ordered range of all the asset categories where groupId = &#63;.
1493             *
1494             * <p>
1495             * 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.
1496             * </p>
1497             *
1498             * @param groupId the group ID
1499             * @param start the lower bound of the range of asset categories
1500             * @param end the upper bound of the range of asset categories (not inclusive)
1501             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1502             * @return the ordered range of matching asset categories
1503             * @throws SystemException if a system exception occurred
1504             */
1505            public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1506                    OrderByComparator orderByComparator) throws SystemException {
1507                    FinderPath finderPath = null;
1508                    Object[] finderArgs = null;
1509    
1510                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1511                                    (orderByComparator == null)) {
1512                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1513                            finderArgs = new Object[] { groupId };
1514                    }
1515                    else {
1516                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1517                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1518                    }
1519    
1520                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1521                                    finderArgs, this);
1522    
1523                    if ((list != null) && !list.isEmpty()) {
1524                            for (AssetCategory assetCategory : list) {
1525                                    if ((groupId != assetCategory.getGroupId())) {
1526                                            list = null;
1527    
1528                                            break;
1529                                    }
1530                            }
1531                    }
1532    
1533                    if (list == null) {
1534                            StringBundler query = null;
1535    
1536                            if (orderByComparator != null) {
1537                                    query = new StringBundler(3 +
1538                                                    (orderByComparator.getOrderByFields().length * 3));
1539                            }
1540                            else {
1541                                    query = new StringBundler(3);
1542                            }
1543    
1544                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1545    
1546                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1547    
1548                            if (orderByComparator != null) {
1549                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1550                                            orderByComparator);
1551                            }
1552    
1553                            else {
1554                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1555                            }
1556    
1557                            String sql = query.toString();
1558    
1559                            Session session = null;
1560    
1561                            try {
1562                                    session = openSession();
1563    
1564                                    Query q = session.createQuery(sql);
1565    
1566                                    QueryPos qPos = QueryPos.getInstance(q);
1567    
1568                                    qPos.add(groupId);
1569    
1570                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1571                                                    start, end);
1572                            }
1573                            catch (Exception e) {
1574                                    throw processException(e);
1575                            }
1576                            finally {
1577                                    if (list == null) {
1578                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1579                                    }
1580                                    else {
1581                                            cacheResult(list);
1582    
1583                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1584                                    }
1585    
1586                                    closeSession(session);
1587                            }
1588                    }
1589    
1590                    return list;
1591            }
1592    
1593            /**
1594             * Returns the first asset category in the ordered set where groupId = &#63;.
1595             *
1596             * <p>
1597             * 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.
1598             * </p>
1599             *
1600             * @param groupId the group ID
1601             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1602             * @return the first matching asset category
1603             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1604             * @throws SystemException if a system exception occurred
1605             */
1606            public AssetCategory findByGroupId_First(long groupId,
1607                    OrderByComparator orderByComparator)
1608                    throws NoSuchCategoryException, SystemException {
1609                    List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1610                                    orderByComparator);
1611    
1612                    if (list.isEmpty()) {
1613                            StringBundler msg = new StringBundler(4);
1614    
1615                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1616    
1617                            msg.append("groupId=");
1618                            msg.append(groupId);
1619    
1620                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1621    
1622                            throw new NoSuchCategoryException(msg.toString());
1623                    }
1624                    else {
1625                            return list.get(0);
1626                    }
1627            }
1628    
1629            /**
1630             * Returns the last asset category in the ordered set where groupId = &#63;.
1631             *
1632             * <p>
1633             * 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.
1634             * </p>
1635             *
1636             * @param groupId the group ID
1637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1638             * @return the last matching asset category
1639             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1640             * @throws SystemException if a system exception occurred
1641             */
1642            public AssetCategory findByGroupId_Last(long groupId,
1643                    OrderByComparator orderByComparator)
1644                    throws NoSuchCategoryException, SystemException {
1645                    int count = countByGroupId(groupId);
1646    
1647                    List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1648                                    orderByComparator);
1649    
1650                    if (list.isEmpty()) {
1651                            StringBundler msg = new StringBundler(4);
1652    
1653                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1654    
1655                            msg.append("groupId=");
1656                            msg.append(groupId);
1657    
1658                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1659    
1660                            throw new NoSuchCategoryException(msg.toString());
1661                    }
1662                    else {
1663                            return list.get(0);
1664                    }
1665            }
1666    
1667            /**
1668             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63;.
1669             *
1670             * <p>
1671             * 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.
1672             * </p>
1673             *
1674             * @param categoryId the primary key of the current asset category
1675             * @param groupId the group ID
1676             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1677             * @return the previous, current, and next asset category
1678             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1679             * @throws SystemException if a system exception occurred
1680             */
1681            public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1682                    long groupId, OrderByComparator orderByComparator)
1683                    throws NoSuchCategoryException, SystemException {
1684                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1685    
1686                    Session session = null;
1687    
1688                    try {
1689                            session = openSession();
1690    
1691                            AssetCategory[] array = new AssetCategoryImpl[3];
1692    
1693                            array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1694                                            groupId, orderByComparator, true);
1695    
1696                            array[1] = assetCategory;
1697    
1698                            array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1699                                            groupId, orderByComparator, false);
1700    
1701                            return array;
1702                    }
1703                    catch (Exception e) {
1704                            throw processException(e);
1705                    }
1706                    finally {
1707                            closeSession(session);
1708                    }
1709            }
1710    
1711            protected AssetCategory getByGroupId_PrevAndNext(Session session,
1712                    AssetCategory assetCategory, long groupId,
1713                    OrderByComparator orderByComparator, boolean previous) {
1714                    StringBundler query = null;
1715    
1716                    if (orderByComparator != null) {
1717                            query = new StringBundler(6 +
1718                                            (orderByComparator.getOrderByFields().length * 6));
1719                    }
1720                    else {
1721                            query = new StringBundler(3);
1722                    }
1723    
1724                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1725    
1726                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1727    
1728                    if (orderByComparator != null) {
1729                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1730    
1731                            if (orderByConditionFields.length > 0) {
1732                                    query.append(WHERE_AND);
1733                            }
1734    
1735                            for (int i = 0; i < orderByConditionFields.length; i++) {
1736                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1737                                    query.append(orderByConditionFields[i]);
1738    
1739                                    if ((i + 1) < orderByConditionFields.length) {
1740                                            if (orderByComparator.isAscending() ^ previous) {
1741                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1742                                            }
1743                                            else {
1744                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1745                                            }
1746                                    }
1747                                    else {
1748                                            if (orderByComparator.isAscending() ^ previous) {
1749                                                    query.append(WHERE_GREATER_THAN);
1750                                            }
1751                                            else {
1752                                                    query.append(WHERE_LESSER_THAN);
1753                                            }
1754                                    }
1755                            }
1756    
1757                            query.append(ORDER_BY_CLAUSE);
1758    
1759                            String[] orderByFields = orderByComparator.getOrderByFields();
1760    
1761                            for (int i = 0; i < orderByFields.length; i++) {
1762                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1763                                    query.append(orderByFields[i]);
1764    
1765                                    if ((i + 1) < orderByFields.length) {
1766                                            if (orderByComparator.isAscending() ^ previous) {
1767                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1768                                            }
1769                                            else {
1770                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1771                                            }
1772                                    }
1773                                    else {
1774                                            if (orderByComparator.isAscending() ^ previous) {
1775                                                    query.append(ORDER_BY_ASC);
1776                                            }
1777                                            else {
1778                                                    query.append(ORDER_BY_DESC);
1779                                            }
1780                                    }
1781                            }
1782                    }
1783    
1784                    else {
1785                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1786                    }
1787    
1788                    String sql = query.toString();
1789    
1790                    Query q = session.createQuery(sql);
1791    
1792                    q.setFirstResult(0);
1793                    q.setMaxResults(2);
1794    
1795                    QueryPos qPos = QueryPos.getInstance(q);
1796    
1797                    qPos.add(groupId);
1798    
1799                    if (orderByComparator != null) {
1800                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1801    
1802                            for (Object value : values) {
1803                                    qPos.add(value);
1804                            }
1805                    }
1806    
1807                    List<AssetCategory> list = q.list();
1808    
1809                    if (list.size() == 2) {
1810                            return list.get(1);
1811                    }
1812                    else {
1813                            return null;
1814                    }
1815            }
1816    
1817            /**
1818             * Returns all the asset categories that the user has permission to view where groupId = &#63;.
1819             *
1820             * @param groupId the group ID
1821             * @return the matching asset categories that the user has permission to view
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public List<AssetCategory> filterFindByGroupId(long groupId)
1825                    throws SystemException {
1826                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1827                            QueryUtil.ALL_POS, null);
1828            }
1829    
1830            /**
1831             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63;.
1832             *
1833             * <p>
1834             * 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.
1835             * </p>
1836             *
1837             * @param groupId the group ID
1838             * @param start the lower bound of the range of asset categories
1839             * @param end the upper bound of the range of asset categories (not inclusive)
1840             * @return the range of matching asset categories that the user has permission to view
1841             * @throws SystemException if a system exception occurred
1842             */
1843            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1844                    int end) throws SystemException {
1845                    return filterFindByGroupId(groupId, start, end, null);
1846            }
1847    
1848            /**
1849             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63;.
1850             *
1851             * <p>
1852             * 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.
1853             * </p>
1854             *
1855             * @param groupId the group ID
1856             * @param start the lower bound of the range of asset categories
1857             * @param end the upper bound of the range of asset categories (not inclusive)
1858             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1859             * @return the ordered range of matching asset categories that the user has permission to view
1860             * @throws SystemException if a system exception occurred
1861             */
1862            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
1863                    int end, OrderByComparator orderByComparator) throws SystemException {
1864                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1865                            return findByGroupId(groupId, start, end, orderByComparator);
1866                    }
1867    
1868                    StringBundler query = null;
1869    
1870                    if (orderByComparator != null) {
1871                            query = new StringBundler(3 +
1872                                            (orderByComparator.getOrderByFields().length * 3));
1873                    }
1874                    else {
1875                            query = new StringBundler(3);
1876                    }
1877    
1878                    if (getDB().isSupportsInlineDistinct()) {
1879                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
1880                    }
1881                    else {
1882                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
1883                    }
1884    
1885                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1886    
1887                    if (!getDB().isSupportsInlineDistinct()) {
1888                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
1889                    }
1890    
1891                    if (orderByComparator != null) {
1892                            if (getDB().isSupportsInlineDistinct()) {
1893                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1894                                            orderByComparator);
1895                            }
1896                            else {
1897                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1898                                            orderByComparator);
1899                            }
1900                    }
1901    
1902                    else {
1903                            if (getDB().isSupportsInlineDistinct()) {
1904                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1905                            }
1906                            else {
1907                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
1908                            }
1909                    }
1910    
1911                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1912                                    AssetCategory.class.getName(),
1913                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1914    
1915                    Session session = null;
1916    
1917                    try {
1918                            session = openSession();
1919    
1920                            SQLQuery q = session.createSQLQuery(sql);
1921    
1922                            if (getDB().isSupportsInlineDistinct()) {
1923                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
1924                            }
1925                            else {
1926                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
1927                            }
1928    
1929                            QueryPos qPos = QueryPos.getInstance(q);
1930    
1931                            qPos.add(groupId);
1932    
1933                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
1934                                    end);
1935                    }
1936                    catch (Exception e) {
1937                            throw processException(e);
1938                    }
1939                    finally {
1940                            closeSession(session);
1941                    }
1942            }
1943    
1944            /**
1945             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63;.
1946             *
1947             * @param categoryId the primary key of the current asset category
1948             * @param groupId the group ID
1949             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1950             * @return the previous, current, and next asset category
1951             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1952             * @throws SystemException if a system exception occurred
1953             */
1954            public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
1955                    long groupId, OrderByComparator orderByComparator)
1956                    throws NoSuchCategoryException, SystemException {
1957                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1958                            return findByGroupId_PrevAndNext(categoryId, groupId,
1959                                    orderByComparator);
1960                    }
1961    
1962                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1963    
1964                    Session session = null;
1965    
1966                    try {
1967                            session = openSession();
1968    
1969                            AssetCategory[] array = new AssetCategoryImpl[3];
1970    
1971                            array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1972                                            groupId, orderByComparator, true);
1973    
1974                            array[1] = assetCategory;
1975    
1976                            array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
1977                                            groupId, orderByComparator, false);
1978    
1979                            return array;
1980                    }
1981                    catch (Exception e) {
1982                            throw processException(e);
1983                    }
1984                    finally {
1985                            closeSession(session);
1986                    }
1987            }
1988    
1989            protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
1990                    AssetCategory assetCategory, long groupId,
1991                    OrderByComparator orderByComparator, boolean previous) {
1992                    StringBundler query = null;
1993    
1994                    if (orderByComparator != null) {
1995                            query = new StringBundler(6 +
1996                                            (orderByComparator.getOrderByFields().length * 6));
1997                    }
1998                    else {
1999                            query = new StringBundler(3);
2000                    }
2001    
2002                    if (getDB().isSupportsInlineDistinct()) {
2003                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2004                    }
2005                    else {
2006                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2007                    }
2008    
2009                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2010    
2011                    if (!getDB().isSupportsInlineDistinct()) {
2012                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2013                    }
2014    
2015                    if (orderByComparator != null) {
2016                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2017    
2018                            if (orderByConditionFields.length > 0) {
2019                                    query.append(WHERE_AND);
2020                            }
2021    
2022                            for (int i = 0; i < orderByConditionFields.length; i++) {
2023                                    if (getDB().isSupportsInlineDistinct()) {
2024                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2025                                    }
2026                                    else {
2027                                            query.append(_ORDER_BY_ENTITY_TABLE);
2028                                    }
2029    
2030                                    query.append(orderByConditionFields[i]);
2031    
2032                                    if ((i + 1) < orderByConditionFields.length) {
2033                                            if (orderByComparator.isAscending() ^ previous) {
2034                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2035                                            }
2036                                            else {
2037                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2038                                            }
2039                                    }
2040                                    else {
2041                                            if (orderByComparator.isAscending() ^ previous) {
2042                                                    query.append(WHERE_GREATER_THAN);
2043                                            }
2044                                            else {
2045                                                    query.append(WHERE_LESSER_THAN);
2046                                            }
2047                                    }
2048                            }
2049    
2050                            query.append(ORDER_BY_CLAUSE);
2051    
2052                            String[] orderByFields = orderByComparator.getOrderByFields();
2053    
2054                            for (int i = 0; i < orderByFields.length; i++) {
2055                                    if (getDB().isSupportsInlineDistinct()) {
2056                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2057                                    }
2058                                    else {
2059                                            query.append(_ORDER_BY_ENTITY_TABLE);
2060                                    }
2061    
2062                                    query.append(orderByFields[i]);
2063    
2064                                    if ((i + 1) < orderByFields.length) {
2065                                            if (orderByComparator.isAscending() ^ previous) {
2066                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2067                                            }
2068                                            else {
2069                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2070                                            }
2071                                    }
2072                                    else {
2073                                            if (orderByComparator.isAscending() ^ previous) {
2074                                                    query.append(ORDER_BY_ASC);
2075                                            }
2076                                            else {
2077                                                    query.append(ORDER_BY_DESC);
2078                                            }
2079                                    }
2080                            }
2081                    }
2082    
2083                    else {
2084                            if (getDB().isSupportsInlineDistinct()) {
2085                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2086                            }
2087                            else {
2088                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2089                            }
2090                    }
2091    
2092                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2093                                    AssetCategory.class.getName(),
2094                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2095    
2096                    SQLQuery q = session.createSQLQuery(sql);
2097    
2098                    q.setFirstResult(0);
2099                    q.setMaxResults(2);
2100    
2101                    if (getDB().isSupportsInlineDistinct()) {
2102                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2103                    }
2104                    else {
2105                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2106                    }
2107    
2108                    QueryPos qPos = QueryPos.getInstance(q);
2109    
2110                    qPos.add(groupId);
2111    
2112                    if (orderByComparator != null) {
2113                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2114    
2115                            for (Object value : values) {
2116                                    qPos.add(value);
2117                            }
2118                    }
2119    
2120                    List<AssetCategory> list = q.list();
2121    
2122                    if (list.size() == 2) {
2123                            return list.get(1);
2124                    }
2125                    else {
2126                            return null;
2127                    }
2128            }
2129    
2130            /**
2131             * Returns all the asset categories where parentCategoryId = &#63;.
2132             *
2133             * @param parentCategoryId the parent category ID
2134             * @return the matching asset categories
2135             * @throws SystemException if a system exception occurred
2136             */
2137            public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2138                    throws SystemException {
2139                    return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2140                            QueryUtil.ALL_POS, null);
2141            }
2142    
2143            /**
2144             * Returns a range of all the asset categories where parentCategoryId = &#63;.
2145             *
2146             * <p>
2147             * 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.
2148             * </p>
2149             *
2150             * @param parentCategoryId the parent category ID
2151             * @param start the lower bound of the range of asset categories
2152             * @param end the upper bound of the range of asset categories (not inclusive)
2153             * @return the range of matching asset categories
2154             * @throws SystemException if a system exception occurred
2155             */
2156            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2157                    int start, int end) throws SystemException {
2158                    return findByParentCategoryId(parentCategoryId, start, end, null);
2159            }
2160    
2161            /**
2162             * Returns an ordered range of all the asset categories where parentCategoryId = &#63;.
2163             *
2164             * <p>
2165             * 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.
2166             * </p>
2167             *
2168             * @param parentCategoryId the parent category ID
2169             * @param start the lower bound of the range of asset categories
2170             * @param end the upper bound of the range of asset categories (not inclusive)
2171             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2172             * @return the ordered range of matching asset categories
2173             * @throws SystemException if a system exception occurred
2174             */
2175            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2176                    int start, int end, OrderByComparator orderByComparator)
2177                    throws SystemException {
2178                    FinderPath finderPath = null;
2179                    Object[] finderArgs = null;
2180    
2181                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2182                                    (orderByComparator == null)) {
2183                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2184                            finderArgs = new Object[] { parentCategoryId };
2185                    }
2186                    else {
2187                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2188                            finderArgs = new Object[] {
2189                                            parentCategoryId,
2190                                            
2191                                            start, end, orderByComparator
2192                                    };
2193                    }
2194    
2195                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2196                                    finderArgs, this);
2197    
2198                    if ((list != null) && !list.isEmpty()) {
2199                            for (AssetCategory assetCategory : list) {
2200                                    if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2201                                            list = null;
2202    
2203                                            break;
2204                                    }
2205                            }
2206                    }
2207    
2208                    if (list == null) {
2209                            StringBundler query = null;
2210    
2211                            if (orderByComparator != null) {
2212                                    query = new StringBundler(3 +
2213                                                    (orderByComparator.getOrderByFields().length * 3));
2214                            }
2215                            else {
2216                                    query = new StringBundler(3);
2217                            }
2218    
2219                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2220    
2221                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2222    
2223                            if (orderByComparator != null) {
2224                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2225                                            orderByComparator);
2226                            }
2227    
2228                            else {
2229                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2230                            }
2231    
2232                            String sql = query.toString();
2233    
2234                            Session session = null;
2235    
2236                            try {
2237                                    session = openSession();
2238    
2239                                    Query q = session.createQuery(sql);
2240    
2241                                    QueryPos qPos = QueryPos.getInstance(q);
2242    
2243                                    qPos.add(parentCategoryId);
2244    
2245                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2246                                                    start, end);
2247                            }
2248                            catch (Exception e) {
2249                                    throw processException(e);
2250                            }
2251                            finally {
2252                                    if (list == null) {
2253                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2254                                    }
2255                                    else {
2256                                            cacheResult(list);
2257    
2258                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2259                                    }
2260    
2261                                    closeSession(session);
2262                            }
2263                    }
2264    
2265                    return list;
2266            }
2267    
2268            /**
2269             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2270             *
2271             * <p>
2272             * 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.
2273             * </p>
2274             *
2275             * @param parentCategoryId the parent category ID
2276             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2277             * @return the first matching asset category
2278             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2279             * @throws SystemException if a system exception occurred
2280             */
2281            public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2282                    OrderByComparator orderByComparator)
2283                    throws NoSuchCategoryException, SystemException {
2284                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2285                                    1, orderByComparator);
2286    
2287                    if (list.isEmpty()) {
2288                            StringBundler msg = new StringBundler(4);
2289    
2290                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2291    
2292                            msg.append("parentCategoryId=");
2293                            msg.append(parentCategoryId);
2294    
2295                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2296    
2297                            throw new NoSuchCategoryException(msg.toString());
2298                    }
2299                    else {
2300                            return list.get(0);
2301                    }
2302            }
2303    
2304            /**
2305             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2306             *
2307             * <p>
2308             * 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.
2309             * </p>
2310             *
2311             * @param parentCategoryId the parent category ID
2312             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2313             * @return the last matching asset category
2314             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2315             * @throws SystemException if a system exception occurred
2316             */
2317            public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2318                    OrderByComparator orderByComparator)
2319                    throws NoSuchCategoryException, SystemException {
2320                    int count = countByParentCategoryId(parentCategoryId);
2321    
2322                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2323                                    count - 1, count, orderByComparator);
2324    
2325                    if (list.isEmpty()) {
2326                            StringBundler msg = new StringBundler(4);
2327    
2328                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2329    
2330                            msg.append("parentCategoryId=");
2331                            msg.append(parentCategoryId);
2332    
2333                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2334    
2335                            throw new NoSuchCategoryException(msg.toString());
2336                    }
2337                    else {
2338                            return list.get(0);
2339                    }
2340            }
2341    
2342            /**
2343             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63;.
2344             *
2345             * <p>
2346             * 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.
2347             * </p>
2348             *
2349             * @param categoryId the primary key of the current asset category
2350             * @param parentCategoryId the parent category ID
2351             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2352             * @return the previous, current, and next asset category
2353             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2354             * @throws SystemException if a system exception occurred
2355             */
2356            public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2357                    long parentCategoryId, OrderByComparator orderByComparator)
2358                    throws NoSuchCategoryException, SystemException {
2359                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2360    
2361                    Session session = null;
2362    
2363                    try {
2364                            session = openSession();
2365    
2366                            AssetCategory[] array = new AssetCategoryImpl[3];
2367    
2368                            array[0] = getByParentCategoryId_PrevAndNext(session,
2369                                            assetCategory, parentCategoryId, orderByComparator, true);
2370    
2371                            array[1] = assetCategory;
2372    
2373                            array[2] = getByParentCategoryId_PrevAndNext(session,
2374                                            assetCategory, parentCategoryId, orderByComparator, false);
2375    
2376                            return array;
2377                    }
2378                    catch (Exception e) {
2379                            throw processException(e);
2380                    }
2381                    finally {
2382                            closeSession(session);
2383                    }
2384            }
2385    
2386            protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2387                    AssetCategory assetCategory, long parentCategoryId,
2388                    OrderByComparator orderByComparator, boolean previous) {
2389                    StringBundler query = null;
2390    
2391                    if (orderByComparator != null) {
2392                            query = new StringBundler(6 +
2393                                            (orderByComparator.getOrderByFields().length * 6));
2394                    }
2395                    else {
2396                            query = new StringBundler(3);
2397                    }
2398    
2399                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2400    
2401                    query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2402    
2403                    if (orderByComparator != null) {
2404                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2405    
2406                            if (orderByConditionFields.length > 0) {
2407                                    query.append(WHERE_AND);
2408                            }
2409    
2410                            for (int i = 0; i < orderByConditionFields.length; i++) {
2411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2412                                    query.append(orderByConditionFields[i]);
2413    
2414                                    if ((i + 1) < orderByConditionFields.length) {
2415                                            if (orderByComparator.isAscending() ^ previous) {
2416                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2417                                            }
2418                                            else {
2419                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2420                                            }
2421                                    }
2422                                    else {
2423                                            if (orderByComparator.isAscending() ^ previous) {
2424                                                    query.append(WHERE_GREATER_THAN);
2425                                            }
2426                                            else {
2427                                                    query.append(WHERE_LESSER_THAN);
2428                                            }
2429                                    }
2430                            }
2431    
2432                            query.append(ORDER_BY_CLAUSE);
2433    
2434                            String[] orderByFields = orderByComparator.getOrderByFields();
2435    
2436                            for (int i = 0; i < orderByFields.length; i++) {
2437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2438                                    query.append(orderByFields[i]);
2439    
2440                                    if ((i + 1) < orderByFields.length) {
2441                                            if (orderByComparator.isAscending() ^ previous) {
2442                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2443                                            }
2444                                            else {
2445                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2446                                            }
2447                                    }
2448                                    else {
2449                                            if (orderByComparator.isAscending() ^ previous) {
2450                                                    query.append(ORDER_BY_ASC);
2451                                            }
2452                                            else {
2453                                                    query.append(ORDER_BY_DESC);
2454                                            }
2455                                    }
2456                            }
2457                    }
2458    
2459                    else {
2460                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2461                    }
2462    
2463                    String sql = query.toString();
2464    
2465                    Query q = session.createQuery(sql);
2466    
2467                    q.setFirstResult(0);
2468                    q.setMaxResults(2);
2469    
2470                    QueryPos qPos = QueryPos.getInstance(q);
2471    
2472                    qPos.add(parentCategoryId);
2473    
2474                    if (orderByComparator != null) {
2475                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2476    
2477                            for (Object value : values) {
2478                                    qPos.add(value);
2479                            }
2480                    }
2481    
2482                    List<AssetCategory> list = q.list();
2483    
2484                    if (list.size() == 2) {
2485                            return list.get(1);
2486                    }
2487                    else {
2488                            return null;
2489                    }
2490            }
2491    
2492            /**
2493             * Returns all the asset categories where vocabularyId = &#63;.
2494             *
2495             * @param vocabularyId the vocabulary ID
2496             * @return the matching asset categories
2497             * @throws SystemException if a system exception occurred
2498             */
2499            public List<AssetCategory> findByVocabularyId(long vocabularyId)
2500                    throws SystemException {
2501                    return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2502                            QueryUtil.ALL_POS, null);
2503            }
2504    
2505            /**
2506             * Returns a range of all the asset categories where vocabularyId = &#63;.
2507             *
2508             * <p>
2509             * 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.
2510             * </p>
2511             *
2512             * @param vocabularyId the vocabulary ID
2513             * @param start the lower bound of the range of asset categories
2514             * @param end the upper bound of the range of asset categories (not inclusive)
2515             * @return the range of matching asset categories
2516             * @throws SystemException if a system exception occurred
2517             */
2518            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2519                    int end) throws SystemException {
2520                    return findByVocabularyId(vocabularyId, start, end, null);
2521            }
2522    
2523            /**
2524             * Returns an ordered range of all the asset categories where vocabularyId = &#63;.
2525             *
2526             * <p>
2527             * 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.
2528             * </p>
2529             *
2530             * @param vocabularyId the vocabulary ID
2531             * @param start the lower bound of the range of asset categories
2532             * @param end the upper bound of the range of asset categories (not inclusive)
2533             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2534             * @return the ordered range of matching asset categories
2535             * @throws SystemException if a system exception occurred
2536             */
2537            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2538                    int end, OrderByComparator orderByComparator) throws SystemException {
2539                    FinderPath finderPath = null;
2540                    Object[] finderArgs = null;
2541    
2542                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2543                                    (orderByComparator == null)) {
2544                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2545                            finderArgs = new Object[] { vocabularyId };
2546                    }
2547                    else {
2548                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2549                            finderArgs = new Object[] {
2550                                            vocabularyId,
2551                                            
2552                                            start, end, orderByComparator
2553                                    };
2554                    }
2555    
2556                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2557                                    finderArgs, this);
2558    
2559                    if ((list != null) && !list.isEmpty()) {
2560                            for (AssetCategory assetCategory : list) {
2561                                    if ((vocabularyId != assetCategory.getVocabularyId())) {
2562                                            list = null;
2563    
2564                                            break;
2565                                    }
2566                            }
2567                    }
2568    
2569                    if (list == null) {
2570                            StringBundler query = null;
2571    
2572                            if (orderByComparator != null) {
2573                                    query = new StringBundler(3 +
2574                                                    (orderByComparator.getOrderByFields().length * 3));
2575                            }
2576                            else {
2577                                    query = new StringBundler(3);
2578                            }
2579    
2580                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2581    
2582                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2583    
2584                            if (orderByComparator != null) {
2585                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2586                                            orderByComparator);
2587                            }
2588    
2589                            else {
2590                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2591                            }
2592    
2593                            String sql = query.toString();
2594    
2595                            Session session = null;
2596    
2597                            try {
2598                                    session = openSession();
2599    
2600                                    Query q = session.createQuery(sql);
2601    
2602                                    QueryPos qPos = QueryPos.getInstance(q);
2603    
2604                                    qPos.add(vocabularyId);
2605    
2606                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2607                                                    start, end);
2608                            }
2609                            catch (Exception e) {
2610                                    throw processException(e);
2611                            }
2612                            finally {
2613                                    if (list == null) {
2614                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2615                                    }
2616                                    else {
2617                                            cacheResult(list);
2618    
2619                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2620                                    }
2621    
2622                                    closeSession(session);
2623                            }
2624                    }
2625    
2626                    return list;
2627            }
2628    
2629            /**
2630             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
2631             *
2632             * <p>
2633             * 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.
2634             * </p>
2635             *
2636             * @param vocabularyId the vocabulary ID
2637             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2638             * @return the first matching asset category
2639             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2640             * @throws SystemException if a system exception occurred
2641             */
2642            public AssetCategory findByVocabularyId_First(long vocabularyId,
2643                    OrderByComparator orderByComparator)
2644                    throws NoSuchCategoryException, SystemException {
2645                    List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2646                                    orderByComparator);
2647    
2648                    if (list.isEmpty()) {
2649                            StringBundler msg = new StringBundler(4);
2650    
2651                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2652    
2653                            msg.append("vocabularyId=");
2654                            msg.append(vocabularyId);
2655    
2656                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2657    
2658                            throw new NoSuchCategoryException(msg.toString());
2659                    }
2660                    else {
2661                            return list.get(0);
2662                    }
2663            }
2664    
2665            /**
2666             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
2667             *
2668             * <p>
2669             * 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.
2670             * </p>
2671             *
2672             * @param vocabularyId the vocabulary ID
2673             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2674             * @return the last matching asset category
2675             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2676             * @throws SystemException if a system exception occurred
2677             */
2678            public AssetCategory findByVocabularyId_Last(long vocabularyId,
2679                    OrderByComparator orderByComparator)
2680                    throws NoSuchCategoryException, SystemException {
2681                    int count = countByVocabularyId(vocabularyId);
2682    
2683                    List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2684                                    count, orderByComparator);
2685    
2686                    if (list.isEmpty()) {
2687                            StringBundler msg = new StringBundler(4);
2688    
2689                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2690    
2691                            msg.append("vocabularyId=");
2692                            msg.append(vocabularyId);
2693    
2694                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2695    
2696                            throw new NoSuchCategoryException(msg.toString());
2697                    }
2698                    else {
2699                            return list.get(0);
2700                    }
2701            }
2702    
2703            /**
2704             * Returns the asset categories before and after the current asset category in the ordered set where vocabularyId = &#63;.
2705             *
2706             * <p>
2707             * 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.
2708             * </p>
2709             *
2710             * @param categoryId the primary key of the current asset category
2711             * @param vocabularyId the vocabulary ID
2712             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2713             * @return the previous, current, and next asset category
2714             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2715             * @throws SystemException if a system exception occurred
2716             */
2717            public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2718                    long vocabularyId, OrderByComparator orderByComparator)
2719                    throws NoSuchCategoryException, SystemException {
2720                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2721    
2722                    Session session = null;
2723    
2724                    try {
2725                            session = openSession();
2726    
2727                            AssetCategory[] array = new AssetCategoryImpl[3];
2728    
2729                            array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
2730                                            vocabularyId, orderByComparator, true);
2731    
2732                            array[1] = assetCategory;
2733    
2734                            array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
2735                                            vocabularyId, orderByComparator, false);
2736    
2737                            return array;
2738                    }
2739                    catch (Exception e) {
2740                            throw processException(e);
2741                    }
2742                    finally {
2743                            closeSession(session);
2744                    }
2745            }
2746    
2747            protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
2748                    AssetCategory assetCategory, long vocabularyId,
2749                    OrderByComparator orderByComparator, boolean previous) {
2750                    StringBundler query = null;
2751    
2752                    if (orderByComparator != null) {
2753                            query = new StringBundler(6 +
2754                                            (orderByComparator.getOrderByFields().length * 6));
2755                    }
2756                    else {
2757                            query = new StringBundler(3);
2758                    }
2759    
2760                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2761    
2762                    query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2763    
2764                    if (orderByComparator != null) {
2765                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2766    
2767                            if (orderByConditionFields.length > 0) {
2768                                    query.append(WHERE_AND);
2769                            }
2770    
2771                            for (int i = 0; i < orderByConditionFields.length; i++) {
2772                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2773                                    query.append(orderByConditionFields[i]);
2774    
2775                                    if ((i + 1) < orderByConditionFields.length) {
2776                                            if (orderByComparator.isAscending() ^ previous) {
2777                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2778                                            }
2779                                            else {
2780                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2781                                            }
2782                                    }
2783                                    else {
2784                                            if (orderByComparator.isAscending() ^ previous) {
2785                                                    query.append(WHERE_GREATER_THAN);
2786                                            }
2787                                            else {
2788                                                    query.append(WHERE_LESSER_THAN);
2789                                            }
2790                                    }
2791                            }
2792    
2793                            query.append(ORDER_BY_CLAUSE);
2794    
2795                            String[] orderByFields = orderByComparator.getOrderByFields();
2796    
2797                            for (int i = 0; i < orderByFields.length; i++) {
2798                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2799                                    query.append(orderByFields[i]);
2800    
2801                                    if ((i + 1) < orderByFields.length) {
2802                                            if (orderByComparator.isAscending() ^ previous) {
2803                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2804                                            }
2805                                            else {
2806                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2807                                            }
2808                                    }
2809                                    else {
2810                                            if (orderByComparator.isAscending() ^ previous) {
2811                                                    query.append(ORDER_BY_ASC);
2812                                            }
2813                                            else {
2814                                                    query.append(ORDER_BY_DESC);
2815                                            }
2816                                    }
2817                            }
2818                    }
2819    
2820                    else {
2821                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2822                    }
2823    
2824                    String sql = query.toString();
2825    
2826                    Query q = session.createQuery(sql);
2827    
2828                    q.setFirstResult(0);
2829                    q.setMaxResults(2);
2830    
2831                    QueryPos qPos = QueryPos.getInstance(q);
2832    
2833                    qPos.add(vocabularyId);
2834    
2835                    if (orderByComparator != null) {
2836                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2837    
2838                            for (Object value : values) {
2839                                    qPos.add(value);
2840                            }
2841                    }
2842    
2843                    List<AssetCategory> list = q.list();
2844    
2845                    if (list.size() == 2) {
2846                            return list.get(1);
2847                    }
2848                    else {
2849                            return null;
2850                    }
2851            }
2852    
2853            /**
2854             * Returns all the asset categories where groupId = &#63; and vocabularyId = &#63;.
2855             *
2856             * @param groupId the group ID
2857             * @param vocabularyId the vocabulary ID
2858             * @return the matching asset categories
2859             * @throws SystemException if a system exception occurred
2860             */
2861            public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
2862                    throws SystemException {
2863                    return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
2864                            QueryUtil.ALL_POS, null);
2865            }
2866    
2867            /**
2868             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
2869             *
2870             * <p>
2871             * 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.
2872             * </p>
2873             *
2874             * @param groupId the group ID
2875             * @param vocabularyId the vocabulary ID
2876             * @param start the lower bound of the range of asset categories
2877             * @param end the upper bound of the range of asset categories (not inclusive)
2878             * @return the range of matching asset categories
2879             * @throws SystemException if a system exception occurred
2880             */
2881            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2882                    int start, int end) throws SystemException {
2883                    return findByG_V(groupId, vocabularyId, start, end, null);
2884            }
2885    
2886            /**
2887             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
2888             *
2889             * <p>
2890             * 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.
2891             * </p>
2892             *
2893             * @param groupId the group ID
2894             * @param vocabularyId the vocabulary ID
2895             * @param start the lower bound of the range of asset categories
2896             * @param end the upper bound of the range of asset categories (not inclusive)
2897             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2898             * @return the ordered range of matching asset categories
2899             * @throws SystemException if a system exception occurred
2900             */
2901            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
2902                    int start, int end, OrderByComparator orderByComparator)
2903                    throws SystemException {
2904                    FinderPath finderPath = null;
2905                    Object[] finderArgs = null;
2906    
2907                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2908                                    (orderByComparator == null)) {
2909                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
2910                            finderArgs = new Object[] { groupId, vocabularyId };
2911                    }
2912                    else {
2913                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
2914                            finderArgs = new Object[] {
2915                                            groupId, vocabularyId,
2916                                            
2917                                            start, end, orderByComparator
2918                                    };
2919                    }
2920    
2921                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2922                                    finderArgs, this);
2923    
2924                    if ((list != null) && !list.isEmpty()) {
2925                            for (AssetCategory assetCategory : list) {
2926                                    if ((groupId != assetCategory.getGroupId()) ||
2927                                                    (vocabularyId != assetCategory.getVocabularyId())) {
2928                                            list = null;
2929    
2930                                            break;
2931                                    }
2932                            }
2933                    }
2934    
2935                    if (list == null) {
2936                            StringBundler query = null;
2937    
2938                            if (orderByComparator != null) {
2939                                    query = new StringBundler(4 +
2940                                                    (orderByComparator.getOrderByFields().length * 3));
2941                            }
2942                            else {
2943                                    query = new StringBundler(4);
2944                            }
2945    
2946                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2947    
2948                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
2949    
2950                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
2951    
2952                            if (orderByComparator != null) {
2953                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2954                                            orderByComparator);
2955                            }
2956    
2957                            else {
2958                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2959                            }
2960    
2961                            String sql = query.toString();
2962    
2963                            Session session = null;
2964    
2965                            try {
2966                                    session = openSession();
2967    
2968                                    Query q = session.createQuery(sql);
2969    
2970                                    QueryPos qPos = QueryPos.getInstance(q);
2971    
2972                                    qPos.add(groupId);
2973    
2974                                    qPos.add(vocabularyId);
2975    
2976                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2977                                                    start, end);
2978                            }
2979                            catch (Exception e) {
2980                                    throw processException(e);
2981                            }
2982                            finally {
2983                                    if (list == null) {
2984                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2985                                    }
2986                                    else {
2987                                            cacheResult(list);
2988    
2989                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2990                                    }
2991    
2992                                    closeSession(session);
2993                            }
2994                    }
2995    
2996                    return list;
2997            }
2998    
2999            /**
3000             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3001             *
3002             * <p>
3003             * 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.
3004             * </p>
3005             *
3006             * @param groupId the group ID
3007             * @param vocabularyId the vocabulary ID
3008             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3009             * @return the first matching asset category
3010             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3011             * @throws SystemException if a system exception occurred
3012             */
3013            public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3014                    OrderByComparator orderByComparator)
3015                    throws NoSuchCategoryException, SystemException {
3016                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3017                                    orderByComparator);
3018    
3019                    if (list.isEmpty()) {
3020                            StringBundler msg = new StringBundler(6);
3021    
3022                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3023    
3024                            msg.append("groupId=");
3025                            msg.append(groupId);
3026    
3027                            msg.append(", vocabularyId=");
3028                            msg.append(vocabularyId);
3029    
3030                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3031    
3032                            throw new NoSuchCategoryException(msg.toString());
3033                    }
3034                    else {
3035                            return list.get(0);
3036                    }
3037            }
3038    
3039            /**
3040             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3041             *
3042             * <p>
3043             * 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.
3044             * </p>
3045             *
3046             * @param groupId the group ID
3047             * @param vocabularyId the vocabulary ID
3048             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3049             * @return the last matching asset category
3050             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3051             * @throws SystemException if a system exception occurred
3052             */
3053            public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3054                    OrderByComparator orderByComparator)
3055                    throws NoSuchCategoryException, SystemException {
3056                    int count = countByG_V(groupId, vocabularyId);
3057    
3058                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3059                                    count, orderByComparator);
3060    
3061                    if (list.isEmpty()) {
3062                            StringBundler msg = new StringBundler(6);
3063    
3064                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3065    
3066                            msg.append("groupId=");
3067                            msg.append(groupId);
3068    
3069                            msg.append(", vocabularyId=");
3070                            msg.append(vocabularyId);
3071    
3072                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3073    
3074                            throw new NoSuchCategoryException(msg.toString());
3075                    }
3076                    else {
3077                            return list.get(0);
3078                    }
3079            }
3080    
3081            /**
3082             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3083             *
3084             * <p>
3085             * 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.
3086             * </p>
3087             *
3088             * @param categoryId the primary key of the current asset category
3089             * @param groupId the group ID
3090             * @param vocabularyId the vocabulary ID
3091             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3092             * @return the previous, current, and next asset category
3093             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3094             * @throws SystemException if a system exception occurred
3095             */
3096            public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3097                    long vocabularyId, OrderByComparator orderByComparator)
3098                    throws NoSuchCategoryException, SystemException {
3099                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3100    
3101                    Session session = null;
3102    
3103                    try {
3104                            session = openSession();
3105    
3106                            AssetCategory[] array = new AssetCategoryImpl[3];
3107    
3108                            array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3109                                            vocabularyId, orderByComparator, true);
3110    
3111                            array[1] = assetCategory;
3112    
3113                            array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3114                                            vocabularyId, orderByComparator, false);
3115    
3116                            return array;
3117                    }
3118                    catch (Exception e) {
3119                            throw processException(e);
3120                    }
3121                    finally {
3122                            closeSession(session);
3123                    }
3124            }
3125    
3126            protected AssetCategory getByG_V_PrevAndNext(Session session,
3127                    AssetCategory assetCategory, long groupId, long vocabularyId,
3128                    OrderByComparator orderByComparator, boolean previous) {
3129                    StringBundler query = null;
3130    
3131                    if (orderByComparator != null) {
3132                            query = new StringBundler(6 +
3133                                            (orderByComparator.getOrderByFields().length * 6));
3134                    }
3135                    else {
3136                            query = new StringBundler(3);
3137                    }
3138    
3139                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3140    
3141                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3142    
3143                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3144    
3145                    if (orderByComparator != null) {
3146                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3147    
3148                            if (orderByConditionFields.length > 0) {
3149                                    query.append(WHERE_AND);
3150                            }
3151    
3152                            for (int i = 0; i < orderByConditionFields.length; i++) {
3153                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3154                                    query.append(orderByConditionFields[i]);
3155    
3156                                    if ((i + 1) < orderByConditionFields.length) {
3157                                            if (orderByComparator.isAscending() ^ previous) {
3158                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3159                                            }
3160                                            else {
3161                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3162                                            }
3163                                    }
3164                                    else {
3165                                            if (orderByComparator.isAscending() ^ previous) {
3166                                                    query.append(WHERE_GREATER_THAN);
3167                                            }
3168                                            else {
3169                                                    query.append(WHERE_LESSER_THAN);
3170                                            }
3171                                    }
3172                            }
3173    
3174                            query.append(ORDER_BY_CLAUSE);
3175    
3176                            String[] orderByFields = orderByComparator.getOrderByFields();
3177    
3178                            for (int i = 0; i < orderByFields.length; i++) {
3179                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3180                                    query.append(orderByFields[i]);
3181    
3182                                    if ((i + 1) < orderByFields.length) {
3183                                            if (orderByComparator.isAscending() ^ previous) {
3184                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3185                                            }
3186                                            else {
3187                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3188                                            }
3189                                    }
3190                                    else {
3191                                            if (orderByComparator.isAscending() ^ previous) {
3192                                                    query.append(ORDER_BY_ASC);
3193                                            }
3194                                            else {
3195                                                    query.append(ORDER_BY_DESC);
3196                                            }
3197                                    }
3198                            }
3199                    }
3200    
3201                    else {
3202                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3203                    }
3204    
3205                    String sql = query.toString();
3206    
3207                    Query q = session.createQuery(sql);
3208    
3209                    q.setFirstResult(0);
3210                    q.setMaxResults(2);
3211    
3212                    QueryPos qPos = QueryPos.getInstance(q);
3213    
3214                    qPos.add(groupId);
3215    
3216                    qPos.add(vocabularyId);
3217    
3218                    if (orderByComparator != null) {
3219                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3220    
3221                            for (Object value : values) {
3222                                    qPos.add(value);
3223                            }
3224                    }
3225    
3226                    List<AssetCategory> list = q.list();
3227    
3228                    if (list.size() == 2) {
3229                            return list.get(1);
3230                    }
3231                    else {
3232                            return null;
3233                    }
3234            }
3235    
3236            /**
3237             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3238             *
3239             * @param groupId the group ID
3240             * @param vocabularyId the vocabulary ID
3241             * @return the matching asset categories that the user has permission to view
3242             * @throws SystemException if a system exception occurred
3243             */
3244            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3245                    throws SystemException {
3246                    return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3247                            QueryUtil.ALL_POS, null);
3248            }
3249    
3250            /**
3251             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3252             *
3253             * <p>
3254             * 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.
3255             * </p>
3256             *
3257             * @param groupId the group ID
3258             * @param vocabularyId the vocabulary ID
3259             * @param start the lower bound of the range of asset categories
3260             * @param end the upper bound of the range of asset categories (not inclusive)
3261             * @return the range of matching asset categories that the user has permission to view
3262             * @throws SystemException if a system exception occurred
3263             */
3264            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3265                    int start, int end) throws SystemException {
3266                    return filterFindByG_V(groupId, vocabularyId, start, end, null);
3267            }
3268    
3269            /**
3270             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and vocabularyId = &#63;.
3271             *
3272             * <p>
3273             * 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.
3274             * </p>
3275             *
3276             * @param groupId the group ID
3277             * @param vocabularyId the vocabulary ID
3278             * @param start the lower bound of the range of asset categories
3279             * @param end the upper bound of the range of asset categories (not inclusive)
3280             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3281             * @return the ordered range of matching asset categories that the user has permission to view
3282             * @throws SystemException if a system exception occurred
3283             */
3284            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3285                    int start, int end, OrderByComparator orderByComparator)
3286                    throws SystemException {
3287                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3288                            return findByG_V(groupId, vocabularyId, start, end,
3289                                    orderByComparator);
3290                    }
3291    
3292                    StringBundler query = null;
3293    
3294                    if (orderByComparator != null) {
3295                            query = new StringBundler(4 +
3296                                            (orderByComparator.getOrderByFields().length * 3));
3297                    }
3298                    else {
3299                            query = new StringBundler(4);
3300                    }
3301    
3302                    if (getDB().isSupportsInlineDistinct()) {
3303                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3304                    }
3305                    else {
3306                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3307                    }
3308    
3309                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3310    
3311                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3312    
3313                    if (!getDB().isSupportsInlineDistinct()) {
3314                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3315                    }
3316    
3317                    if (orderByComparator != null) {
3318                            if (getDB().isSupportsInlineDistinct()) {
3319                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3320                                            orderByComparator);
3321                            }
3322                            else {
3323                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3324                                            orderByComparator);
3325                            }
3326                    }
3327    
3328                    else {
3329                            if (getDB().isSupportsInlineDistinct()) {
3330                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3331                            }
3332                            else {
3333                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3334                            }
3335                    }
3336    
3337                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3338                                    AssetCategory.class.getName(),
3339                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3340    
3341                    Session session = null;
3342    
3343                    try {
3344                            session = openSession();
3345    
3346                            SQLQuery q = session.createSQLQuery(sql);
3347    
3348                            if (getDB().isSupportsInlineDistinct()) {
3349                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3350                            }
3351                            else {
3352                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3353                            }
3354    
3355                            QueryPos qPos = QueryPos.getInstance(q);
3356    
3357                            qPos.add(groupId);
3358    
3359                            qPos.add(vocabularyId);
3360    
3361                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3362                                    end);
3363                    }
3364                    catch (Exception e) {
3365                            throw processException(e);
3366                    }
3367                    finally {
3368                            closeSession(session);
3369                    }
3370            }
3371    
3372            /**
3373             * Returns the asset categories before and after the current asset category in the ordered set of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3374             *
3375             * @param categoryId the primary key of the current asset category
3376             * @param groupId the group ID
3377             * @param vocabularyId the vocabulary ID
3378             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3379             * @return the previous, current, and next asset category
3380             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3381             * @throws SystemException if a system exception occurred
3382             */
3383            public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3384                    long groupId, long vocabularyId, OrderByComparator orderByComparator)
3385                    throws NoSuchCategoryException, SystemException {
3386                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3387                            return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3388                                    orderByComparator);
3389                    }
3390    
3391                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3392    
3393                    Session session = null;
3394    
3395                    try {
3396                            session = openSession();
3397    
3398                            AssetCategory[] array = new AssetCategoryImpl[3];
3399    
3400                            array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3401                                            groupId, vocabularyId, orderByComparator, true);
3402    
3403                            array[1] = assetCategory;
3404    
3405                            array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3406                                            groupId, vocabularyId, orderByComparator, false);
3407    
3408                            return array;
3409                    }
3410                    catch (Exception e) {
3411                            throw processException(e);
3412                    }
3413                    finally {
3414                            closeSession(session);
3415                    }
3416            }
3417    
3418            protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3419                    AssetCategory assetCategory, long groupId, long vocabularyId,
3420                    OrderByComparator orderByComparator, boolean previous) {
3421                    StringBundler query = null;
3422    
3423                    if (orderByComparator != null) {
3424                            query = new StringBundler(6 +
3425                                            (orderByComparator.getOrderByFields().length * 6));
3426                    }
3427                    else {
3428                            query = new StringBundler(3);
3429                    }
3430    
3431                    if (getDB().isSupportsInlineDistinct()) {
3432                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3433                    }
3434                    else {
3435                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3436                    }
3437    
3438                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3439    
3440                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3441    
3442                    if (!getDB().isSupportsInlineDistinct()) {
3443                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3444                    }
3445    
3446                    if (orderByComparator != null) {
3447                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3448    
3449                            if (orderByConditionFields.length > 0) {
3450                                    query.append(WHERE_AND);
3451                            }
3452    
3453                            for (int i = 0; i < orderByConditionFields.length; i++) {
3454                                    if (getDB().isSupportsInlineDistinct()) {
3455                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3456                                    }
3457                                    else {
3458                                            query.append(_ORDER_BY_ENTITY_TABLE);
3459                                    }
3460    
3461                                    query.append(orderByConditionFields[i]);
3462    
3463                                    if ((i + 1) < orderByConditionFields.length) {
3464                                            if (orderByComparator.isAscending() ^ previous) {
3465                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3466                                            }
3467                                            else {
3468                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3469                                            }
3470                                    }
3471                                    else {
3472                                            if (orderByComparator.isAscending() ^ previous) {
3473                                                    query.append(WHERE_GREATER_THAN);
3474                                            }
3475                                            else {
3476                                                    query.append(WHERE_LESSER_THAN);
3477                                            }
3478                                    }
3479                            }
3480    
3481                            query.append(ORDER_BY_CLAUSE);
3482    
3483                            String[] orderByFields = orderByComparator.getOrderByFields();
3484    
3485                            for (int i = 0; i < orderByFields.length; i++) {
3486                                    if (getDB().isSupportsInlineDistinct()) {
3487                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3488                                    }
3489                                    else {
3490                                            query.append(_ORDER_BY_ENTITY_TABLE);
3491                                    }
3492    
3493                                    query.append(orderByFields[i]);
3494    
3495                                    if ((i + 1) < orderByFields.length) {
3496                                            if (orderByComparator.isAscending() ^ previous) {
3497                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3498                                            }
3499                                            else {
3500                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3501                                            }
3502                                    }
3503                                    else {
3504                                            if (orderByComparator.isAscending() ^ previous) {
3505                                                    query.append(ORDER_BY_ASC);
3506                                            }
3507                                            else {
3508                                                    query.append(ORDER_BY_DESC);
3509                                            }
3510                                    }
3511                            }
3512                    }
3513    
3514                    else {
3515                            if (getDB().isSupportsInlineDistinct()) {
3516                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3517                            }
3518                            else {
3519                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3520                            }
3521                    }
3522    
3523                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3524                                    AssetCategory.class.getName(),
3525                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3526    
3527                    SQLQuery q = session.createSQLQuery(sql);
3528    
3529                    q.setFirstResult(0);
3530                    q.setMaxResults(2);
3531    
3532                    if (getDB().isSupportsInlineDistinct()) {
3533                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3534                    }
3535                    else {
3536                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3537                    }
3538    
3539                    QueryPos qPos = QueryPos.getInstance(q);
3540    
3541                    qPos.add(groupId);
3542    
3543                    qPos.add(vocabularyId);
3544    
3545                    if (orderByComparator != null) {
3546                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3547    
3548                            for (Object value : values) {
3549                                    qPos.add(value);
3550                            }
3551                    }
3552    
3553                    List<AssetCategory> list = q.list();
3554    
3555                    if (list.size() == 2) {
3556                            return list.get(1);
3557                    }
3558                    else {
3559                            return null;
3560                    }
3561            }
3562    
3563            /**
3564             * Returns all the asset categories where parentCategoryId = &#63; and name = &#63;.
3565             *
3566             * @param parentCategoryId the parent category ID
3567             * @param name the name
3568             * @return the matching asset categories
3569             * @throws SystemException if a system exception occurred
3570             */
3571            public List<AssetCategory> findByP_N(long parentCategoryId, String name)
3572                    throws SystemException {
3573                    return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
3574                            QueryUtil.ALL_POS, null);
3575            }
3576    
3577            /**
3578             * Returns a range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
3579             *
3580             * <p>
3581             * 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.
3582             * </p>
3583             *
3584             * @param parentCategoryId the parent category ID
3585             * @param name the name
3586             * @param start the lower bound of the range of asset categories
3587             * @param end the upper bound of the range of asset categories (not inclusive)
3588             * @return the range of matching asset categories
3589             * @throws SystemException if a system exception occurred
3590             */
3591            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3592                    int start, int end) throws SystemException {
3593                    return findByP_N(parentCategoryId, name, start, end, null);
3594            }
3595    
3596            /**
3597             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
3598             *
3599             * <p>
3600             * 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.
3601             * </p>
3602             *
3603             * @param parentCategoryId the parent category ID
3604             * @param name the name
3605             * @param start the lower bound of the range of asset categories
3606             * @param end the upper bound of the range of asset categories (not inclusive)
3607             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3608             * @return the ordered range of matching asset categories
3609             * @throws SystemException if a system exception occurred
3610             */
3611            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
3612                    int start, int end, OrderByComparator orderByComparator)
3613                    throws SystemException {
3614                    FinderPath finderPath = null;
3615                    Object[] finderArgs = null;
3616    
3617                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3618                                    (orderByComparator == null)) {
3619                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
3620                            finderArgs = new Object[] { parentCategoryId, name };
3621                    }
3622                    else {
3623                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
3624                            finderArgs = new Object[] {
3625                                            parentCategoryId, name,
3626                                            
3627                                            start, end, orderByComparator
3628                                    };
3629                    }
3630    
3631                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3632                                    finderArgs, this);
3633    
3634                    if ((list != null) && !list.isEmpty()) {
3635                            for (AssetCategory assetCategory : list) {
3636                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
3637                                                    !Validator.equals(name, assetCategory.getName())) {
3638                                            list = null;
3639    
3640                                            break;
3641                                    }
3642                            }
3643                    }
3644    
3645                    if (list == null) {
3646                            StringBundler query = null;
3647    
3648                            if (orderByComparator != null) {
3649                                    query = new StringBundler(4 +
3650                                                    (orderByComparator.getOrderByFields().length * 3));
3651                            }
3652                            else {
3653                                    query = new StringBundler(4);
3654                            }
3655    
3656                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3657    
3658                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3659    
3660                            if (name == null) {
3661                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
3662                            }
3663                            else {
3664                                    if (name.equals(StringPool.BLANK)) {
3665                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
3666                                    }
3667                                    else {
3668                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
3669                                    }
3670                            }
3671    
3672                            if (orderByComparator != null) {
3673                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3674                                            orderByComparator);
3675                            }
3676    
3677                            else {
3678                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3679                            }
3680    
3681                            String sql = query.toString();
3682    
3683                            Session session = null;
3684    
3685                            try {
3686                                    session = openSession();
3687    
3688                                    Query q = session.createQuery(sql);
3689    
3690                                    QueryPos qPos = QueryPos.getInstance(q);
3691    
3692                                    qPos.add(parentCategoryId);
3693    
3694                                    if (name != null) {
3695                                            qPos.add(name);
3696                                    }
3697    
3698                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3699                                                    start, end);
3700                            }
3701                            catch (Exception e) {
3702                                    throw processException(e);
3703                            }
3704                            finally {
3705                                    if (list == null) {
3706                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3707                                    }
3708                                    else {
3709                                            cacheResult(list);
3710    
3711                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3712                                    }
3713    
3714                                    closeSession(session);
3715                            }
3716                    }
3717    
3718                    return list;
3719            }
3720    
3721            /**
3722             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
3723             *
3724             * <p>
3725             * 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.
3726             * </p>
3727             *
3728             * @param parentCategoryId the parent category ID
3729             * @param name the name
3730             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3731             * @return the first matching asset category
3732             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3733             * @throws SystemException if a system exception occurred
3734             */
3735            public AssetCategory findByP_N_First(long parentCategoryId, String name,
3736                    OrderByComparator orderByComparator)
3737                    throws NoSuchCategoryException, SystemException {
3738                    List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
3739                                    orderByComparator);
3740    
3741                    if (list.isEmpty()) {
3742                            StringBundler msg = new StringBundler(6);
3743    
3744                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3745    
3746                            msg.append("parentCategoryId=");
3747                            msg.append(parentCategoryId);
3748    
3749                            msg.append(", name=");
3750                            msg.append(name);
3751    
3752                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3753    
3754                            throw new NoSuchCategoryException(msg.toString());
3755                    }
3756                    else {
3757                            return list.get(0);
3758                    }
3759            }
3760    
3761            /**
3762             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
3763             *
3764             * <p>
3765             * 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.
3766             * </p>
3767             *
3768             * @param parentCategoryId the parent category ID
3769             * @param name the name
3770             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3771             * @return the last matching asset category
3772             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3773             * @throws SystemException if a system exception occurred
3774             */
3775            public AssetCategory findByP_N_Last(long parentCategoryId, String name,
3776                    OrderByComparator orderByComparator)
3777                    throws NoSuchCategoryException, SystemException {
3778                    int count = countByP_N(parentCategoryId, name);
3779    
3780                    List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
3781                                    count, orderByComparator);
3782    
3783                    if (list.isEmpty()) {
3784                            StringBundler msg = new StringBundler(6);
3785    
3786                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3787    
3788                            msg.append("parentCategoryId=");
3789                            msg.append(parentCategoryId);
3790    
3791                            msg.append(", name=");
3792                            msg.append(name);
3793    
3794                            msg.append(StringPool.CLOSE_CURLY_BRACE);
3795    
3796                            throw new NoSuchCategoryException(msg.toString());
3797                    }
3798                    else {
3799                            return list.get(0);
3800                    }
3801            }
3802    
3803            /**
3804             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
3805             *
3806             * <p>
3807             * 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.
3808             * </p>
3809             *
3810             * @param categoryId the primary key of the current asset category
3811             * @param parentCategoryId the parent category ID
3812             * @param name the name
3813             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3814             * @return the previous, current, and next asset category
3815             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3816             * @throws SystemException if a system exception occurred
3817             */
3818            public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
3819                    long parentCategoryId, String name, OrderByComparator orderByComparator)
3820                    throws NoSuchCategoryException, SystemException {
3821                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3822    
3823                    Session session = null;
3824    
3825                    try {
3826                            session = openSession();
3827    
3828                            AssetCategory[] array = new AssetCategoryImpl[3];
3829    
3830                            array[0] = getByP_N_PrevAndNext(session, assetCategory,
3831                                            parentCategoryId, name, orderByComparator, true);
3832    
3833                            array[1] = assetCategory;
3834    
3835                            array[2] = getByP_N_PrevAndNext(session, assetCategory,
3836                                            parentCategoryId, name, orderByComparator, false);
3837    
3838                            return array;
3839                    }
3840                    catch (Exception e) {
3841                            throw processException(e);
3842                    }
3843                    finally {
3844                            closeSession(session);
3845                    }
3846            }
3847    
3848            protected AssetCategory getByP_N_PrevAndNext(Session session,
3849                    AssetCategory assetCategory, long parentCategoryId, String name,
3850                    OrderByComparator orderByComparator, boolean previous) {
3851                    StringBundler query = null;
3852    
3853                    if (orderByComparator != null) {
3854                            query = new StringBundler(6 +
3855                                            (orderByComparator.getOrderByFields().length * 6));
3856                    }
3857                    else {
3858                            query = new StringBundler(3);
3859                    }
3860    
3861                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3862    
3863                    query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
3864    
3865                    if (name == null) {
3866                            query.append(_FINDER_COLUMN_P_N_NAME_1);
3867                    }
3868                    else {
3869                            if (name.equals(StringPool.BLANK)) {
3870                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
3871                            }
3872                            else {
3873                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
3874                            }
3875                    }
3876    
3877                    if (orderByComparator != null) {
3878                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3879    
3880                            if (orderByConditionFields.length > 0) {
3881                                    query.append(WHERE_AND);
3882                            }
3883    
3884                            for (int i = 0; i < orderByConditionFields.length; i++) {
3885                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3886                                    query.append(orderByConditionFields[i]);
3887    
3888                                    if ((i + 1) < orderByConditionFields.length) {
3889                                            if (orderByComparator.isAscending() ^ previous) {
3890                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3891                                            }
3892                                            else {
3893                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3894                                            }
3895                                    }
3896                                    else {
3897                                            if (orderByComparator.isAscending() ^ previous) {
3898                                                    query.append(WHERE_GREATER_THAN);
3899                                            }
3900                                            else {
3901                                                    query.append(WHERE_LESSER_THAN);
3902                                            }
3903                                    }
3904                            }
3905    
3906                            query.append(ORDER_BY_CLAUSE);
3907    
3908                            String[] orderByFields = orderByComparator.getOrderByFields();
3909    
3910                            for (int i = 0; i < orderByFields.length; i++) {
3911                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3912                                    query.append(orderByFields[i]);
3913    
3914                                    if ((i + 1) < orderByFields.length) {
3915                                            if (orderByComparator.isAscending() ^ previous) {
3916                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3917                                            }
3918                                            else {
3919                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3920                                            }
3921                                    }
3922                                    else {
3923                                            if (orderByComparator.isAscending() ^ previous) {
3924                                                    query.append(ORDER_BY_ASC);
3925                                            }
3926                                            else {
3927                                                    query.append(ORDER_BY_DESC);
3928                                            }
3929                                    }
3930                            }
3931                    }
3932    
3933                    else {
3934                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3935                    }
3936    
3937                    String sql = query.toString();
3938    
3939                    Query q = session.createQuery(sql);
3940    
3941                    q.setFirstResult(0);
3942                    q.setMaxResults(2);
3943    
3944                    QueryPos qPos = QueryPos.getInstance(q);
3945    
3946                    qPos.add(parentCategoryId);
3947    
3948                    if (name != null) {
3949                            qPos.add(name);
3950                    }
3951    
3952                    if (orderByComparator != null) {
3953                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3954    
3955                            for (Object value : values) {
3956                                    qPos.add(value);
3957                            }
3958                    }
3959    
3960                    List<AssetCategory> list = q.list();
3961    
3962                    if (list.size() == 2) {
3963                            return list.get(1);
3964                    }
3965                    else {
3966                            return null;
3967                    }
3968            }
3969    
3970            /**
3971             * Returns all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
3972             *
3973             * @param parentCategoryId the parent category ID
3974             * @param vocabularyId the vocabulary ID
3975             * @return the matching asset categories
3976             * @throws SystemException if a system exception occurred
3977             */
3978            public List<AssetCategory> findByP_V(long parentCategoryId,
3979                    long vocabularyId) throws SystemException {
3980                    return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
3981                            QueryUtil.ALL_POS, null);
3982            }
3983    
3984            /**
3985             * Returns a range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
3986             *
3987             * <p>
3988             * 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.
3989             * </p>
3990             *
3991             * @param parentCategoryId the parent category ID
3992             * @param vocabularyId the vocabulary ID
3993             * @param start the lower bound of the range of asset categories
3994             * @param end the upper bound of the range of asset categories (not inclusive)
3995             * @return the range of matching asset categories
3996             * @throws SystemException if a system exception occurred
3997             */
3998            public List<AssetCategory> findByP_V(long parentCategoryId,
3999                    long vocabularyId, int start, int end) throws SystemException {
4000                    return findByP_V(parentCategoryId, vocabularyId, start, end, null);
4001            }
4002    
4003            /**
4004             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
4005             *
4006             * <p>
4007             * 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.
4008             * </p>
4009             *
4010             * @param parentCategoryId the parent category ID
4011             * @param vocabularyId the vocabulary ID
4012             * @param start the lower bound of the range of asset categories
4013             * @param end the upper bound of the range of asset categories (not inclusive)
4014             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4015             * @return the ordered range of matching asset categories
4016             * @throws SystemException if a system exception occurred
4017             */
4018            public List<AssetCategory> findByP_V(long parentCategoryId,
4019                    long vocabularyId, int start, int end,
4020                    OrderByComparator orderByComparator) throws SystemException {
4021                    FinderPath finderPath = null;
4022                    Object[] finderArgs = null;
4023    
4024                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4025                                    (orderByComparator == null)) {
4026                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
4027                            finderArgs = new Object[] { parentCategoryId, vocabularyId };
4028                    }
4029                    else {
4030                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
4031                            finderArgs = new Object[] {
4032                                            parentCategoryId, vocabularyId,
4033                                            
4034                                            start, end, orderByComparator
4035                                    };
4036                    }
4037    
4038                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4039                                    finderArgs, this);
4040    
4041                    if ((list != null) && !list.isEmpty()) {
4042                            for (AssetCategory assetCategory : list) {
4043                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4044                                                    (vocabularyId != assetCategory.getVocabularyId())) {
4045                                            list = null;
4046    
4047                                            break;
4048                                    }
4049                            }
4050                    }
4051    
4052                    if (list == null) {
4053                            StringBundler query = null;
4054    
4055                            if (orderByComparator != null) {
4056                                    query = new StringBundler(4 +
4057                                                    (orderByComparator.getOrderByFields().length * 3));
4058                            }
4059                            else {
4060                                    query = new StringBundler(4);
4061                            }
4062    
4063                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4064    
4065                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4066    
4067                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4068    
4069                            if (orderByComparator != null) {
4070                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4071                                            orderByComparator);
4072                            }
4073    
4074                            else {
4075                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4076                            }
4077    
4078                            String sql = query.toString();
4079    
4080                            Session session = null;
4081    
4082                            try {
4083                                    session = openSession();
4084    
4085                                    Query q = session.createQuery(sql);
4086    
4087                                    QueryPos qPos = QueryPos.getInstance(q);
4088    
4089                                    qPos.add(parentCategoryId);
4090    
4091                                    qPos.add(vocabularyId);
4092    
4093                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4094                                                    start, end);
4095                            }
4096                            catch (Exception e) {
4097                                    throw processException(e);
4098                            }
4099                            finally {
4100                                    if (list == null) {
4101                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4102                                    }
4103                                    else {
4104                                            cacheResult(list);
4105    
4106                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4107                                    }
4108    
4109                                    closeSession(session);
4110                            }
4111                    }
4112    
4113                    return list;
4114            }
4115    
4116            /**
4117             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4118             *
4119             * <p>
4120             * 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.
4121             * </p>
4122             *
4123             * @param parentCategoryId the parent category ID
4124             * @param vocabularyId the vocabulary ID
4125             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4126             * @return the first matching asset category
4127             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4128             * @throws SystemException if a system exception occurred
4129             */
4130            public AssetCategory findByP_V_First(long parentCategoryId,
4131                    long vocabularyId, OrderByComparator orderByComparator)
4132                    throws NoSuchCategoryException, SystemException {
4133                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4134                                    1, orderByComparator);
4135    
4136                    if (list.isEmpty()) {
4137                            StringBundler msg = new StringBundler(6);
4138    
4139                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4140    
4141                            msg.append("parentCategoryId=");
4142                            msg.append(parentCategoryId);
4143    
4144                            msg.append(", vocabularyId=");
4145                            msg.append(vocabularyId);
4146    
4147                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4148    
4149                            throw new NoSuchCategoryException(msg.toString());
4150                    }
4151                    else {
4152                            return list.get(0);
4153                    }
4154            }
4155    
4156            /**
4157             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4158             *
4159             * <p>
4160             * 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.
4161             * </p>
4162             *
4163             * @param parentCategoryId the parent category ID
4164             * @param vocabularyId the vocabulary ID
4165             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4166             * @return the last matching asset category
4167             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4168             * @throws SystemException if a system exception occurred
4169             */
4170            public AssetCategory findByP_V_Last(long parentCategoryId,
4171                    long vocabularyId, OrderByComparator orderByComparator)
4172                    throws NoSuchCategoryException, SystemException {
4173                    int count = countByP_V(parentCategoryId, vocabularyId);
4174    
4175                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4176                                    count - 1, count, orderByComparator);
4177    
4178                    if (list.isEmpty()) {
4179                            StringBundler msg = new StringBundler(6);
4180    
4181                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4182    
4183                            msg.append("parentCategoryId=");
4184                            msg.append(parentCategoryId);
4185    
4186                            msg.append(", vocabularyId=");
4187                            msg.append(vocabularyId);
4188    
4189                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4190    
4191                            throw new NoSuchCategoryException(msg.toString());
4192                    }
4193                    else {
4194                            return list.get(0);
4195                    }
4196            }
4197    
4198            /**
4199             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4200             *
4201             * <p>
4202             * 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.
4203             * </p>
4204             *
4205             * @param categoryId the primary key of the current asset category
4206             * @param parentCategoryId the parent category ID
4207             * @param vocabularyId the vocabulary ID
4208             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4209             * @return the previous, current, and next asset category
4210             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
4211             * @throws SystemException if a system exception occurred
4212             */
4213            public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4214                    long parentCategoryId, long vocabularyId,
4215                    OrderByComparator orderByComparator)
4216                    throws NoSuchCategoryException, SystemException {
4217                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
4218    
4219                    Session session = null;
4220    
4221                    try {
4222                            session = openSession();
4223    
4224                            AssetCategory[] array = new AssetCategoryImpl[3];
4225    
4226                            array[0] = getByP_V_PrevAndNext(session, assetCategory,
4227                                            parentCategoryId, vocabularyId, orderByComparator, true);
4228    
4229                            array[1] = assetCategory;
4230    
4231                            array[2] = getByP_V_PrevAndNext(session, assetCategory,
4232                                            parentCategoryId, vocabularyId, orderByComparator, false);
4233    
4234                            return array;
4235                    }
4236                    catch (Exception e) {
4237                            throw processException(e);
4238                    }
4239                    finally {
4240                            closeSession(session);
4241                    }
4242            }
4243    
4244            protected AssetCategory getByP_V_PrevAndNext(Session session,
4245                    AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4246                    OrderByComparator orderByComparator, boolean previous) {
4247                    StringBundler query = null;
4248    
4249                    if (orderByComparator != null) {
4250                            query = new StringBundler(6 +
4251                                            (orderByComparator.getOrderByFields().length * 6));
4252                    }
4253                    else {
4254                            query = new StringBundler(3);
4255                    }
4256    
4257                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4258    
4259                    query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4260    
4261                    query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4262    
4263                    if (orderByComparator != null) {
4264                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4265    
4266                            if (orderByConditionFields.length > 0) {
4267                                    query.append(WHERE_AND);
4268                            }
4269    
4270                            for (int i = 0; i < orderByConditionFields.length; i++) {
4271                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4272                                    query.append(orderByConditionFields[i]);
4273    
4274                                    if ((i + 1) < orderByConditionFields.length) {
4275                                            if (orderByComparator.isAscending() ^ previous) {
4276                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4277                                            }
4278                                            else {
4279                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4280                                            }
4281                                    }
4282                                    else {
4283                                            if (orderByComparator.isAscending() ^ previous) {
4284                                                    query.append(WHERE_GREATER_THAN);
4285                                            }
4286                                            else {
4287                                                    query.append(WHERE_LESSER_THAN);
4288                                            }
4289                                    }
4290                            }
4291    
4292                            query.append(ORDER_BY_CLAUSE);
4293    
4294                            String[] orderByFields = orderByComparator.getOrderByFields();
4295    
4296                            for (int i = 0; i < orderByFields.length; i++) {
4297                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4298                                    query.append(orderByFields[i]);
4299    
4300                                    if ((i + 1) < orderByFields.length) {
4301                                            if (orderByComparator.isAscending() ^ previous) {
4302                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4303                                            }
4304                                            else {
4305                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4306                                            }
4307                                    }
4308                                    else {
4309                                            if (orderByComparator.isAscending() ^ previous) {
4310                                                    query.append(ORDER_BY_ASC);
4311                                            }
4312                                            else {
4313                                                    query.append(ORDER_BY_DESC);
4314                                            }
4315                                    }
4316                            }
4317                    }
4318    
4319                    else {
4320                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4321                    }
4322    
4323                    String sql = query.toString();
4324    
4325                    Query q = session.createQuery(sql);
4326    
4327                    q.setFirstResult(0);
4328                    q.setMaxResults(2);
4329    
4330                    QueryPos qPos = QueryPos.getInstance(q);
4331    
4332                    qPos.add(parentCategoryId);
4333    
4334                    qPos.add(vocabularyId);
4335    
4336                    if (orderByComparator != null) {
4337                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4338    
4339                            for (Object value : values) {
4340                                    qPos.add(value);
4341                            }
4342                    }
4343    
4344                    List<AssetCategory> list = q.list();
4345    
4346                    if (list.size() == 2) {
4347                            return list.get(1);
4348                    }
4349                    else {
4350                            return null;
4351                    }
4352            }
4353    
4354            /**
4355             * Returns all the asset categories where name = &#63; and vocabularyId = &#63;.
4356             *
4357             * @param name the name
4358             * @param vocabularyId the vocabulary ID
4359             * @return the matching asset categories
4360             * @throws SystemException if a system exception occurred
4361             */
4362            public List<AssetCategory> findByN_V(String name, long vocabularyId)
4363                    throws SystemException {
4364                    return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
4365                            QueryUtil.ALL_POS, null);
4366            }
4367    
4368            /**
4369             * Returns a range of all the asset categories where name = &#63; and vocabularyId = &#63;.
4370             *
4371             * <p>
4372             * 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.
4373             * </p>
4374             *
4375             * @param name the name
4376             * @param vocabularyId the vocabulary ID
4377             * @param start the lower bound of the range of asset categories
4378             * @param end the upper bound of the range of asset categories (not inclusive)
4379             * @return the range of matching asset categories
4380             * @throws SystemException if a system exception occurred
4381             */
4382            public List<AssetCategory> findByN_V(String name, long vocabularyId,
4383                    int start, int end) throws SystemException {
4384                    return findByN_V(name, vocabularyId, start, end, null);
4385            }
4386    
4387            /**
4388             * Returns an ordered range of all the asset categories where name = &#63; and vocabularyId = &#63;.
4389             *
4390             * <p>
4391             * 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.
4392             * </p>
4393             *
4394             * @param name the name
4395             * @param vocabularyId the vocabulary ID
4396             * @param start the lower bound of the range of asset categories
4397             * @param end the upper bound of the range of asset categories (not inclusive)
4398             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4399             * @return the ordered range of matching asset categories
4400             * @throws SystemException if a system exception occurred
4401             */
4402            public List<AssetCategory> findByN_V(String name, long vocabularyId,
4403                    int start, int end, OrderByComparator orderByComparator)
4404                    throws SystemException {
4405                    FinderPath finderPath = null;
4406                    Object[] finderArgs = null;
4407    
4408                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4409                                    (orderByComparator == null)) {
4410                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
4411                            finderArgs = new Object[] { name, vocabularyId };
4412                    }
4413                    else {
4414                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
4415                            finderArgs = new Object[] {
4416                                            name, vocabularyId,
4417                                            
4418                                            start, end, orderByComparator
4419                                    };
4420                    }
4421    
4422                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4423                                    finderArgs, this);
4424    
4425                    if ((list != null) && !list.isEmpty()) {
4426                            for (AssetCategory assetCategory : list) {
4427                                    if (!Validator.equals(name, assetCategory.getName()) ||
4428                                                    (vocabularyId != assetCategory.getVocabularyId())) {
4429                                            list = null;
4430    
4431                                            break;
4432                                    }
4433                            }
4434                    }
4435    
4436                    if (list == null) {
4437                            StringBundler query = null;
4438    
4439                            if (orderByComparator != null) {
4440                                    query = new StringBundler(4 +
4441                                                    (orderByComparator.getOrderByFields().length * 3));
4442                            }
4443                            else {
4444                                    query = new StringBundler(4);
4445                            }
4446    
4447                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4448    
4449                            if (name == null) {
4450                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
4451                            }
4452                            else {
4453                                    if (name.equals(StringPool.BLANK)) {
4454                                            query.append(_FINDER_COLUMN_N_V_NAME_3);
4455                                    }
4456                                    else {
4457                                            query.append(_FINDER_COLUMN_N_V_NAME_2);
4458                                    }
4459                            }
4460    
4461                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4462    
4463                            if (orderByComparator != null) {
4464                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4465                                            orderByComparator);
4466                            }
4467    
4468                            else {
4469                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4470                            }
4471    
4472                            String sql = query.toString();
4473    
4474                            Session session = null;
4475    
4476                            try {
4477                                    session = openSession();
4478    
4479                                    Query q = session.createQuery(sql);
4480    
4481                                    QueryPos qPos = QueryPos.getInstance(q);
4482    
4483                                    if (name != null) {
4484                                            qPos.add(name);
4485                                    }
4486    
4487                                    qPos.add(vocabularyId);
4488    
4489                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4490                                                    start, end);
4491                            }
4492                            catch (Exception e) {
4493                                    throw processException(e);
4494                            }
4495                            finally {
4496                                    if (list == null) {
4497                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4498                                    }
4499                                    else {
4500                                            cacheResult(list);
4501    
4502                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4503                                    }
4504    
4505                                    closeSession(session);
4506                            }
4507                    }
4508    
4509                    return list;
4510            }
4511    
4512            /**
4513             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
4514             *
4515             * <p>
4516             * 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.
4517             * </p>
4518             *
4519             * @param name the name
4520             * @param vocabularyId the vocabulary ID
4521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4522             * @return the first matching asset category
4523             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4524             * @throws SystemException if a system exception occurred
4525             */
4526            public AssetCategory findByN_V_First(String name, long vocabularyId,
4527                    OrderByComparator orderByComparator)
4528                    throws NoSuchCategoryException, SystemException {
4529                    List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
4530                                    orderByComparator);
4531    
4532                    if (list.isEmpty()) {
4533                            StringBundler msg = new StringBundler(6);
4534    
4535                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4536    
4537                            msg.append("name=");
4538                            msg.append(name);
4539    
4540                            msg.append(", vocabularyId=");
4541                            msg.append(vocabularyId);
4542    
4543                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4544    
4545                            throw new NoSuchCategoryException(msg.toString());
4546                    }
4547                    else {
4548                            return list.get(0);
4549                    }
4550            }
4551    
4552            /**
4553             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
4554             *
4555             * <p>
4556             * 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.
4557             * </p>
4558             *
4559             * @param name the name
4560             * @param vocabularyId the vocabulary ID
4561             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4562             * @return the last matching asset category
4563             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4564             * @throws SystemException if a system exception occurred
4565             */
4566            public AssetCategory findByN_V_Last(String name, long vocabularyId,
4567                    OrderByComparator orderByComparator)
4568                    throws NoSuchCategoryException, SystemException {
4569                    int count = countByN_V(name, vocabularyId);
4570    
4571                    List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
4572                                    count, orderByComparator);
4573    
4574                    if (list.isEmpty()) {
4575                            StringBundler msg = new StringBundler(6);
4576    
4577                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4578    
4579                            msg.append("name=");
4580                            msg.append(name);
4581    
4582                            msg.append(", vocabularyId=");
4583                            msg.append(vocabularyId);
4584    
4585                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4586    
4587                            throw new NoSuchCategoryException(msg.toString());
4588                    }
4589                    else {
4590                            return list.get(0);
4591                    }
4592            }
4593    
4594            /**
4595             * Returns the asset categories before and after the current asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
4596             *
4597             * <p>
4598             * 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.
4599             * </p>
4600             *
4601             * @param categoryId the primary key of the current asset category
4602             * @param name the name
4603             * @param vocabularyId the vocabulary ID
4604             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4605             * @return the previous, current, and next asset category
4606             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
4607             * @throws SystemException if a system exception occurred
4608             */
4609            public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
4610                    long vocabularyId, OrderByComparator orderByComparator)
4611                    throws NoSuchCategoryException, SystemException {
4612                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
4613    
4614                    Session session = null;
4615    
4616                    try {
4617                            session = openSession();
4618    
4619                            AssetCategory[] array = new AssetCategoryImpl[3];
4620    
4621                            array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
4622                                            vocabularyId, orderByComparator, true);
4623    
4624                            array[1] = assetCategory;
4625    
4626                            array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
4627                                            vocabularyId, orderByComparator, false);
4628    
4629                            return array;
4630                    }
4631                    catch (Exception e) {
4632                            throw processException(e);
4633                    }
4634                    finally {
4635                            closeSession(session);
4636                    }
4637            }
4638    
4639            protected AssetCategory getByN_V_PrevAndNext(Session session,
4640                    AssetCategory assetCategory, String name, long vocabularyId,
4641                    OrderByComparator orderByComparator, boolean previous) {
4642                    StringBundler query = null;
4643    
4644                    if (orderByComparator != null) {
4645                            query = new StringBundler(6 +
4646                                            (orderByComparator.getOrderByFields().length * 6));
4647                    }
4648                    else {
4649                            query = new StringBundler(3);
4650                    }
4651    
4652                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4653    
4654                    if (name == null) {
4655                            query.append(_FINDER_COLUMN_N_V_NAME_1);
4656                    }
4657                    else {
4658                            if (name.equals(StringPool.BLANK)) {
4659                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
4660                            }
4661                            else {
4662                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
4663                            }
4664                    }
4665    
4666                    query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
4667    
4668                    if (orderByComparator != null) {
4669                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4670    
4671                            if (orderByConditionFields.length > 0) {
4672                                    query.append(WHERE_AND);
4673                            }
4674    
4675                            for (int i = 0; i < orderByConditionFields.length; i++) {
4676                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4677                                    query.append(orderByConditionFields[i]);
4678    
4679                                    if ((i + 1) < orderByConditionFields.length) {
4680                                            if (orderByComparator.isAscending() ^ previous) {
4681                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4682                                            }
4683                                            else {
4684                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4685                                            }
4686                                    }
4687                                    else {
4688                                            if (orderByComparator.isAscending() ^ previous) {
4689                                                    query.append(WHERE_GREATER_THAN);
4690                                            }
4691                                            else {
4692                                                    query.append(WHERE_LESSER_THAN);
4693                                            }
4694                                    }
4695                            }
4696    
4697                            query.append(ORDER_BY_CLAUSE);
4698    
4699                            String[] orderByFields = orderByComparator.getOrderByFields();
4700    
4701                            for (int i = 0; i < orderByFields.length; i++) {
4702                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4703                                    query.append(orderByFields[i]);
4704    
4705                                    if ((i + 1) < orderByFields.length) {
4706                                            if (orderByComparator.isAscending() ^ previous) {
4707                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4708                                            }
4709                                            else {
4710                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4711                                            }
4712                                    }
4713                                    else {
4714                                            if (orderByComparator.isAscending() ^ previous) {
4715                                                    query.append(ORDER_BY_ASC);
4716                                            }
4717                                            else {
4718                                                    query.append(ORDER_BY_DESC);
4719                                            }
4720                                    }
4721                            }
4722                    }
4723    
4724                    else {
4725                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4726                    }
4727    
4728                    String sql = query.toString();
4729    
4730                    Query q = session.createQuery(sql);
4731    
4732                    q.setFirstResult(0);
4733                    q.setMaxResults(2);
4734    
4735                    QueryPos qPos = QueryPos.getInstance(q);
4736    
4737                    if (name != null) {
4738                            qPos.add(name);
4739                    }
4740    
4741                    qPos.add(vocabularyId);
4742    
4743                    if (orderByComparator != null) {
4744                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4745    
4746                            for (Object value : values) {
4747                                    qPos.add(value);
4748                            }
4749                    }
4750    
4751                    List<AssetCategory> list = q.list();
4752    
4753                    if (list.size() == 2) {
4754                            return list.get(1);
4755                    }
4756                    else {
4757                            return null;
4758                    }
4759            }
4760    
4761            /**
4762             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
4763             *
4764             * @param parentCategoryId the parent category ID
4765             * @param name the name
4766             * @param vocabularyId the vocabulary ID
4767             * @return the matching asset category
4768             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4769             * @throws SystemException if a system exception occurred
4770             */
4771            public AssetCategory findByP_N_V(long parentCategoryId, String name,
4772                    long vocabularyId) throws NoSuchCategoryException, SystemException {
4773                    AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
4774                                    vocabularyId);
4775    
4776                    if (assetCategory == null) {
4777                            StringBundler msg = new StringBundler(8);
4778    
4779                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4780    
4781                            msg.append("parentCategoryId=");
4782                            msg.append(parentCategoryId);
4783    
4784                            msg.append(", name=");
4785                            msg.append(name);
4786    
4787                            msg.append(", vocabularyId=");
4788                            msg.append(vocabularyId);
4789    
4790                            msg.append(StringPool.CLOSE_CURLY_BRACE);
4791    
4792                            if (_log.isWarnEnabled()) {
4793                                    _log.warn(msg.toString());
4794                            }
4795    
4796                            throw new NoSuchCategoryException(msg.toString());
4797                    }
4798    
4799                    return assetCategory;
4800            }
4801    
4802            /**
4803             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
4804             *
4805             * @param parentCategoryId the parent category ID
4806             * @param name the name
4807             * @param vocabularyId the vocabulary ID
4808             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
4809             * @throws SystemException if a system exception occurred
4810             */
4811            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4812                    long vocabularyId) throws SystemException {
4813                    return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
4814            }
4815    
4816            /**
4817             * Returns the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
4818             *
4819             * @param parentCategoryId the parent category ID
4820             * @param name the name
4821             * @param vocabularyId the vocabulary ID
4822             * @param retrieveFromCache whether to use the finder cache
4823             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
4824             * @throws SystemException if a system exception occurred
4825             */
4826            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
4827                    long vocabularyId, boolean retrieveFromCache) throws SystemException {
4828                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
4829    
4830                    Object result = null;
4831    
4832                    if (retrieveFromCache) {
4833                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
4834                                            finderArgs, this);
4835                    }
4836    
4837                    if (result instanceof AssetCategory) {
4838                            AssetCategory assetCategory = (AssetCategory)result;
4839    
4840                            if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4841                                            !Validator.equals(name, assetCategory.getName()) ||
4842                                            (vocabularyId != assetCategory.getVocabularyId())) {
4843                                    result = null;
4844                            }
4845                    }
4846    
4847                    if (result == null) {
4848                            StringBundler query = new StringBundler(5);
4849    
4850                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4851    
4852                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
4853    
4854                            if (name == null) {
4855                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
4856                            }
4857                            else {
4858                                    if (name.equals(StringPool.BLANK)) {
4859                                            query.append(_FINDER_COLUMN_P_N_V_NAME_3);
4860                                    }
4861                                    else {
4862                                            query.append(_FINDER_COLUMN_P_N_V_NAME_2);
4863                                    }
4864                            }
4865    
4866                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
4867    
4868                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4869    
4870                            String sql = query.toString();
4871    
4872                            Session session = null;
4873    
4874                            try {
4875                                    session = openSession();
4876    
4877                                    Query q = session.createQuery(sql);
4878    
4879                                    QueryPos qPos = QueryPos.getInstance(q);
4880    
4881                                    qPos.add(parentCategoryId);
4882    
4883                                    if (name != null) {
4884                                            qPos.add(name);
4885                                    }
4886    
4887                                    qPos.add(vocabularyId);
4888    
4889                                    List<AssetCategory> list = q.list();
4890    
4891                                    result = list;
4892    
4893                                    AssetCategory assetCategory = null;
4894    
4895                                    if (list.isEmpty()) {
4896                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4897                                                    finderArgs, list);
4898                                    }
4899                                    else {
4900                                            assetCategory = list.get(0);
4901    
4902                                            cacheResult(assetCategory);
4903    
4904                                            if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
4905                                                            (assetCategory.getName() == null) ||
4906                                                            !assetCategory.getName().equals(name) ||
4907                                                            (assetCategory.getVocabularyId() != vocabularyId)) {
4908                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
4909                                                            finderArgs, assetCategory);
4910                                            }
4911                                    }
4912    
4913                                    return assetCategory;
4914                            }
4915                            catch (Exception e) {
4916                                    throw processException(e);
4917                            }
4918                            finally {
4919                                    if (result == null) {
4920                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
4921                                                    finderArgs);
4922                                    }
4923    
4924                                    closeSession(session);
4925                            }
4926                    }
4927                    else {
4928                            if (result instanceof List<?>) {
4929                                    return null;
4930                            }
4931                            else {
4932                                    return (AssetCategory)result;
4933                            }
4934                    }
4935            }
4936    
4937            /**
4938             * Returns all the asset categories.
4939             *
4940             * @return the asset categories
4941             * @throws SystemException if a system exception occurred
4942             */
4943            public List<AssetCategory> findAll() throws SystemException {
4944                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
4945            }
4946    
4947            /**
4948             * Returns a range of all the asset categories.
4949             *
4950             * <p>
4951             * 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.
4952             * </p>
4953             *
4954             * @param start the lower bound of the range of asset categories
4955             * @param end the upper bound of the range of asset categories (not inclusive)
4956             * @return the range of asset categories
4957             * @throws SystemException if a system exception occurred
4958             */
4959            public List<AssetCategory> findAll(int start, int end)
4960                    throws SystemException {
4961                    return findAll(start, end, null);
4962            }
4963    
4964            /**
4965             * Returns an ordered range of all the asset categories.
4966             *
4967             * <p>
4968             * 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.
4969             * </p>
4970             *
4971             * @param start the lower bound of the range of asset categories
4972             * @param end the upper bound of the range of asset categories (not inclusive)
4973             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4974             * @return the ordered range of asset categories
4975             * @throws SystemException if a system exception occurred
4976             */
4977            public List<AssetCategory> findAll(int start, int end,
4978                    OrderByComparator orderByComparator) throws SystemException {
4979                    FinderPath finderPath = null;
4980                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
4981    
4982                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4983                                    (orderByComparator == null)) {
4984                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
4985                            finderArgs = FINDER_ARGS_EMPTY;
4986                    }
4987                    else {
4988                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
4989                            finderArgs = new Object[] { start, end, orderByComparator };
4990                    }
4991    
4992                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4993                                    finderArgs, this);
4994    
4995                    if (list == null) {
4996                            StringBundler query = null;
4997                            String sql = null;
4998    
4999                            if (orderByComparator != null) {
5000                                    query = new StringBundler(2 +
5001                                                    (orderByComparator.getOrderByFields().length * 3));
5002    
5003                                    query.append(_SQL_SELECT_ASSETCATEGORY);
5004    
5005                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5006                                            orderByComparator);
5007    
5008                                    sql = query.toString();
5009                            }
5010                            else {
5011                                    sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
5012                            }
5013    
5014                            Session session = null;
5015    
5016                            try {
5017                                    session = openSession();
5018    
5019                                    Query q = session.createQuery(sql);
5020    
5021                                    if (orderByComparator == null) {
5022                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5023                                                            start, end, false);
5024    
5025                                            Collections.sort(list);
5026                                    }
5027                                    else {
5028                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5029                                                            start, end);
5030                                    }
5031                            }
5032                            catch (Exception e) {
5033                                    throw processException(e);
5034                            }
5035                            finally {
5036                                    if (list == null) {
5037                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5038                                    }
5039                                    else {
5040                                            cacheResult(list);
5041    
5042                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5043                                    }
5044    
5045                                    closeSession(session);
5046                            }
5047                    }
5048    
5049                    return list;
5050            }
5051    
5052            /**
5053             * Removes all the asset categories where uuid = &#63; from the database.
5054             *
5055             * @param uuid the uuid
5056             * @throws SystemException if a system exception occurred
5057             */
5058            public void removeByUuid(String uuid) throws SystemException {
5059                    for (AssetCategory assetCategory : findByUuid(uuid)) {
5060                            remove(assetCategory);
5061                    }
5062            }
5063    
5064            /**
5065             * Removes the asset category where uuid = &#63; and groupId = &#63; from the database.
5066             *
5067             * @param uuid the uuid
5068             * @param groupId the group ID
5069             * @throws SystemException if a system exception occurred
5070             */
5071            public void removeByUUID_G(String uuid, long groupId)
5072                    throws NoSuchCategoryException, SystemException {
5073                    AssetCategory assetCategory = findByUUID_G(uuid, groupId);
5074    
5075                    remove(assetCategory);
5076            }
5077    
5078            /**
5079             * Removes all the asset categories where groupId = &#63; from the database.
5080             *
5081             * @param groupId the group ID
5082             * @throws SystemException if a system exception occurred
5083             */
5084            public void removeByGroupId(long groupId) throws SystemException {
5085                    for (AssetCategory assetCategory : findByGroupId(groupId)) {
5086                            remove(assetCategory);
5087                    }
5088            }
5089    
5090            /**
5091             * Removes all the asset categories where parentCategoryId = &#63; from the database.
5092             *
5093             * @param parentCategoryId the parent category ID
5094             * @throws SystemException if a system exception occurred
5095             */
5096            public void removeByParentCategoryId(long parentCategoryId)
5097                    throws SystemException {
5098                    for (AssetCategory assetCategory : findByParentCategoryId(
5099                                    parentCategoryId)) {
5100                            remove(assetCategory);
5101                    }
5102            }
5103    
5104            /**
5105             * Removes all the asset categories where vocabularyId = &#63; from the database.
5106             *
5107             * @param vocabularyId the vocabulary ID
5108             * @throws SystemException if a system exception occurred
5109             */
5110            public void removeByVocabularyId(long vocabularyId)
5111                    throws SystemException {
5112                    for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
5113                            remove(assetCategory);
5114                    }
5115            }
5116    
5117            /**
5118             * Removes all the asset categories where groupId = &#63; and vocabularyId = &#63; from the database.
5119             *
5120             * @param groupId the group ID
5121             * @param vocabularyId the vocabulary ID
5122             * @throws SystemException if a system exception occurred
5123             */
5124            public void removeByG_V(long groupId, long vocabularyId)
5125                    throws SystemException {
5126                    for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
5127                            remove(assetCategory);
5128                    }
5129            }
5130    
5131            /**
5132             * Removes all the asset categories where parentCategoryId = &#63; and name = &#63; from the database.
5133             *
5134             * @param parentCategoryId the parent category ID
5135             * @param name the name
5136             * @throws SystemException if a system exception occurred
5137             */
5138            public void removeByP_N(long parentCategoryId, String name)
5139                    throws SystemException {
5140                    for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
5141                            remove(assetCategory);
5142                    }
5143            }
5144    
5145            /**
5146             * Removes all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63; from the database.
5147             *
5148             * @param parentCategoryId the parent category ID
5149             * @param vocabularyId the vocabulary ID
5150             * @throws SystemException if a system exception occurred
5151             */
5152            public void removeByP_V(long parentCategoryId, long vocabularyId)
5153                    throws SystemException {
5154                    for (AssetCategory assetCategory : findByP_V(parentCategoryId,
5155                                    vocabularyId)) {
5156                            remove(assetCategory);
5157                    }
5158            }
5159    
5160            /**
5161             * Removes all the asset categories where name = &#63; and vocabularyId = &#63; from the database.
5162             *
5163             * @param name the name
5164             * @param vocabularyId the vocabulary ID
5165             * @throws SystemException if a system exception occurred
5166             */
5167            public void removeByN_V(String name, long vocabularyId)
5168                    throws SystemException {
5169                    for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
5170                            remove(assetCategory);
5171                    }
5172            }
5173    
5174            /**
5175             * Removes the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
5176             *
5177             * @param parentCategoryId the parent category ID
5178             * @param name the name
5179             * @param vocabularyId the vocabulary ID
5180             * @throws SystemException if a system exception occurred
5181             */
5182            public void removeByP_N_V(long parentCategoryId, String name,
5183                    long vocabularyId) throws NoSuchCategoryException, SystemException {
5184                    AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
5185                                    vocabularyId);
5186    
5187                    remove(assetCategory);
5188            }
5189    
5190            /**
5191             * Removes all the asset categories from the database.
5192             *
5193             * @throws SystemException if a system exception occurred
5194             */
5195            public void removeAll() throws SystemException {
5196                    for (AssetCategory assetCategory : findAll()) {
5197                            remove(assetCategory);
5198                    }
5199            }
5200    
5201            /**
5202             * Returns the number of asset categories where uuid = &#63;.
5203             *
5204             * @param uuid the uuid
5205             * @return the number of matching asset categories
5206             * @throws SystemException if a system exception occurred
5207             */
5208            public int countByUuid(String uuid) throws SystemException {
5209                    Object[] finderArgs = new Object[] { uuid };
5210    
5211                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
5212                                    finderArgs, this);
5213    
5214                    if (count == null) {
5215                            StringBundler query = new StringBundler(2);
5216    
5217                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5218    
5219                            if (uuid == null) {
5220                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
5221                            }
5222                            else {
5223                                    if (uuid.equals(StringPool.BLANK)) {
5224                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
5225                                    }
5226                                    else {
5227                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
5228                                    }
5229                            }
5230    
5231                            String sql = query.toString();
5232    
5233                            Session session = null;
5234    
5235                            try {
5236                                    session = openSession();
5237    
5238                                    Query q = session.createQuery(sql);
5239    
5240                                    QueryPos qPos = QueryPos.getInstance(q);
5241    
5242                                    if (uuid != null) {
5243                                            qPos.add(uuid);
5244                                    }
5245    
5246                                    count = (Long)q.uniqueResult();
5247                            }
5248                            catch (Exception e) {
5249                                    throw processException(e);
5250                            }
5251                            finally {
5252                                    if (count == null) {
5253                                            count = Long.valueOf(0);
5254                                    }
5255    
5256                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
5257                                            finderArgs, count);
5258    
5259                                    closeSession(session);
5260                            }
5261                    }
5262    
5263                    return count.intValue();
5264            }
5265    
5266            /**
5267             * Returns the number of asset categories where uuid = &#63; and groupId = &#63;.
5268             *
5269             * @param uuid the uuid
5270             * @param groupId the group ID
5271             * @return the number of matching asset categories
5272             * @throws SystemException if a system exception occurred
5273             */
5274            public int countByUUID_G(String uuid, long groupId)
5275                    throws SystemException {
5276                    Object[] finderArgs = new Object[] { uuid, groupId };
5277    
5278                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
5279                                    finderArgs, this);
5280    
5281                    if (count == null) {
5282                            StringBundler query = new StringBundler(3);
5283    
5284                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5285    
5286                            if (uuid == null) {
5287                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
5288                            }
5289                            else {
5290                                    if (uuid.equals(StringPool.BLANK)) {
5291                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
5292                                    }
5293                                    else {
5294                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
5295                                    }
5296                            }
5297    
5298                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
5299    
5300                            String sql = query.toString();
5301    
5302                            Session session = null;
5303    
5304                            try {
5305                                    session = openSession();
5306    
5307                                    Query q = session.createQuery(sql);
5308    
5309                                    QueryPos qPos = QueryPos.getInstance(q);
5310    
5311                                    if (uuid != null) {
5312                                            qPos.add(uuid);
5313                                    }
5314    
5315                                    qPos.add(groupId);
5316    
5317                                    count = (Long)q.uniqueResult();
5318                            }
5319                            catch (Exception e) {
5320                                    throw processException(e);
5321                            }
5322                            finally {
5323                                    if (count == null) {
5324                                            count = Long.valueOf(0);
5325                                    }
5326    
5327                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
5328                                            finderArgs, count);
5329    
5330                                    closeSession(session);
5331                            }
5332                    }
5333    
5334                    return count.intValue();
5335            }
5336    
5337            /**
5338             * Returns the number of asset categories where groupId = &#63;.
5339             *
5340             * @param groupId the group ID
5341             * @return the number of matching asset categories
5342             * @throws SystemException if a system exception occurred
5343             */
5344            public int countByGroupId(long groupId) throws SystemException {
5345                    Object[] finderArgs = new Object[] { groupId };
5346    
5347                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
5348                                    finderArgs, this);
5349    
5350                    if (count == null) {
5351                            StringBundler query = new StringBundler(2);
5352    
5353                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5354    
5355                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5356    
5357                            String sql = query.toString();
5358    
5359                            Session session = null;
5360    
5361                            try {
5362                                    session = openSession();
5363    
5364                                    Query q = session.createQuery(sql);
5365    
5366                                    QueryPos qPos = QueryPos.getInstance(q);
5367    
5368                                    qPos.add(groupId);
5369    
5370                                    count = (Long)q.uniqueResult();
5371                            }
5372                            catch (Exception e) {
5373                                    throw processException(e);
5374                            }
5375                            finally {
5376                                    if (count == null) {
5377                                            count = Long.valueOf(0);
5378                                    }
5379    
5380                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
5381                                            finderArgs, count);
5382    
5383                                    closeSession(session);
5384                            }
5385                    }
5386    
5387                    return count.intValue();
5388            }
5389    
5390            /**
5391             * Returns the number of asset categories that the user has permission to view where groupId = &#63;.
5392             *
5393             * @param groupId the group ID
5394             * @return the number of matching asset categories that the user has permission to view
5395             * @throws SystemException if a system exception occurred
5396             */
5397            public int filterCountByGroupId(long groupId) throws SystemException {
5398                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5399                            return countByGroupId(groupId);
5400                    }
5401    
5402                    StringBundler query = new StringBundler(2);
5403    
5404                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5405    
5406                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
5407    
5408                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5409                                    AssetCategory.class.getName(),
5410                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5411    
5412                    Session session = null;
5413    
5414                    try {
5415                            session = openSession();
5416    
5417                            SQLQuery q = session.createSQLQuery(sql);
5418    
5419                            q.addScalar(COUNT_COLUMN_NAME,
5420                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5421    
5422                            QueryPos qPos = QueryPos.getInstance(q);
5423    
5424                            qPos.add(groupId);
5425    
5426                            Long count = (Long)q.uniqueResult();
5427    
5428                            return count.intValue();
5429                    }
5430                    catch (Exception e) {
5431                            throw processException(e);
5432                    }
5433                    finally {
5434                            closeSession(session);
5435                    }
5436            }
5437    
5438            /**
5439             * Returns the number of asset categories where parentCategoryId = &#63;.
5440             *
5441             * @param parentCategoryId the parent category ID
5442             * @return the number of matching asset categories
5443             * @throws SystemException if a system exception occurred
5444             */
5445            public int countByParentCategoryId(long parentCategoryId)
5446                    throws SystemException {
5447                    Object[] finderArgs = new Object[] { parentCategoryId };
5448    
5449                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5450                                    finderArgs, this);
5451    
5452                    if (count == null) {
5453                            StringBundler query = new StringBundler(2);
5454    
5455                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5456    
5457                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
5458    
5459                            String sql = query.toString();
5460    
5461                            Session session = null;
5462    
5463                            try {
5464                                    session = openSession();
5465    
5466                                    Query q = session.createQuery(sql);
5467    
5468                                    QueryPos qPos = QueryPos.getInstance(q);
5469    
5470                                    qPos.add(parentCategoryId);
5471    
5472                                    count = (Long)q.uniqueResult();
5473                            }
5474                            catch (Exception e) {
5475                                    throw processException(e);
5476                            }
5477                            finally {
5478                                    if (count == null) {
5479                                            count = Long.valueOf(0);
5480                                    }
5481    
5482                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
5483                                            finderArgs, count);
5484    
5485                                    closeSession(session);
5486                            }
5487                    }
5488    
5489                    return count.intValue();
5490            }
5491    
5492            /**
5493             * Returns the number of asset categories where vocabularyId = &#63;.
5494             *
5495             * @param vocabularyId the vocabulary ID
5496             * @return the number of matching asset categories
5497             * @throws SystemException if a system exception occurred
5498             */
5499            public int countByVocabularyId(long vocabularyId) throws SystemException {
5500                    Object[] finderArgs = new Object[] { vocabularyId };
5501    
5502                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5503                                    finderArgs, this);
5504    
5505                    if (count == null) {
5506                            StringBundler query = new StringBundler(2);
5507    
5508                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5509    
5510                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
5511    
5512                            String sql = query.toString();
5513    
5514                            Session session = null;
5515    
5516                            try {
5517                                    session = openSession();
5518    
5519                                    Query q = session.createQuery(sql);
5520    
5521                                    QueryPos qPos = QueryPos.getInstance(q);
5522    
5523                                    qPos.add(vocabularyId);
5524    
5525                                    count = (Long)q.uniqueResult();
5526                            }
5527                            catch (Exception e) {
5528                                    throw processException(e);
5529                            }
5530                            finally {
5531                                    if (count == null) {
5532                                            count = Long.valueOf(0);
5533                                    }
5534    
5535                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
5536                                            finderArgs, count);
5537    
5538                                    closeSession(session);
5539                            }
5540                    }
5541    
5542                    return count.intValue();
5543            }
5544    
5545            /**
5546             * Returns the number of asset categories where groupId = &#63; and vocabularyId = &#63;.
5547             *
5548             * @param groupId the group ID
5549             * @param vocabularyId the vocabulary ID
5550             * @return the number of matching asset categories
5551             * @throws SystemException if a system exception occurred
5552             */
5553            public int countByG_V(long groupId, long vocabularyId)
5554                    throws SystemException {
5555                    Object[] finderArgs = new Object[] { groupId, vocabularyId };
5556    
5557                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
5558                                    finderArgs, this);
5559    
5560                    if (count == null) {
5561                            StringBundler query = new StringBundler(3);
5562    
5563                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5564    
5565                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5566    
5567                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5568    
5569                            String sql = query.toString();
5570    
5571                            Session session = null;
5572    
5573                            try {
5574                                    session = openSession();
5575    
5576                                    Query q = session.createQuery(sql);
5577    
5578                                    QueryPos qPos = QueryPos.getInstance(q);
5579    
5580                                    qPos.add(groupId);
5581    
5582                                    qPos.add(vocabularyId);
5583    
5584                                    count = (Long)q.uniqueResult();
5585                            }
5586                            catch (Exception e) {
5587                                    throw processException(e);
5588                            }
5589                            finally {
5590                                    if (count == null) {
5591                                            count = Long.valueOf(0);
5592                                    }
5593    
5594                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
5595                                            count);
5596    
5597                                    closeSession(session);
5598                            }
5599                    }
5600    
5601                    return count.intValue();
5602            }
5603    
5604            /**
5605             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
5606             *
5607             * @param groupId the group ID
5608             * @param vocabularyId the vocabulary ID
5609             * @return the number of matching asset categories that the user has permission to view
5610             * @throws SystemException if a system exception occurred
5611             */
5612            public int filterCountByG_V(long groupId, long vocabularyId)
5613                    throws SystemException {
5614                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5615                            return countByG_V(groupId, vocabularyId);
5616                    }
5617    
5618                    StringBundler query = new StringBundler(3);
5619    
5620                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
5621    
5622                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
5623    
5624                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
5625    
5626                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
5627                                    AssetCategory.class.getName(),
5628                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
5629    
5630                    Session session = null;
5631    
5632                    try {
5633                            session = openSession();
5634    
5635                            SQLQuery q = session.createSQLQuery(sql);
5636    
5637                            q.addScalar(COUNT_COLUMN_NAME,
5638                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
5639    
5640                            QueryPos qPos = QueryPos.getInstance(q);
5641    
5642                            qPos.add(groupId);
5643    
5644                            qPos.add(vocabularyId);
5645    
5646                            Long count = (Long)q.uniqueResult();
5647    
5648                            return count.intValue();
5649                    }
5650                    catch (Exception e) {
5651                            throw processException(e);
5652                    }
5653                    finally {
5654                            closeSession(session);
5655                    }
5656            }
5657    
5658            /**
5659             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63;.
5660             *
5661             * @param parentCategoryId the parent category ID
5662             * @param name the name
5663             * @return the number of matching asset categories
5664             * @throws SystemException if a system exception occurred
5665             */
5666            public int countByP_N(long parentCategoryId, String name)
5667                    throws SystemException {
5668                    Object[] finderArgs = new Object[] { parentCategoryId, name };
5669    
5670                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
5671                                    finderArgs, this);
5672    
5673                    if (count == null) {
5674                            StringBundler query = new StringBundler(3);
5675    
5676                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5677    
5678                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
5679    
5680                            if (name == null) {
5681                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
5682                            }
5683                            else {
5684                                    if (name.equals(StringPool.BLANK)) {
5685                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
5686                                    }
5687                                    else {
5688                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
5689                                    }
5690                            }
5691    
5692                            String sql = query.toString();
5693    
5694                            Session session = null;
5695    
5696                            try {
5697                                    session = openSession();
5698    
5699                                    Query q = session.createQuery(sql);
5700    
5701                                    QueryPos qPos = QueryPos.getInstance(q);
5702    
5703                                    qPos.add(parentCategoryId);
5704    
5705                                    if (name != null) {
5706                                            qPos.add(name);
5707                                    }
5708    
5709                                    count = (Long)q.uniqueResult();
5710                            }
5711                            catch (Exception e) {
5712                                    throw processException(e);
5713                            }
5714                            finally {
5715                                    if (count == null) {
5716                                            count = Long.valueOf(0);
5717                                    }
5718    
5719                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
5720                                            count);
5721    
5722                                    closeSession(session);
5723                            }
5724                    }
5725    
5726                    return count.intValue();
5727            }
5728    
5729            /**
5730             * Returns the number of asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
5731             *
5732             * @param parentCategoryId the parent category ID
5733             * @param vocabularyId the vocabulary ID
5734             * @return the number of matching asset categories
5735             * @throws SystemException if a system exception occurred
5736             */
5737            public int countByP_V(long parentCategoryId, long vocabularyId)
5738                    throws SystemException {
5739                    Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
5740    
5741                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
5742                                    finderArgs, this);
5743    
5744                    if (count == null) {
5745                            StringBundler query = new StringBundler(3);
5746    
5747                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5748    
5749                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
5750    
5751                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
5752    
5753                            String sql = query.toString();
5754    
5755                            Session session = null;
5756    
5757                            try {
5758                                    session = openSession();
5759    
5760                                    Query q = session.createQuery(sql);
5761    
5762                                    QueryPos qPos = QueryPos.getInstance(q);
5763    
5764                                    qPos.add(parentCategoryId);
5765    
5766                                    qPos.add(vocabularyId);
5767    
5768                                    count = (Long)q.uniqueResult();
5769                            }
5770                            catch (Exception e) {
5771                                    throw processException(e);
5772                            }
5773                            finally {
5774                                    if (count == null) {
5775                                            count = Long.valueOf(0);
5776                                    }
5777    
5778                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
5779                                            count);
5780    
5781                                    closeSession(session);
5782                            }
5783                    }
5784    
5785                    return count.intValue();
5786            }
5787    
5788            /**
5789             * Returns the number of asset categories where name = &#63; and vocabularyId = &#63;.
5790             *
5791             * @param name the name
5792             * @param vocabularyId the vocabulary ID
5793             * @return the number of matching asset categories
5794             * @throws SystemException if a system exception occurred
5795             */
5796            public int countByN_V(String name, long vocabularyId)
5797                    throws SystemException {
5798                    Object[] finderArgs = new Object[] { name, vocabularyId };
5799    
5800                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
5801                                    finderArgs, this);
5802    
5803                    if (count == null) {
5804                            StringBundler query = new StringBundler(3);
5805    
5806                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5807    
5808                            if (name == null) {
5809                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
5810                            }
5811                            else {
5812                                    if (name.equals(StringPool.BLANK)) {
5813                                            query.append(_FINDER_COLUMN_N_V_NAME_3);
5814                                    }
5815                                    else {
5816                                            query.append(_FINDER_COLUMN_N_V_NAME_2);
5817                                    }
5818                            }
5819    
5820                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5821    
5822                            String sql = query.toString();
5823    
5824                            Session session = null;
5825    
5826                            try {
5827                                    session = openSession();
5828    
5829                                    Query q = session.createQuery(sql);
5830    
5831                                    QueryPos qPos = QueryPos.getInstance(q);
5832    
5833                                    if (name != null) {
5834                                            qPos.add(name);
5835                                    }
5836    
5837                                    qPos.add(vocabularyId);
5838    
5839                                    count = (Long)q.uniqueResult();
5840                            }
5841                            catch (Exception e) {
5842                                    throw processException(e);
5843                            }
5844                            finally {
5845                                    if (count == null) {
5846                                            count = Long.valueOf(0);
5847                                    }
5848    
5849                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
5850                                            count);
5851    
5852                                    closeSession(session);
5853                            }
5854                    }
5855    
5856                    return count.intValue();
5857            }
5858    
5859            /**
5860             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
5861             *
5862             * @param parentCategoryId the parent category ID
5863             * @param name the name
5864             * @param vocabularyId the vocabulary ID
5865             * @return the number of matching asset categories
5866             * @throws SystemException if a system exception occurred
5867             */
5868            public int countByP_N_V(long parentCategoryId, String name,
5869                    long vocabularyId) throws SystemException {
5870                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
5871    
5872                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
5873                                    finderArgs, this);
5874    
5875                    if (count == null) {
5876                            StringBundler query = new StringBundler(4);
5877    
5878                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
5879    
5880                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
5881    
5882                            if (name == null) {
5883                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
5884                            }
5885                            else {
5886                                    if (name.equals(StringPool.BLANK)) {
5887                                            query.append(_FINDER_COLUMN_P_N_V_NAME_3);
5888                                    }
5889                                    else {
5890                                            query.append(_FINDER_COLUMN_P_N_V_NAME_2);
5891                                    }
5892                            }
5893    
5894                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
5895    
5896                            String sql = query.toString();
5897    
5898                            Session session = null;
5899    
5900                            try {
5901                                    session = openSession();
5902    
5903                                    Query q = session.createQuery(sql);
5904    
5905                                    QueryPos qPos = QueryPos.getInstance(q);
5906    
5907                                    qPos.add(parentCategoryId);
5908    
5909                                    if (name != null) {
5910                                            qPos.add(name);
5911                                    }
5912    
5913                                    qPos.add(vocabularyId);
5914    
5915                                    count = (Long)q.uniqueResult();
5916                            }
5917                            catch (Exception e) {
5918                                    throw processException(e);
5919                            }
5920                            finally {
5921                                    if (count == null) {
5922                                            count = Long.valueOf(0);
5923                                    }
5924    
5925                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
5926                                            finderArgs, count);
5927    
5928                                    closeSession(session);
5929                            }
5930                    }
5931    
5932                    return count.intValue();
5933            }
5934    
5935            /**
5936             * Returns the number of asset categories.
5937             *
5938             * @return the number of asset categories
5939             * @throws SystemException if a system exception occurred
5940             */
5941            public int countAll() throws SystemException {
5942                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
5943                                    FINDER_ARGS_EMPTY, this);
5944    
5945                    if (count == null) {
5946                            Session session = null;
5947    
5948                            try {
5949                                    session = openSession();
5950    
5951                                    Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
5952    
5953                                    count = (Long)q.uniqueResult();
5954                            }
5955                            catch (Exception e) {
5956                                    throw processException(e);
5957                            }
5958                            finally {
5959                                    if (count == null) {
5960                                            count = Long.valueOf(0);
5961                                    }
5962    
5963                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
5964                                            FINDER_ARGS_EMPTY, count);
5965    
5966                                    closeSession(session);
5967                            }
5968                    }
5969    
5970                    return count.intValue();
5971            }
5972    
5973            /**
5974             * Returns all the asset entries associated with the asset category.
5975             *
5976             * @param pk the primary key of the asset category
5977             * @return the asset entries associated with the asset category
5978             * @throws SystemException if a system exception occurred
5979             */
5980            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5981                    long pk) throws SystemException {
5982                    return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5983            }
5984    
5985            /**
5986             * Returns a range of all the asset entries associated with the asset category.
5987             *
5988             * <p>
5989             * 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.
5990             * </p>
5991             *
5992             * @param pk the primary key of the asset category
5993             * @param start the lower bound of the range of asset categories
5994             * @param end the upper bound of the range of asset categories (not inclusive)
5995             * @return the range of asset entries associated with the asset category
5996             * @throws SystemException if a system exception occurred
5997             */
5998            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
5999                    long pk, int start, int end) throws SystemException {
6000                    return getAssetEntries(pk, start, end, null);
6001            }
6002    
6003            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
6004                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
6005                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
6006                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6007                            "getAssetEntries",
6008                            new String[] {
6009                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6010                                    "com.liferay.portal.kernel.util.OrderByComparator"
6011                            });
6012    
6013            static {
6014                    FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
6015            }
6016    
6017            /**
6018             * Returns an ordered range of all the asset entries associated with the asset category.
6019             *
6020             * <p>
6021             * 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.
6022             * </p>
6023             *
6024             * @param pk the primary key of the asset category
6025             * @param start the lower bound of the range of asset categories
6026             * @param end the upper bound of the range of asset categories (not inclusive)
6027             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6028             * @return the ordered range of asset entries associated with the asset category
6029             * @throws SystemException if a system exception occurred
6030             */
6031            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
6032                    long pk, int start, int end, OrderByComparator orderByComparator)
6033                    throws SystemException {
6034                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6035    
6036                    List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
6037                                    finderArgs, this);
6038    
6039                    if (list == null) {
6040                            Session session = null;
6041    
6042                            try {
6043                                    session = openSession();
6044    
6045                                    String sql = null;
6046    
6047                                    if (orderByComparator != null) {
6048                                            sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
6049                                                                                              .concat(orderByComparator.getOrderBy());
6050                                    }
6051                                    else {
6052                                            sql = _SQL_GETASSETENTRIES;
6053                                    }
6054    
6055                                    SQLQuery q = session.createSQLQuery(sql);
6056    
6057                                    q.addEntity("AssetEntry",
6058                                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
6059    
6060                                    QueryPos qPos = QueryPos.getInstance(q);
6061    
6062                                    qPos.add(pk);
6063    
6064                                    list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
6065                                                    getDialect(), start, end);
6066                            }
6067                            catch (Exception e) {
6068                                    throw processException(e);
6069                            }
6070                            finally {
6071                                    if (list == null) {
6072                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
6073                                                    finderArgs);
6074                                    }
6075                                    else {
6076                                            assetEntryPersistence.cacheResult(list);
6077    
6078                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
6079                                                    finderArgs, list);
6080                                    }
6081    
6082                                    closeSession(session);
6083                            }
6084                    }
6085    
6086                    return list;
6087            }
6088    
6089            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
6090                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
6091                            Long.class,
6092                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6093                            "getAssetEntriesSize", new String[] { Long.class.getName() });
6094    
6095            static {
6096                    FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
6097            }
6098    
6099            /**
6100             * Returns the number of asset entries associated with the asset category.
6101             *
6102             * @param pk the primary key of the asset category
6103             * @return the number of asset entries associated with the asset category
6104             * @throws SystemException if a system exception occurred
6105             */
6106            public int getAssetEntriesSize(long pk) throws SystemException {
6107                    Object[] finderArgs = new Object[] { pk };
6108    
6109                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6110                                    finderArgs, this);
6111    
6112                    if (count == null) {
6113                            Session session = null;
6114    
6115                            try {
6116                                    session = openSession();
6117    
6118                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
6119    
6120                                    q.addScalar(COUNT_COLUMN_NAME,
6121                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
6122    
6123                                    QueryPos qPos = QueryPos.getInstance(q);
6124    
6125                                    qPos.add(pk);
6126    
6127                                    count = (Long)q.uniqueResult();
6128                            }
6129                            catch (Exception e) {
6130                                    throw processException(e);
6131                            }
6132                            finally {
6133                                    if (count == null) {
6134                                            count = Long.valueOf(0);
6135                                    }
6136    
6137                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
6138                                            finderArgs, count);
6139    
6140                                    closeSession(session);
6141                            }
6142                    }
6143    
6144                    return count.intValue();
6145            }
6146    
6147            public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
6148                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
6149                            Boolean.class,
6150                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
6151                            "containsAssetEntry",
6152                            new String[] { Long.class.getName(), Long.class.getName() });
6153    
6154            /**
6155             * Returns <code>true</code> if the asset entry is associated with the asset category.
6156             *
6157             * @param pk the primary key of the asset category
6158             * @param assetEntryPK the primary key of the asset entry
6159             * @return <code>true</code> if the asset entry is associated with the asset category; <code>false</code> otherwise
6160             * @throws SystemException if a system exception occurred
6161             */
6162            public boolean containsAssetEntry(long pk, long assetEntryPK)
6163                    throws SystemException {
6164                    Object[] finderArgs = new Object[] { pk, assetEntryPK };
6165    
6166                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6167                                    finderArgs, this);
6168    
6169                    if (value == null) {
6170                            try {
6171                                    value = Boolean.valueOf(containsAssetEntry.contains(pk,
6172                                                            assetEntryPK));
6173                            }
6174                            catch (Exception e) {
6175                                    throw processException(e);
6176                            }
6177                            finally {
6178                                    if (value == null) {
6179                                            value = Boolean.FALSE;
6180                                    }
6181    
6182                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
6183                                            finderArgs, value);
6184                            }
6185                    }
6186    
6187                    return value.booleanValue();
6188            }
6189    
6190            /**
6191             * Returns <code>true</code> if the asset category has any asset entries associated with it.
6192             *
6193             * @param pk the primary key of the asset category to check for associations with asset entries
6194             * @return <code>true</code> if the asset category has any asset entries associated with it; <code>false</code> otherwise
6195             * @throws SystemException if a system exception occurred
6196             */
6197            public boolean containsAssetEntries(long pk) throws SystemException {
6198                    if (getAssetEntriesSize(pk) > 0) {
6199                            return true;
6200                    }
6201                    else {
6202                            return false;
6203                    }
6204            }
6205    
6206            /**
6207             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6208             *
6209             * @param pk the primary key of the asset category
6210             * @param assetEntryPK the primary key of the asset entry
6211             * @throws SystemException if a system exception occurred
6212             */
6213            public void addAssetEntry(long pk, long assetEntryPK)
6214                    throws SystemException {
6215                    try {
6216                            addAssetEntry.add(pk, assetEntryPK);
6217                    }
6218                    catch (Exception e) {
6219                            throw processException(e);
6220                    }
6221                    finally {
6222                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6223                    }
6224            }
6225    
6226            /**
6227             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6228             *
6229             * @param pk the primary key of the asset category
6230             * @param assetEntry the asset entry
6231             * @throws SystemException if a system exception occurred
6232             */
6233            public void addAssetEntry(long pk,
6234                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
6235                    throws SystemException {
6236                    try {
6237                            addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6238                    }
6239                    catch (Exception e) {
6240                            throw processException(e);
6241                    }
6242                    finally {
6243                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6244                    }
6245            }
6246    
6247            /**
6248             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6249             *
6250             * @param pk the primary key of the asset category
6251             * @param assetEntryPKs the primary keys of the asset entries
6252             * @throws SystemException if a system exception occurred
6253             */
6254            public void addAssetEntries(long pk, long[] assetEntryPKs)
6255                    throws SystemException {
6256                    try {
6257                            for (long assetEntryPK : assetEntryPKs) {
6258                                    addAssetEntry.add(pk, assetEntryPK);
6259                            }
6260                    }
6261                    catch (Exception e) {
6262                            throw processException(e);
6263                    }
6264                    finally {
6265                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6266                    }
6267            }
6268    
6269            /**
6270             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6271             *
6272             * @param pk the primary key of the asset category
6273             * @param assetEntries the asset entries
6274             * @throws SystemException if a system exception occurred
6275             */
6276            public void addAssetEntries(long pk,
6277                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6278                    throws SystemException {
6279                    try {
6280                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6281                                    addAssetEntry.add(pk, assetEntry.getPrimaryKey());
6282                            }
6283                    }
6284                    catch (Exception e) {
6285                            throw processException(e);
6286                    }
6287                    finally {
6288                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6289                    }
6290            }
6291    
6292            /**
6293             * Clears all associations between the asset category and its asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6294             *
6295             * @param pk the primary key of the asset category to clear the associated asset entries from
6296             * @throws SystemException if a system exception occurred
6297             */
6298            public void clearAssetEntries(long pk) throws SystemException {
6299                    try {
6300                            clearAssetEntries.clear(pk);
6301                    }
6302                    catch (Exception e) {
6303                            throw processException(e);
6304                    }
6305                    finally {
6306                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6307                    }
6308            }
6309    
6310            /**
6311             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6312             *
6313             * @param pk the primary key of the asset category
6314             * @param assetEntryPK the primary key of the asset entry
6315             * @throws SystemException if a system exception occurred
6316             */
6317            public void removeAssetEntry(long pk, long assetEntryPK)
6318                    throws SystemException {
6319                    try {
6320                            removeAssetEntry.remove(pk, assetEntryPK);
6321                    }
6322                    catch (Exception e) {
6323                            throw processException(e);
6324                    }
6325                    finally {
6326                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6327                    }
6328            }
6329    
6330            /**
6331             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6332             *
6333             * @param pk the primary key of the asset category
6334             * @param assetEntry the asset entry
6335             * @throws SystemException if a system exception occurred
6336             */
6337            public void removeAssetEntry(long pk,
6338                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
6339                    throws SystemException {
6340                    try {
6341                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6342                    }
6343                    catch (Exception e) {
6344                            throw processException(e);
6345                    }
6346                    finally {
6347                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6348                    }
6349            }
6350    
6351            /**
6352             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6353             *
6354             * @param pk the primary key of the asset category
6355             * @param assetEntryPKs the primary keys of the asset entries
6356             * @throws SystemException if a system exception occurred
6357             */
6358            public void removeAssetEntries(long pk, long[] assetEntryPKs)
6359                    throws SystemException {
6360                    try {
6361                            for (long assetEntryPK : assetEntryPKs) {
6362                                    removeAssetEntry.remove(pk, assetEntryPK);
6363                            }
6364                    }
6365                    catch (Exception e) {
6366                            throw processException(e);
6367                    }
6368                    finally {
6369                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6370                    }
6371            }
6372    
6373            /**
6374             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6375             *
6376             * @param pk the primary key of the asset category
6377             * @param assetEntries the asset entries
6378             * @throws SystemException if a system exception occurred
6379             */
6380            public void removeAssetEntries(long pk,
6381                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6382                    throws SystemException {
6383                    try {
6384                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6385                                    removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6386                            }
6387                    }
6388                    catch (Exception e) {
6389                            throw processException(e);
6390                    }
6391                    finally {
6392                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6393                    }
6394            }
6395    
6396            /**
6397             * Sets the asset entries associated with the asset category, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6398             *
6399             * @param pk the primary key of the asset category
6400             * @param assetEntryPKs the primary keys of the asset entries to be associated with the asset category
6401             * @throws SystemException if a system exception occurred
6402             */
6403            public void setAssetEntries(long pk, long[] assetEntryPKs)
6404                    throws SystemException {
6405                    try {
6406                            Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
6407    
6408                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
6409    
6410                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6411                                    if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
6412                                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
6413                                    }
6414                            }
6415    
6416                            for (Long assetEntryPK : assetEntryPKSet) {
6417                                    addAssetEntry.add(pk, assetEntryPK);
6418                            }
6419                    }
6420                    catch (Exception e) {
6421                            throw processException(e);
6422                    }
6423                    finally {
6424                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6425                    }
6426            }
6427    
6428            /**
6429             * Sets the asset entries associated with the asset category, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
6430             *
6431             * @param pk the primary key of the asset category
6432             * @param assetEntries the asset entries to be associated with the asset category
6433             * @throws SystemException if a system exception occurred
6434             */
6435            public void setAssetEntries(long pk,
6436                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
6437                    throws SystemException {
6438                    try {
6439                            long[] assetEntryPKs = new long[assetEntries.size()];
6440    
6441                            for (int i = 0; i < assetEntries.size(); i++) {
6442                                    com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
6443    
6444                                    assetEntryPKs[i] = assetEntry.getPrimaryKey();
6445                            }
6446    
6447                            setAssetEntries(pk, assetEntryPKs);
6448                    }
6449                    catch (Exception e) {
6450                            throw processException(e);
6451                    }
6452                    finally {
6453                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
6454                    }
6455            }
6456    
6457            /**
6458             * Rebuilds the asset categories tree for the scope using the modified pre-order tree traversal algorithm.
6459             *
6460             * <p>
6461             * Only call this method if the tree has become stale through operations other than normal CRUD. Under normal circumstances the tree is automatically rebuilt whenver necessary.
6462             * </p>
6463             *
6464             * @param groupId the ID of the scope
6465             * @param force whether to force the rebuild even if the tree is not stale
6466             */
6467            public void rebuildTree(long groupId, boolean force)
6468                    throws SystemException {
6469                    if (!rebuildTreeEnabled) {
6470                            return;
6471                    }
6472    
6473                    if (force || (countOrphanTreeNodes(groupId) > 0)) {
6474                            rebuildTree(groupId, 0, 1);
6475    
6476                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6477                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6478                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6479                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6480                    }
6481            }
6482    
6483            public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
6484                    this.rebuildTreeEnabled = rebuildTreeEnabled;
6485            }
6486    
6487            protected long countOrphanTreeNodes(long groupId) throws SystemException {
6488                    Session session = null;
6489    
6490                    try {
6491                            session = openSession();
6492    
6493                            SQLQuery q = session.createSQLQuery(
6494                                            "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
6495    
6496                            q.addScalar(COUNT_COLUMN_NAME,
6497                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6498    
6499                            QueryPos qPos = QueryPos.getInstance(q);
6500    
6501                            qPos.add(groupId);
6502    
6503                            return (Long)q.uniqueResult();
6504                    }
6505                    catch (Exception e) {
6506                            throw processException(e);
6507                    }
6508                    finally {
6509                            closeSession(session);
6510                    }
6511            }
6512    
6513            protected void expandNoChildrenLeftCategoryId(long groupId,
6514                    long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
6515                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
6516                            StringUtil.merge(childrenCategoryIds) + "))";
6517    
6518                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6519                                    sql,
6520                                    new int[] {
6521                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6522                                            java.sql.Types.BIGINT
6523                                    });
6524    
6525                    _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
6526            }
6527    
6528            protected void expandNoChildrenRightCategoryId(long groupId,
6529                    long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
6530                    String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
6531                            StringUtil.merge(childrenCategoryIds) + "))";
6532    
6533                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6534                                    sql,
6535                                    new int[] {
6536                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6537                                            java.sql.Types.BIGINT
6538                                    });
6539    
6540                    _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
6541            }
6542    
6543            protected void expandTree(AssetCategory assetCategory,
6544                    List<Long> childrenCategoryIds) throws SystemException {
6545                    if (!rebuildTreeEnabled) {
6546                            return;
6547                    }
6548    
6549                    long groupId = assetCategory.getGroupId();
6550    
6551                    long lastRightCategoryId = getLastRightCategoryId(groupId,
6552                                    assetCategory.getParentCategoryId());
6553    
6554                    long leftCategoryId = 2;
6555                    long rightCategoryId = 3;
6556    
6557                    if (lastRightCategoryId > 0) {
6558                            leftCategoryId = lastRightCategoryId + 1;
6559    
6560                            long childrenDistance = assetCategory.getRightCategoryId() -
6561                                    assetCategory.getLeftCategoryId();
6562    
6563                            if (childrenDistance > 1) {
6564                                    rightCategoryId = leftCategoryId + childrenDistance;
6565    
6566                                    updateChildrenTree(groupId, childrenCategoryIds,
6567                                            leftCategoryId - assetCategory.getLeftCategoryId());
6568    
6569                                    expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
6570                                            childrenCategoryIds, childrenDistance + 1);
6571                                    expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
6572                                            childrenCategoryIds, childrenDistance + 1);
6573                            }
6574                            else {
6575                                    rightCategoryId = lastRightCategoryId + 2;
6576    
6577                                    expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
6578                                    expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
6579                            }
6580    
6581                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6582                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6583                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6584                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6585                    }
6586    
6587                    assetCategory.setLeftCategoryId(leftCategoryId);
6588                    assetCategory.setRightCategoryId(rightCategoryId);
6589            }
6590    
6591            protected List<Long> getChildrenTreeCategoryIds(
6592                    AssetCategory parentAssetCategory) throws SystemException {
6593                    Session session = null;
6594    
6595                    try {
6596                            session = openSession();
6597    
6598                            SQLQuery q = session.createSQLQuery(
6599                                            "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
6600    
6601                            q.addScalar("CategoryId",
6602                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6603    
6604                            QueryPos qPos = QueryPos.getInstance(q);
6605    
6606                            qPos.add(parentAssetCategory.getGroupId());
6607                            qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
6608                            qPos.add(parentAssetCategory.getRightCategoryId());
6609    
6610                            return q.list();
6611                    }
6612                    catch (Exception e) {
6613                            throw processException(e);
6614                    }
6615                    finally {
6616                            closeSession(session);
6617                    }
6618            }
6619    
6620            protected long getLastRightCategoryId(long groupId, long parentCategoryId)
6621                    throws SystemException {
6622                    Session session = null;
6623    
6624                    try {
6625                            session = openSession();
6626    
6627                            SQLQuery q = session.createSQLQuery(
6628                                            "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
6629    
6630                            q.addScalar("rightCategoryId",
6631                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6632    
6633                            QueryPos qPos = QueryPos.getInstance(q);
6634    
6635                            qPos.add(groupId);
6636                            qPos.add(parentCategoryId);
6637    
6638                            List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
6639    
6640                            if (list.isEmpty()) {
6641                                    if (parentCategoryId > 0) {
6642                                            session.clear();
6643    
6644                                            AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
6645    
6646                                            return parentAssetCategory.getLeftCategoryId();
6647                                    }
6648    
6649                                    return 0;
6650                            }
6651                            else {
6652                                    return list.get(0);
6653                            }
6654                    }
6655                    catch (Exception e) {
6656                            throw processException(e);
6657                    }
6658                    finally {
6659                            closeSession(session);
6660                    }
6661            }
6662    
6663            protected long rebuildTree(long groupId, long parentCategoryId,
6664                    long leftCategoryId) throws SystemException {
6665                    if (!rebuildTreeEnabled) {
6666                            return 0;
6667                    }
6668    
6669                    List<Long> categoryIds = null;
6670    
6671                    Session session = null;
6672    
6673                    try {
6674                            session = openSession();
6675    
6676                            SQLQuery q = session.createSQLQuery(
6677                                            "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
6678    
6679                            q.addScalar("categoryId",
6680                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
6681    
6682                            QueryPos qPos = QueryPos.getInstance(q);
6683    
6684                            qPos.add(groupId);
6685                            qPos.add(parentCategoryId);
6686    
6687                            categoryIds = q.list();
6688                    }
6689                    catch (Exception e) {
6690                            throw processException(e);
6691                    }
6692                    finally {
6693                            closeSession(session);
6694                    }
6695    
6696                    long rightCategoryId = leftCategoryId + 1;
6697    
6698                    for (long categoryId : categoryIds) {
6699                            rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
6700                    }
6701    
6702                    if (parentCategoryId > 0) {
6703                            updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
6704                    }
6705    
6706                    return rightCategoryId + 1;
6707            }
6708    
6709            protected void shrinkTree(AssetCategory assetCategory) {
6710                    if (!rebuildTreeEnabled) {
6711                            return;
6712                    }
6713    
6714                    long groupId = assetCategory.getGroupId();
6715    
6716                    long leftCategoryId = assetCategory.getLeftCategoryId();
6717                    long rightCategoryId = assetCategory.getRightCategoryId();
6718    
6719                    long delta = (rightCategoryId - leftCategoryId) + 1;
6720    
6721                    shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
6722                    shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
6723    
6724                    CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
6725                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
6726                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
6727                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6728            }
6729    
6730            protected void updateChildrenTree(long groupId,
6731                    List<Long> childrenCategoryIds, long delta) {
6732                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
6733                            StringUtil.merge(childrenCategoryIds) + "))";
6734    
6735                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6736                                    sql,
6737                                    new int[] {
6738                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
6739                                            java.sql.Types.BIGINT
6740                                    });
6741    
6742                    _sqlUpdate.update(new Object[] { delta, delta, groupId });
6743            }
6744    
6745            /**
6746             * Initializes the asset category persistence.
6747             */
6748            public void afterPropertiesSet() {
6749                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
6750                                            com.liferay.portal.util.PropsUtil.get(
6751                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
6752    
6753                    if (listenerClassNames.length > 0) {
6754                            try {
6755                                    List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
6756    
6757                                    for (String listenerClassName : listenerClassNames) {
6758                                            listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
6759                                                            listenerClassName));
6760                                    }
6761    
6762                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
6763                            }
6764                            catch (Exception e) {
6765                                    _log.error(e);
6766                            }
6767                    }
6768    
6769                    containsAssetEntry = new ContainsAssetEntry();
6770    
6771                    addAssetEntry = new AddAssetEntry();
6772                    clearAssetEntries = new ClearAssetEntries();
6773                    removeAssetEntry = new RemoveAssetEntry();
6774    
6775                    expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
6776                    expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
6777                    shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
6778                    shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
6779                    updateTree = new UpdateTree();
6780            }
6781    
6782            public void destroy() {
6783                    EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
6784                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
6785                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
6786            }
6787    
6788            @BeanReference(type = AssetCategoryPersistence.class)
6789            protected AssetCategoryPersistence assetCategoryPersistence;
6790            @BeanReference(type = AssetCategoryPropertyPersistence.class)
6791            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
6792            @BeanReference(type = AssetEntryPersistence.class)
6793            protected AssetEntryPersistence assetEntryPersistence;
6794            @BeanReference(type = AssetLinkPersistence.class)
6795            protected AssetLinkPersistence assetLinkPersistence;
6796            @BeanReference(type = AssetTagPersistence.class)
6797            protected AssetTagPersistence assetTagPersistence;
6798            @BeanReference(type = AssetTagPropertyPersistence.class)
6799            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
6800            @BeanReference(type = AssetTagStatsPersistence.class)
6801            protected AssetTagStatsPersistence assetTagStatsPersistence;
6802            @BeanReference(type = AssetVocabularyPersistence.class)
6803            protected AssetVocabularyPersistence assetVocabularyPersistence;
6804            @BeanReference(type = ResourcePersistence.class)
6805            protected ResourcePersistence resourcePersistence;
6806            @BeanReference(type = UserPersistence.class)
6807            protected UserPersistence userPersistence;
6808            protected ContainsAssetEntry containsAssetEntry;
6809            protected AddAssetEntry addAssetEntry;
6810            protected ClearAssetEntries clearAssetEntries;
6811            protected RemoveAssetEntry removeAssetEntry;
6812    
6813            protected class ContainsAssetEntry {
6814                    protected ContainsAssetEntry() {
6815                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
6816                                            _SQL_CONTAINSASSETENTRY,
6817                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
6818                                            RowMapper.COUNT);
6819                    }
6820    
6821                    protected boolean contains(long categoryId, long entryId) {
6822                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
6823                                                    new Long(categoryId), new Long(entryId)
6824                                            });
6825    
6826                            if (results.size() > 0) {
6827                                    Integer count = results.get(0);
6828    
6829                                    if (count.intValue() > 0) {
6830                                            return true;
6831                                    }
6832                            }
6833    
6834                            return false;
6835                    }
6836    
6837                    private MappingSqlQuery<Integer> _mappingSqlQuery;
6838            }
6839    
6840            protected class AddAssetEntry {
6841                    protected AddAssetEntry() {
6842                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6843                                            "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
6844                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6845                    }
6846    
6847                    protected void add(long categoryId, long entryId)
6848                            throws SystemException {
6849                            if (!containsAssetEntry.contains(categoryId, entryId)) {
6850                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6851                                            assetEntryPersistence.getListeners();
6852    
6853                                    for (ModelListener<AssetCategory> listener : listeners) {
6854                                            listener.onBeforeAddAssociation(categoryId,
6855                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6856                                                    entryId);
6857                                    }
6858    
6859                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6860                                            listener.onBeforeAddAssociation(entryId,
6861                                                    AssetCategory.class.getName(), categoryId);
6862                                    }
6863    
6864                                    _sqlUpdate.update(new Object[] {
6865                                                    new Long(categoryId), new Long(entryId)
6866                                            });
6867    
6868                                    for (ModelListener<AssetCategory> listener : listeners) {
6869                                            listener.onAfterAddAssociation(categoryId,
6870                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6871                                                    entryId);
6872                                    }
6873    
6874                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6875                                            listener.onAfterAddAssociation(entryId,
6876                                                    AssetCategory.class.getName(), categoryId);
6877                                    }
6878                            }
6879                    }
6880    
6881                    private SqlUpdate _sqlUpdate;
6882            }
6883    
6884            protected class ClearAssetEntries {
6885                    protected ClearAssetEntries() {
6886                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6887                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
6888                                            new int[] { java.sql.Types.BIGINT });
6889                    }
6890    
6891                    protected void clear(long categoryId) throws SystemException {
6892                            ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6893                                    assetEntryPersistence.getListeners();
6894    
6895                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
6896    
6897                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6898                                    assetEntries = getAssetEntries(categoryId);
6899    
6900                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6901                                            for (ModelListener<AssetCategory> listener : listeners) {
6902                                                    listener.onBeforeRemoveAssociation(categoryId,
6903                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6904                                                            assetEntry.getPrimaryKey());
6905                                            }
6906    
6907                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6908                                                    listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
6909                                                            AssetCategory.class.getName(), categoryId);
6910                                            }
6911                                    }
6912                            }
6913    
6914                            _sqlUpdate.update(new Object[] { new Long(categoryId) });
6915    
6916                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
6917                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
6918                                            for (ModelListener<AssetCategory> listener : listeners) {
6919                                                    listener.onAfterRemoveAssociation(categoryId,
6920                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6921                                                            assetEntry.getPrimaryKey());
6922                                            }
6923    
6924                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6925                                                    listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
6926                                                            AssetCategory.class.getName(), categoryId);
6927                                            }
6928                                    }
6929                            }
6930                    }
6931    
6932                    private SqlUpdate _sqlUpdate;
6933            }
6934    
6935            protected class RemoveAssetEntry {
6936                    protected RemoveAssetEntry() {
6937                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6938                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
6939                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6940                    }
6941    
6942                    protected void remove(long categoryId, long entryId)
6943                            throws SystemException {
6944                            if (containsAssetEntry.contains(categoryId, entryId)) {
6945                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
6946                                            assetEntryPersistence.getListeners();
6947    
6948                                    for (ModelListener<AssetCategory> listener : listeners) {
6949                                            listener.onBeforeRemoveAssociation(categoryId,
6950                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6951                                                    entryId);
6952                                    }
6953    
6954                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6955                                            listener.onBeforeRemoveAssociation(entryId,
6956                                                    AssetCategory.class.getName(), categoryId);
6957                                    }
6958    
6959                                    _sqlUpdate.update(new Object[] {
6960                                                    new Long(categoryId), new Long(entryId)
6961                                            });
6962    
6963                                    for (ModelListener<AssetCategory> listener : listeners) {
6964                                            listener.onAfterRemoveAssociation(categoryId,
6965                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
6966                                                    entryId);
6967                                    }
6968    
6969                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
6970                                            listener.onAfterRemoveAssociation(entryId,
6971                                                    AssetCategory.class.getName(), categoryId);
6972                                    }
6973                            }
6974                    }
6975    
6976                    private SqlUpdate _sqlUpdate;
6977            }
6978    
6979            protected boolean rebuildTreeEnabled = true;
6980            protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
6981            protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
6982            protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
6983            protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
6984            protected UpdateTree updateTree;
6985    
6986            protected class ExpandTreeLeftCategoryId {
6987                    protected ExpandTreeLeftCategoryId() {
6988                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
6989                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
6990                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
6991                    }
6992    
6993                    protected void expand(long groupId, long leftCategoryId) {
6994                            _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
6995                    }
6996    
6997                    private SqlUpdate _sqlUpdate;
6998            }
6999    
7000            protected class ExpandTreeRightCategoryId {
7001                    protected ExpandTreeRightCategoryId() {
7002                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7003                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
7004                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7005                    }
7006    
7007                    protected void expand(long groupId, long rightCategoryId) {
7008                            _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
7009                    }
7010    
7011                    private SqlUpdate _sqlUpdate;
7012            }
7013    
7014            protected class ShrinkTreeLeftCategoryId {
7015                    protected ShrinkTreeLeftCategoryId() {
7016                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7017                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
7018                                            new int[] {
7019                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
7020                                                    java.sql.Types.BIGINT
7021                                            });
7022                    }
7023    
7024                    protected void shrink(long groupId, long leftCategoryId, long delta) {
7025                            _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
7026                    }
7027    
7028                    private SqlUpdate _sqlUpdate;
7029            }
7030    
7031            protected class ShrinkTreeRightCategoryId {
7032                    protected ShrinkTreeRightCategoryId() {
7033                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7034                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
7035                                            new int[] {
7036                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
7037                                                    java.sql.Types.BIGINT
7038                                            });
7039                    }
7040    
7041                    protected void shrink(long groupId, long rightCategoryId, long delta) {
7042                            _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
7043                    }
7044    
7045                    private SqlUpdate _sqlUpdate;
7046            }
7047    
7048            protected class UpdateTree {
7049                    protected UpdateTree() {
7050                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7051                                            "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
7052                                            new int[] {
7053                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
7054                                                    java.sql.Types.BIGINT
7055                                            });
7056                    }
7057    
7058                    protected void update(long categoryId, long leftCategoryId,
7059                            long rightCategoryId) {
7060                            _sqlUpdate.update(new Object[] {
7061                                            leftCategoryId, rightCategoryId, categoryId
7062                                    });
7063                    }
7064    
7065                    private SqlUpdate _sqlUpdate;
7066            }
7067    
7068            private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
7069            private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
7070            private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
7071            private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
7072            private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
7073            private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
7074            private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
7075            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
7076            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
7077            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
7078            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
7079            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
7080            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
7081            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
7082            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
7083            private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
7084                    "assetCategory.parentCategoryId = ?";
7085            private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7086            private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
7087            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7088            private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7089            private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
7090            private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
7091            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
7092            private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7093            private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7094            private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
7095            private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
7096            private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
7097            private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7098            private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
7099            private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
7100            private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
7101            private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
7102            private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
7103            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
7104            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
7105            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
7106                    "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
7107            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
7108                    ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
7109            private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
7110            private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
7111            private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
7112            private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
7113            private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
7114            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
7115            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
7116            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
7117            private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
7118            private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
7119                            @Override
7120                            public Object clone() {
7121                                    return this;
7122                            }
7123    
7124                            @Override
7125                            public CacheModel<AssetCategory> toCacheModel() {
7126                                    return _nullAssetCategoryCacheModel;
7127                            }
7128                    };
7129    
7130            private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
7131                            public AssetCategory toEntityModel() {
7132                                    return _nullAssetCategory;
7133                            }
7134                    };
7135    }