001    /**
002     * Copyright (c) 2000-2013 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.ArrayUtil;
037    import com.liferay.portal.kernel.util.GetterUtil;
038    import com.liferay.portal.kernel.util.InstanceFactory;
039    import com.liferay.portal.kernel.util.OrderByComparator;
040    import com.liferay.portal.kernel.util.SetUtil;
041    import com.liferay.portal.kernel.util.StringBundler;
042    import com.liferay.portal.kernel.util.StringPool;
043    import com.liferay.portal.kernel.util.StringUtil;
044    import com.liferay.portal.kernel.util.Validator;
045    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046    import com.liferay.portal.model.CacheModel;
047    import com.liferay.portal.model.ModelListener;
048    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
049    import com.liferay.portal.service.persistence.BatchSessionUtil;
050    import com.liferay.portal.service.persistence.ResourcePersistence;
051    import com.liferay.portal.service.persistence.UserPersistence;
052    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
053    
054    import com.liferay.portlet.asset.NoSuchCategoryException;
055    import com.liferay.portlet.asset.model.AssetCategory;
056    import com.liferay.portlet.asset.model.impl.AssetCategoryImpl;
057    import com.liferay.portlet.asset.model.impl.AssetCategoryModelImpl;
058    
059    import java.io.Serializable;
060    
061    import java.util.ArrayList;
062    import java.util.Collections;
063    import java.util.List;
064    import java.util.Set;
065    
066    /**
067     * The persistence implementation for the asset category service.
068     *
069     * <p>
070     * Caching information and settings can be found in <code>portal.properties</code>
071     * </p>
072     *
073     * @author Brian Wing Shun Chan
074     * @see AssetCategoryPersistence
075     * @see AssetCategoryUtil
076     * @generated
077     */
078    public class AssetCategoryPersistenceImpl extends BasePersistenceImpl<AssetCategory>
079            implements AssetCategoryPersistence {
080            /*
081             * NOTE FOR DEVELOPERS:
082             *
083             * 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.
084             */
085            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryImpl.class.getName();
086            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087                    ".List1";
088            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089                    ".List2";
090            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
091                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
092                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
093                            "findByUuid",
094                            new String[] {
095                                    String.class.getName(),
096                                    
097                            "java.lang.Integer", "java.lang.Integer",
098                                    "com.liferay.portal.kernel.util.OrderByComparator"
099                            });
100            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
101                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
102                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
103                            "findByUuid", new String[] { String.class.getName() },
104                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK);
105            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
106                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
107                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
108                            new String[] { String.class.getName() });
109            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
110                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
111                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
112                            new String[] { String.class.getName(), Long.class.getName() },
113                            AssetCategoryModelImpl.UUID_COLUMN_BITMASK |
114                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
115            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
116                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
118                            new String[] { String.class.getName(), Long.class.getName() });
119            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
120                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
121                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
122                            "findByGroupId",
123                            new String[] {
124                                    Long.class.getName(),
125                                    
126                            "java.lang.Integer", "java.lang.Integer",
127                                    "com.liferay.portal.kernel.util.OrderByComparator"
128                            });
129            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
130                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
131                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
132                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
133                            "findByGroupId", new String[] { Long.class.getName() },
134                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK);
135            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
136                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
137                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
138                            new String[] { Long.class.getName() });
139            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID =
140                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
141                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
142                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
143                            "findByParentCategoryId",
144                            new String[] {
145                                    Long.class.getName(),
146                                    
147                            "java.lang.Integer", "java.lang.Integer",
148                                    "com.liferay.portal.kernel.util.OrderByComparator"
149                            });
150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID =
151                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
152                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
153                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
154                            "findByParentCategoryId", new String[] { Long.class.getName() },
155                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK);
156            public static final FinderPath FINDER_PATH_COUNT_BY_PARENTCATEGORYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
157                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
158                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
159                            "countByParentCategoryId", new String[] { Long.class.getName() });
160            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID =
161                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
162                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
163                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
164                            "findByVocabularyId",
165                            new String[] {
166                                    Long.class.getName(),
167                                    
168                            "java.lang.Integer", "java.lang.Integer",
169                                    "com.liferay.portal.kernel.util.OrderByComparator"
170                            });
171            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID =
172                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
173                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
174                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
175                            "findByVocabularyId", new String[] { Long.class.getName() },
176                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
177            public static final FinderPath FINDER_PATH_COUNT_BY_VOCABULARYID = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
178                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
179                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByVocabularyId",
180                            new String[] { Long.class.getName() });
181            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
182                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
183                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
184                            "findByG_V",
185                            new String[] {
186                                    Long.class.getName(), Long.class.getName(),
187                                    
188                            "java.lang.Integer", "java.lang.Integer",
189                                    "com.liferay.portal.kernel.util.OrderByComparator"
190                            });
191            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
192                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
193                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
194                            "findByG_V",
195                            new String[] { Long.class.getName(), Long.class.getName() },
196                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
197                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
198            public static final FinderPath FINDER_PATH_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
199                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
200                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_V",
201                            new String[] { Long.class.getName(), Long.class.getName() });
202            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
203                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
204                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_V",
205                            new String[] { Long.class.getName(), Long.class.getName() });
206            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
207                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
208                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
209                            "findByP_N",
210                            new String[] {
211                                    Long.class.getName(), String.class.getName(),
212                                    
213                            "java.lang.Integer", "java.lang.Integer",
214                                    "com.liferay.portal.kernel.util.OrderByComparator"
215                            });
216            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
217                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
218                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
219                            "findByP_N",
220                            new String[] { Long.class.getName(), String.class.getName() },
221                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
222                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK);
223            public static final FinderPath FINDER_PATH_COUNT_BY_P_N = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
224                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
225                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N",
226                            new String[] { Long.class.getName(), String.class.getName() });
227            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
228                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
229                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
230                            "findByP_V",
231                            new String[] {
232                                    Long.class.getName(), Long.class.getName(),
233                                    
234                            "java.lang.Integer", "java.lang.Integer",
235                                    "com.liferay.portal.kernel.util.OrderByComparator"
236                            });
237            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
238                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
239                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
240                            "findByP_V",
241                            new String[] { Long.class.getName(), Long.class.getName() },
242                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
243                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
244            public static final FinderPath FINDER_PATH_COUNT_BY_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
245                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
246                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_V",
247                            new String[] { Long.class.getName(), Long.class.getName() });
248            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
249                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
250                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
251                            "findByN_V",
252                            new String[] {
253                                    String.class.getName(), Long.class.getName(),
254                                    
255                            "java.lang.Integer", "java.lang.Integer",
256                                    "com.liferay.portal.kernel.util.OrderByComparator"
257                            });
258            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
259                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
260                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
261                            "findByN_V",
262                            new String[] { String.class.getName(), Long.class.getName() },
263                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
264                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
265            public static final FinderPath FINDER_PATH_COUNT_BY_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
266                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
267                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByN_V",
268                            new String[] { String.class.getName(), Long.class.getName() });
269            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
270                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
271                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
272                            "findByG_P_V",
273                            new String[] {
274                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
275                                    
276                            "java.lang.Integer", "java.lang.Integer",
277                                    "com.liferay.portal.kernel.util.OrderByComparator"
278                            });
279            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
280                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
281                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
282                            "findByG_P_V",
283                            new String[] {
284                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
285                            },
286                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
287                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
288                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
289            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
290                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
291                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_V",
292                            new String[] {
293                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
294                            });
295            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V =
296                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
297                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
298                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
299                            "findByG_LikeN_V",
300                            new String[] {
301                                    Long.class.getName(), String.class.getName(),
302                                    Long.class.getName(),
303                                    
304                            "java.lang.Integer", "java.lang.Integer",
305                                    "com.liferay.portal.kernel.util.OrderByComparator"
306                            });
307            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V =
308                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
309                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
310                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByG_LikeN_V",
311                            new String[] {
312                                    Long.class.getName(), String.class.getName(),
313                                    Long.class.getName()
314                            });
315            public static final FinderPath FINDER_PATH_FETCH_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
316                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
317                            AssetCategoryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByP_N_V",
318                            new String[] {
319                                    Long.class.getName(), String.class.getName(),
320                                    Long.class.getName()
321                            },
322                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
323                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
324                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
325            public static final FinderPath FINDER_PATH_COUNT_BY_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
326                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
327                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByP_N_V",
328                            new String[] {
329                                    Long.class.getName(), String.class.getName(),
330                                    Long.class.getName()
331                            });
332            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
333                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
334                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
335                            "findByG_P_N_V",
336                            new String[] {
337                                    Long.class.getName(), Long.class.getName(),
338                                    String.class.getName(), Long.class.getName(),
339                                    
340                            "java.lang.Integer", "java.lang.Integer",
341                                    "com.liferay.portal.kernel.util.OrderByComparator"
342                            });
343            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V =
344                    new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
345                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
346                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
347                            "findByG_P_N_V",
348                            new String[] {
349                                    Long.class.getName(), Long.class.getName(),
350                                    String.class.getName(), Long.class.getName()
351                            },
352                            AssetCategoryModelImpl.GROUPID_COLUMN_BITMASK |
353                            AssetCategoryModelImpl.PARENTCATEGORYID_COLUMN_BITMASK |
354                            AssetCategoryModelImpl.NAME_COLUMN_BITMASK |
355                            AssetCategoryModelImpl.VOCABULARYID_COLUMN_BITMASK);
356            public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N_V = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
357                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
358                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_P_N_V",
359                            new String[] {
360                                    Long.class.getName(), Long.class.getName(),
361                                    String.class.getName(), Long.class.getName()
362                            });
363            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
364                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
365                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
366                            "findAll", new String[0]);
367            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
368                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED,
369                            AssetCategoryImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
370                            "findAll", new String[0]);
371            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
372                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED, Long.class,
373                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
374    
375            /**
376             * Caches the asset category in the entity cache if it is enabled.
377             *
378             * @param assetCategory the asset category
379             */
380            public void cacheResult(AssetCategory assetCategory) {
381                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
382                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
383                            assetCategory);
384    
385                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
386                            new Object[] {
387                                    assetCategory.getUuid(),
388                                    Long.valueOf(assetCategory.getGroupId())
389                            }, assetCategory);
390    
391                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
392                            new Object[] {
393                                    Long.valueOf(assetCategory.getParentCategoryId()),
394                                    
395                            assetCategory.getName(),
396                                    Long.valueOf(assetCategory.getVocabularyId())
397                            }, assetCategory);
398    
399                    assetCategory.resetOriginalValues();
400            }
401    
402            /**
403             * Caches the asset categories in the entity cache if it is enabled.
404             *
405             * @param assetCategories the asset categories
406             */
407            public void cacheResult(List<AssetCategory> assetCategories) {
408                    for (AssetCategory assetCategory : assetCategories) {
409                            if (EntityCacheUtil.getResult(
410                                                    AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
411                                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey()) == null) {
412                                    cacheResult(assetCategory);
413                            }
414                            else {
415                                    assetCategory.resetOriginalValues();
416                            }
417                    }
418            }
419    
420            /**
421             * Clears the cache for all asset categories.
422             *
423             * <p>
424             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
425             * </p>
426             */
427            @Override
428            public void clearCache() {
429                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
430                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
431                    }
432    
433                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
434    
435                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
436                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
437                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
438            }
439    
440            /**
441             * Clears the cache for the asset category.
442             *
443             * <p>
444             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
445             * </p>
446             */
447            @Override
448            public void clearCache(AssetCategory assetCategory) {
449                    EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
450                            AssetCategoryImpl.class, assetCategory.getPrimaryKey());
451    
452                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
453                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
454    
455                    clearUniqueFindersCache(assetCategory);
456            }
457    
458            @Override
459            public void clearCache(List<AssetCategory> assetCategories) {
460                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
461                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
462    
463                    for (AssetCategory assetCategory : assetCategories) {
464                            EntityCacheUtil.removeResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
465                                    AssetCategoryImpl.class, assetCategory.getPrimaryKey());
466    
467                            clearUniqueFindersCache(assetCategory);
468                    }
469            }
470    
471            protected void cacheUniqueFindersCache(AssetCategory assetCategory) {
472                    if (assetCategory.isNew()) {
473                            Object[] args = new Object[] {
474                                            assetCategory.getUuid(),
475                                            Long.valueOf(assetCategory.getGroupId())
476                                    };
477    
478                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
479                                    Long.valueOf(1));
480                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
481                                    assetCategory);
482    
483                            args = new Object[] {
484                                            Long.valueOf(assetCategory.getParentCategoryId()),
485                                            
486                                            assetCategory.getName(),
487                                            Long.valueOf(assetCategory.getVocabularyId())
488                                    };
489    
490                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
491                                    Long.valueOf(1));
492                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
493                                    assetCategory);
494                    }
495                    else {
496                            AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
497    
498                            if ((assetCategoryModelImpl.getColumnBitmask() &
499                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
500                                    Object[] args = new Object[] {
501                                                    assetCategory.getUuid(),
502                                                    Long.valueOf(assetCategory.getGroupId())
503                                            };
504    
505                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
506                                            Long.valueOf(1));
507                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
508                                            assetCategory);
509                            }
510    
511                            if ((assetCategoryModelImpl.getColumnBitmask() &
512                                            FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
513                                    Object[] args = new Object[] {
514                                                    Long.valueOf(assetCategory.getParentCategoryId()),
515                                                    
516                                                    assetCategory.getName(),
517                                                    Long.valueOf(assetCategory.getVocabularyId())
518                                            };
519    
520                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V, args,
521                                            Long.valueOf(1));
522                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V, args,
523                                            assetCategory);
524                            }
525                    }
526            }
527    
528            protected void clearUniqueFindersCache(AssetCategory assetCategory) {
529                    AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
530    
531                    Object[] args = new Object[] {
532                                    assetCategory.getUuid(),
533                                    Long.valueOf(assetCategory.getGroupId())
534                            };
535    
536                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
537                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
538    
539                    if ((assetCategoryModelImpl.getColumnBitmask() &
540                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
541                            args = new Object[] {
542                                            assetCategoryModelImpl.getOriginalUuid(),
543                                            Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
544                                    };
545    
546                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
547                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
548                    }
549    
550                    args = new Object[] {
551                                    Long.valueOf(assetCategory.getParentCategoryId()),
552                                    
553                                    assetCategory.getName(),
554                                    Long.valueOf(assetCategory.getVocabularyId())
555                            };
556    
557                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
558                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
559    
560                    if ((assetCategoryModelImpl.getColumnBitmask() &
561                                    FINDER_PATH_FETCH_BY_P_N_V.getColumnBitmask()) != 0) {
562                            args = new Object[] {
563                                            Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
564                                            
565                                            assetCategoryModelImpl.getOriginalName(),
566                                            Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
567                                    };
568    
569                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N_V, args);
570                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V, args);
571                    }
572            }
573    
574            /**
575             * Creates a new asset category with the primary key. Does not add the asset category to the database.
576             *
577             * @param categoryId the primary key for the new asset category
578             * @return the new asset category
579             */
580            public AssetCategory create(long categoryId) {
581                    AssetCategory assetCategory = new AssetCategoryImpl();
582    
583                    assetCategory.setNew(true);
584                    assetCategory.setPrimaryKey(categoryId);
585    
586                    String uuid = PortalUUIDUtil.generate();
587    
588                    assetCategory.setUuid(uuid);
589    
590                    return assetCategory;
591            }
592    
593            /**
594             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
595             *
596             * @param categoryId the primary key of the asset category
597             * @return the asset category that was removed
598             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
599             * @throws SystemException if a system exception occurred
600             */
601            public AssetCategory remove(long categoryId)
602                    throws NoSuchCategoryException, SystemException {
603                    return remove(Long.valueOf(categoryId));
604            }
605    
606            /**
607             * Removes the asset category with the primary key from the database. Also notifies the appropriate model listeners.
608             *
609             * @param primaryKey the primary key of the asset category
610             * @return the asset category that was removed
611             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
612             * @throws SystemException if a system exception occurred
613             */
614            @Override
615            public AssetCategory remove(Serializable primaryKey)
616                    throws NoSuchCategoryException, SystemException {
617                    Session session = null;
618    
619                    try {
620                            session = openSession();
621    
622                            AssetCategory assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
623                                            primaryKey);
624    
625                            if (assetCategory == null) {
626                                    if (_log.isWarnEnabled()) {
627                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
628                                    }
629    
630                                    throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
631                                            primaryKey);
632                            }
633    
634                            return remove(assetCategory);
635                    }
636                    catch (NoSuchCategoryException nsee) {
637                            throw nsee;
638                    }
639                    catch (Exception e) {
640                            throw processException(e);
641                    }
642                    finally {
643                            closeSession(session);
644                    }
645            }
646    
647            @Override
648            protected AssetCategory removeImpl(AssetCategory assetCategory)
649                    throws SystemException {
650                    assetCategory = toUnwrappedModel(assetCategory);
651    
652                    try {
653                            clearAssetEntries.clear(assetCategory.getPrimaryKey());
654                    }
655                    catch (Exception e) {
656                            throw processException(e);
657                    }
658                    finally {
659                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
660                    }
661    
662                    shrinkTree(assetCategory);
663    
664                    Session session = null;
665    
666                    try {
667                            session = openSession();
668    
669                            BatchSessionUtil.delete(session, assetCategory);
670                    }
671                    catch (Exception e) {
672                            throw processException(e);
673                    }
674                    finally {
675                            closeSession(session);
676                    }
677    
678                    clearCache(assetCategory);
679    
680                    return assetCategory;
681            }
682    
683            @Override
684            public AssetCategory updateImpl(
685                    com.liferay.portlet.asset.model.AssetCategory assetCategory,
686                    boolean merge) throws SystemException {
687                    assetCategory = toUnwrappedModel(assetCategory);
688    
689                    boolean isNew = assetCategory.isNew();
690    
691                    AssetCategoryModelImpl assetCategoryModelImpl = (AssetCategoryModelImpl)assetCategory;
692    
693                    if (Validator.isNull(assetCategory.getUuid())) {
694                            String uuid = PortalUUIDUtil.generate();
695    
696                            assetCategory.setUuid(uuid);
697                    }
698    
699                    if (isNew) {
700                            expandTree(assetCategory, null);
701                    }
702                    else {
703                            if (assetCategory.getParentCategoryId() != assetCategoryModelImpl.getOriginalParentCategoryId()) {
704                                    List<Long> childrenCategoryIds = getChildrenTreeCategoryIds(assetCategory);
705    
706                                    shrinkTree(assetCategory);
707                                    expandTree(assetCategory, childrenCategoryIds);
708                            }
709                    }
710    
711                    Session session = null;
712    
713                    try {
714                            session = openSession();
715    
716                            BatchSessionUtil.update(session, assetCategory, merge);
717    
718                            assetCategory.setNew(false);
719                    }
720                    catch (Exception e) {
721                            throw processException(e);
722                    }
723                    finally {
724                            closeSession(session);
725                    }
726    
727                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
728    
729                    if (isNew || !AssetCategoryModelImpl.COLUMN_BITMASK_ENABLED) {
730                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
731                    }
732    
733                    else {
734                            if ((assetCategoryModelImpl.getColumnBitmask() &
735                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
736                                    Object[] args = new Object[] {
737                                                    assetCategoryModelImpl.getOriginalUuid()
738                                            };
739    
740                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
741                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
742                                            args);
743    
744                                    args = new Object[] { assetCategoryModelImpl.getUuid() };
745    
746                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
747                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
748                                            args);
749                            }
750    
751                            if ((assetCategoryModelImpl.getColumnBitmask() &
752                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
753                                    Object[] args = new Object[] {
754                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId())
755                                            };
756    
757                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
758                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
759                                            args);
760    
761                                    args = new Object[] {
762                                                    Long.valueOf(assetCategoryModelImpl.getGroupId())
763                                            };
764    
765                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
766                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
767                                            args);
768                            }
769    
770                            if ((assetCategoryModelImpl.getColumnBitmask() &
771                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID.getColumnBitmask()) != 0) {
772                                    Object[] args = new Object[] {
773                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId())
774                                            };
775    
776                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
777                                            args);
778                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
779                                            args);
780    
781                                    args = new Object[] {
782                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId())
783                                            };
784    
785                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
786                                            args);
787                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID,
788                                            args);
789                            }
790    
791                            if ((assetCategoryModelImpl.getColumnBitmask() &
792                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID.getColumnBitmask()) != 0) {
793                                    Object[] args = new Object[] {
794                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
795                                            };
796    
797                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
798                                            args);
799                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
800                                            args);
801    
802                                    args = new Object[] {
803                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
804                                            };
805    
806                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
807                                            args);
808                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID,
809                                            args);
810                            }
811    
812                            if ((assetCategoryModelImpl.getColumnBitmask() &
813                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V.getColumnBitmask()) != 0) {
814                                    Object[] args = new Object[] {
815                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
816                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
817                                            };
818    
819                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
820                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
821                                            args);
822    
823                                    args = new Object[] {
824                                                    Long.valueOf(assetCategoryModelImpl.getGroupId()),
825                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
826                                            };
827    
828                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_V, args);
829                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V,
830                                            args);
831                            }
832    
833                            if ((assetCategoryModelImpl.getColumnBitmask() &
834                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N.getColumnBitmask()) != 0) {
835                                    Object[] args = new Object[] {
836                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
837                                                    
838                                                    assetCategoryModelImpl.getOriginalName()
839                                            };
840    
841                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
842                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
843                                            args);
844    
845                                    args = new Object[] {
846                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
847                                                    
848                                                    assetCategoryModelImpl.getName()
849                                            };
850    
851                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_N, args);
852                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N,
853                                            args);
854                            }
855    
856                            if ((assetCategoryModelImpl.getColumnBitmask() &
857                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V.getColumnBitmask()) != 0) {
858                                    Object[] args = new Object[] {
859                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
860                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
861                                            };
862    
863                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
864                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
865                                            args);
866    
867                                    args = new Object[] {
868                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
869                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
870                                            };
871    
872                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_P_V, args);
873                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V,
874                                            args);
875                            }
876    
877                            if ((assetCategoryModelImpl.getColumnBitmask() &
878                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V.getColumnBitmask()) != 0) {
879                                    Object[] args = new Object[] {
880                                                    assetCategoryModelImpl.getOriginalName(),
881                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
882                                            };
883    
884                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
885                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
886                                            args);
887    
888                                    args = new Object[] {
889                                                    assetCategoryModelImpl.getName(),
890                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
891                                            };
892    
893                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_N_V, args);
894                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V,
895                                            args);
896                            }
897    
898                            if ((assetCategoryModelImpl.getColumnBitmask() &
899                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V.getColumnBitmask()) != 0) {
900                                    Object[] args = new Object[] {
901                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
902                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
903                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
904                                            };
905    
906                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
907                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
908                                            args);
909    
910                                    args = new Object[] {
911                                                    Long.valueOf(assetCategoryModelImpl.getGroupId()),
912                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
913                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
914                                            };
915    
916                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_V, args);
917                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V,
918                                            args);
919                            }
920    
921                            if ((assetCategoryModelImpl.getColumnBitmask() &
922                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V.getColumnBitmask()) != 0) {
923                                    Object[] args = new Object[] {
924                                                    Long.valueOf(assetCategoryModelImpl.getOriginalGroupId()),
925                                                    Long.valueOf(assetCategoryModelImpl.getOriginalParentCategoryId()),
926                                                    
927                                                    assetCategoryModelImpl.getOriginalName(),
928                                                    Long.valueOf(assetCategoryModelImpl.getOriginalVocabularyId())
929                                            };
930    
931                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
932                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
933                                            args);
934    
935                                    args = new Object[] {
936                                                    Long.valueOf(assetCategoryModelImpl.getGroupId()),
937                                                    Long.valueOf(assetCategoryModelImpl.getParentCategoryId()),
938                                                    
939                                                    assetCategoryModelImpl.getName(),
940                                                    Long.valueOf(assetCategoryModelImpl.getVocabularyId())
941                                            };
942    
943                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_P_N_V, args);
944                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V,
945                                            args);
946                            }
947                    }
948    
949                    EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
950                            AssetCategoryImpl.class, assetCategory.getPrimaryKey(),
951                            assetCategory);
952    
953                    clearUniqueFindersCache(assetCategory);
954                    cacheUniqueFindersCache(assetCategory);
955    
956                    return assetCategory;
957            }
958    
959            protected AssetCategory toUnwrappedModel(AssetCategory assetCategory) {
960                    if (assetCategory instanceof AssetCategoryImpl) {
961                            return assetCategory;
962                    }
963    
964                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
965    
966                    assetCategoryImpl.setNew(assetCategory.isNew());
967                    assetCategoryImpl.setPrimaryKey(assetCategory.getPrimaryKey());
968    
969                    assetCategoryImpl.setUuid(assetCategory.getUuid());
970                    assetCategoryImpl.setCategoryId(assetCategory.getCategoryId());
971                    assetCategoryImpl.setGroupId(assetCategory.getGroupId());
972                    assetCategoryImpl.setCompanyId(assetCategory.getCompanyId());
973                    assetCategoryImpl.setUserId(assetCategory.getUserId());
974                    assetCategoryImpl.setUserName(assetCategory.getUserName());
975                    assetCategoryImpl.setCreateDate(assetCategory.getCreateDate());
976                    assetCategoryImpl.setModifiedDate(assetCategory.getModifiedDate());
977                    assetCategoryImpl.setParentCategoryId(assetCategory.getParentCategoryId());
978                    assetCategoryImpl.setLeftCategoryId(assetCategory.getLeftCategoryId());
979                    assetCategoryImpl.setRightCategoryId(assetCategory.getRightCategoryId());
980                    assetCategoryImpl.setName(assetCategory.getName());
981                    assetCategoryImpl.setTitle(assetCategory.getTitle());
982                    assetCategoryImpl.setDescription(assetCategory.getDescription());
983                    assetCategoryImpl.setVocabularyId(assetCategory.getVocabularyId());
984    
985                    return assetCategoryImpl;
986            }
987    
988            /**
989             * Returns the asset category with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
990             *
991             * @param primaryKey the primary key of the asset category
992             * @return the asset category
993             * @throws com.liferay.portal.NoSuchModelException if a asset category with the primary key could not be found
994             * @throws SystemException if a system exception occurred
995             */
996            @Override
997            public AssetCategory findByPrimaryKey(Serializable primaryKey)
998                    throws NoSuchModelException, SystemException {
999                    return findByPrimaryKey(((Long)primaryKey).longValue());
1000            }
1001    
1002            /**
1003             * Returns the asset category with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchCategoryException} if it could not be found.
1004             *
1005             * @param categoryId the primary key of the asset category
1006             * @return the asset category
1007             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1008             * @throws SystemException if a system exception occurred
1009             */
1010            public AssetCategory findByPrimaryKey(long categoryId)
1011                    throws NoSuchCategoryException, SystemException {
1012                    AssetCategory assetCategory = fetchByPrimaryKey(categoryId);
1013    
1014                    if (assetCategory == null) {
1015                            if (_log.isWarnEnabled()) {
1016                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + categoryId);
1017                            }
1018    
1019                            throw new NoSuchCategoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
1020                                    categoryId);
1021                    }
1022    
1023                    return assetCategory;
1024            }
1025    
1026            /**
1027             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
1028             *
1029             * @param primaryKey the primary key of the asset category
1030             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
1031             * @throws SystemException if a system exception occurred
1032             */
1033            @Override
1034            public AssetCategory fetchByPrimaryKey(Serializable primaryKey)
1035                    throws SystemException {
1036                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
1037            }
1038    
1039            /**
1040             * Returns the asset category with the primary key or returns <code>null</code> if it could not be found.
1041             *
1042             * @param categoryId the primary key of the asset category
1043             * @return the asset category, or <code>null</code> if a asset category with the primary key could not be found
1044             * @throws SystemException if a system exception occurred
1045             */
1046            public AssetCategory fetchByPrimaryKey(long categoryId)
1047                    throws SystemException {
1048                    AssetCategory assetCategory = (AssetCategory)EntityCacheUtil.getResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1049                                    AssetCategoryImpl.class, categoryId);
1050    
1051                    if (assetCategory == _nullAssetCategory) {
1052                            return null;
1053                    }
1054    
1055                    if (assetCategory == null) {
1056                            Session session = null;
1057    
1058                            boolean hasException = false;
1059    
1060                            try {
1061                                    session = openSession();
1062    
1063                                    assetCategory = (AssetCategory)session.get(AssetCategoryImpl.class,
1064                                                    Long.valueOf(categoryId));
1065                            }
1066                            catch (Exception e) {
1067                                    hasException = true;
1068    
1069                                    throw processException(e);
1070                            }
1071                            finally {
1072                                    if (assetCategory != null) {
1073                                            cacheResult(assetCategory);
1074                                    }
1075                                    else if (!hasException) {
1076                                            EntityCacheUtil.putResult(AssetCategoryModelImpl.ENTITY_CACHE_ENABLED,
1077                                                    AssetCategoryImpl.class, categoryId, _nullAssetCategory);
1078                                    }
1079    
1080                                    closeSession(session);
1081                            }
1082                    }
1083    
1084                    return assetCategory;
1085            }
1086    
1087            /**
1088             * Returns all the asset categories where uuid = &#63;.
1089             *
1090             * @param uuid the uuid
1091             * @return the matching asset categories
1092             * @throws SystemException if a system exception occurred
1093             */
1094            public List<AssetCategory> findByUuid(String uuid)
1095                    throws SystemException {
1096                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1097            }
1098    
1099            /**
1100             * Returns a range of all the asset categories where uuid = &#63;.
1101             *
1102             * <p>
1103             * 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.
1104             * </p>
1105             *
1106             * @param uuid the uuid
1107             * @param start the lower bound of the range of asset categories
1108             * @param end the upper bound of the range of asset categories (not inclusive)
1109             * @return the range of matching asset categories
1110             * @throws SystemException if a system exception occurred
1111             */
1112            public List<AssetCategory> findByUuid(String uuid, int start, int end)
1113                    throws SystemException {
1114                    return findByUuid(uuid, start, end, null);
1115            }
1116    
1117            /**
1118             * Returns an ordered range of all the asset categories where uuid = &#63;.
1119             *
1120             * <p>
1121             * 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.
1122             * </p>
1123             *
1124             * @param uuid the uuid
1125             * @param start the lower bound of the range of asset categories
1126             * @param end the upper bound of the range of asset categories (not inclusive)
1127             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1128             * @return the ordered range of matching asset categories
1129             * @throws SystemException if a system exception occurred
1130             */
1131            public List<AssetCategory> findByUuid(String uuid, int start, int end,
1132                    OrderByComparator orderByComparator) throws SystemException {
1133                    FinderPath finderPath = null;
1134                    Object[] finderArgs = null;
1135    
1136                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1137                                    (orderByComparator == null)) {
1138                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1139                            finderArgs = new Object[] { uuid };
1140                    }
1141                    else {
1142                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1143                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
1144                    }
1145    
1146                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1147                                    finderArgs, this);
1148    
1149                    if ((list != null) && !list.isEmpty()) {
1150                            for (AssetCategory assetCategory : list) {
1151                                    if (!Validator.equals(uuid, assetCategory.getUuid())) {
1152                                            list = null;
1153    
1154                                            break;
1155                                    }
1156                            }
1157                    }
1158    
1159                    if (list == null) {
1160                            StringBundler query = null;
1161    
1162                            if (orderByComparator != null) {
1163                                    query = new StringBundler(3 +
1164                                                    (orderByComparator.getOrderByFields().length * 3));
1165                            }
1166                            else {
1167                                    query = new StringBundler(3);
1168                            }
1169    
1170                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1171    
1172                            if (uuid == null) {
1173                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1174                            }
1175                            else {
1176                                    if (uuid.equals(StringPool.BLANK)) {
1177                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
1178                                    }
1179                                    else {
1180                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
1181                                    }
1182                            }
1183    
1184                            if (orderByComparator != null) {
1185                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1186                                            orderByComparator);
1187                            }
1188    
1189                            else {
1190                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1191                            }
1192    
1193                            String sql = query.toString();
1194    
1195                            Session session = null;
1196    
1197                            try {
1198                                    session = openSession();
1199    
1200                                    Query q = session.createQuery(sql);
1201    
1202                                    QueryPos qPos = QueryPos.getInstance(q);
1203    
1204                                    if (uuid != null) {
1205                                            qPos.add(uuid);
1206                                    }
1207    
1208                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1209                                                    start, end);
1210                            }
1211                            catch (Exception e) {
1212                                    throw processException(e);
1213                            }
1214                            finally {
1215                                    if (list == null) {
1216                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1217                                    }
1218                                    else {
1219                                            cacheResult(list);
1220    
1221                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1222                                    }
1223    
1224                                    closeSession(session);
1225                            }
1226                    }
1227    
1228                    return list;
1229            }
1230    
1231            /**
1232             * Returns the first asset category in the ordered set where uuid = &#63;.
1233             *
1234             * @param uuid the uuid
1235             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1236             * @return the first matching asset category
1237             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1238             * @throws SystemException if a system exception occurred
1239             */
1240            public AssetCategory findByUuid_First(String uuid,
1241                    OrderByComparator orderByComparator)
1242                    throws NoSuchCategoryException, SystemException {
1243                    AssetCategory assetCategory = fetchByUuid_First(uuid, orderByComparator);
1244    
1245                    if (assetCategory != null) {
1246                            return assetCategory;
1247                    }
1248    
1249                    StringBundler msg = new StringBundler(4);
1250    
1251                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1252    
1253                    msg.append("uuid=");
1254                    msg.append(uuid);
1255    
1256                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1257    
1258                    throw new NoSuchCategoryException(msg.toString());
1259            }
1260    
1261            /**
1262             * Returns the first asset category in the ordered set where uuid = &#63;.
1263             *
1264             * @param uuid the uuid
1265             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1266             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1267             * @throws SystemException if a system exception occurred
1268             */
1269            public AssetCategory fetchByUuid_First(String uuid,
1270                    OrderByComparator orderByComparator) throws SystemException {
1271                    List<AssetCategory> list = findByUuid(uuid, 0, 1, orderByComparator);
1272    
1273                    if (!list.isEmpty()) {
1274                            return list.get(0);
1275                    }
1276    
1277                    return null;
1278            }
1279    
1280            /**
1281             * Returns the last asset category in the ordered set where uuid = &#63;.
1282             *
1283             * @param uuid the uuid
1284             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1285             * @return the last matching asset category
1286             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1287             * @throws SystemException if a system exception occurred
1288             */
1289            public AssetCategory findByUuid_Last(String uuid,
1290                    OrderByComparator orderByComparator)
1291                    throws NoSuchCategoryException, SystemException {
1292                    AssetCategory assetCategory = fetchByUuid_Last(uuid, orderByComparator);
1293    
1294                    if (assetCategory != null) {
1295                            return assetCategory;
1296                    }
1297    
1298                    StringBundler msg = new StringBundler(4);
1299    
1300                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1301    
1302                    msg.append("uuid=");
1303                    msg.append(uuid);
1304    
1305                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1306    
1307                    throw new NoSuchCategoryException(msg.toString());
1308            }
1309    
1310            /**
1311             * Returns the last asset category in the ordered set where uuid = &#63;.
1312             *
1313             * @param uuid the uuid
1314             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1315             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1316             * @throws SystemException if a system exception occurred
1317             */
1318            public AssetCategory fetchByUuid_Last(String uuid,
1319                    OrderByComparator orderByComparator) throws SystemException {
1320                    int count = countByUuid(uuid);
1321    
1322                    List<AssetCategory> list = findByUuid(uuid, count - 1, count,
1323                                    orderByComparator);
1324    
1325                    if (!list.isEmpty()) {
1326                            return list.get(0);
1327                    }
1328    
1329                    return null;
1330            }
1331    
1332            /**
1333             * Returns the asset categories before and after the current asset category in the ordered set where uuid = &#63;.
1334             *
1335             * @param categoryId the primary key of the current asset category
1336             * @param uuid the uuid
1337             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1338             * @return the previous, current, and next asset category
1339             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1340             * @throws SystemException if a system exception occurred
1341             */
1342            public AssetCategory[] findByUuid_PrevAndNext(long categoryId, String uuid,
1343                    OrderByComparator orderByComparator)
1344                    throws NoSuchCategoryException, SystemException {
1345                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1346    
1347                    Session session = null;
1348    
1349                    try {
1350                            session = openSession();
1351    
1352                            AssetCategory[] array = new AssetCategoryImpl[3];
1353    
1354                            array[0] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1355                                            orderByComparator, true);
1356    
1357                            array[1] = assetCategory;
1358    
1359                            array[2] = getByUuid_PrevAndNext(session, assetCategory, uuid,
1360                                            orderByComparator, false);
1361    
1362                            return array;
1363                    }
1364                    catch (Exception e) {
1365                            throw processException(e);
1366                    }
1367                    finally {
1368                            closeSession(session);
1369                    }
1370            }
1371    
1372            protected AssetCategory getByUuid_PrevAndNext(Session session,
1373                    AssetCategory assetCategory, String uuid,
1374                    OrderByComparator orderByComparator, boolean previous) {
1375                    StringBundler query = null;
1376    
1377                    if (orderByComparator != null) {
1378                            query = new StringBundler(6 +
1379                                            (orderByComparator.getOrderByFields().length * 6));
1380                    }
1381                    else {
1382                            query = new StringBundler(3);
1383                    }
1384    
1385                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1386    
1387                    if (uuid == null) {
1388                            query.append(_FINDER_COLUMN_UUID_UUID_1);
1389                    }
1390                    else {
1391                            if (uuid.equals(StringPool.BLANK)) {
1392                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
1393                            }
1394                            else {
1395                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
1396                            }
1397                    }
1398    
1399                    if (orderByComparator != null) {
1400                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1401    
1402                            if (orderByConditionFields.length > 0) {
1403                                    query.append(WHERE_AND);
1404                            }
1405    
1406                            for (int i = 0; i < orderByConditionFields.length; i++) {
1407                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1408                                    query.append(orderByConditionFields[i]);
1409    
1410                                    if ((i + 1) < orderByConditionFields.length) {
1411                                            if (orderByComparator.isAscending() ^ previous) {
1412                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1413                                            }
1414                                            else {
1415                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1416                                            }
1417                                    }
1418                                    else {
1419                                            if (orderByComparator.isAscending() ^ previous) {
1420                                                    query.append(WHERE_GREATER_THAN);
1421                                            }
1422                                            else {
1423                                                    query.append(WHERE_LESSER_THAN);
1424                                            }
1425                                    }
1426                            }
1427    
1428                            query.append(ORDER_BY_CLAUSE);
1429    
1430                            String[] orderByFields = orderByComparator.getOrderByFields();
1431    
1432                            for (int i = 0; i < orderByFields.length; i++) {
1433                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1434                                    query.append(orderByFields[i]);
1435    
1436                                    if ((i + 1) < orderByFields.length) {
1437                                            if (orderByComparator.isAscending() ^ previous) {
1438                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1439                                            }
1440                                            else {
1441                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1442                                            }
1443                                    }
1444                                    else {
1445                                            if (orderByComparator.isAscending() ^ previous) {
1446                                                    query.append(ORDER_BY_ASC);
1447                                            }
1448                                            else {
1449                                                    query.append(ORDER_BY_DESC);
1450                                            }
1451                                    }
1452                            }
1453                    }
1454    
1455                    else {
1456                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1457                    }
1458    
1459                    String sql = query.toString();
1460    
1461                    Query q = session.createQuery(sql);
1462    
1463                    q.setFirstResult(0);
1464                    q.setMaxResults(2);
1465    
1466                    QueryPos qPos = QueryPos.getInstance(q);
1467    
1468                    if (uuid != null) {
1469                            qPos.add(uuid);
1470                    }
1471    
1472                    if (orderByComparator != null) {
1473                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
1474    
1475                            for (Object value : values) {
1476                                    qPos.add(value);
1477                            }
1478                    }
1479    
1480                    List<AssetCategory> list = q.list();
1481    
1482                    if (list.size() == 2) {
1483                            return list.get(1);
1484                    }
1485                    else {
1486                            return null;
1487                    }
1488            }
1489    
1490            /**
1491             * 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.
1492             *
1493             * @param uuid the uuid
1494             * @param groupId the group ID
1495             * @return the matching asset category
1496             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1497             * @throws SystemException if a system exception occurred
1498             */
1499            public AssetCategory findByUUID_G(String uuid, long groupId)
1500                    throws NoSuchCategoryException, SystemException {
1501                    AssetCategory assetCategory = fetchByUUID_G(uuid, groupId);
1502    
1503                    if (assetCategory == null) {
1504                            StringBundler msg = new StringBundler(6);
1505    
1506                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1507    
1508                            msg.append("uuid=");
1509                            msg.append(uuid);
1510    
1511                            msg.append(", groupId=");
1512                            msg.append(groupId);
1513    
1514                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1515    
1516                            if (_log.isWarnEnabled()) {
1517                                    _log.warn(msg.toString());
1518                            }
1519    
1520                            throw new NoSuchCategoryException(msg.toString());
1521                    }
1522    
1523                    return assetCategory;
1524            }
1525    
1526            /**
1527             * 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.
1528             *
1529             * @param uuid the uuid
1530             * @param groupId the group ID
1531             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
1532             * @throws SystemException if a system exception occurred
1533             */
1534            public AssetCategory fetchByUUID_G(String uuid, long groupId)
1535                    throws SystemException {
1536                    return fetchByUUID_G(uuid, groupId, true);
1537            }
1538    
1539            /**
1540             * 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.
1541             *
1542             * @param uuid the uuid
1543             * @param groupId the group ID
1544             * @param retrieveFromCache whether to use the finder cache
1545             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
1546             * @throws SystemException if a system exception occurred
1547             */
1548            public AssetCategory fetchByUUID_G(String uuid, long groupId,
1549                    boolean retrieveFromCache) throws SystemException {
1550                    Object[] finderArgs = new Object[] { uuid, groupId };
1551    
1552                    Object result = null;
1553    
1554                    if (retrieveFromCache) {
1555                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1556                                            finderArgs, this);
1557                    }
1558    
1559                    if (result instanceof AssetCategory) {
1560                            AssetCategory assetCategory = (AssetCategory)result;
1561    
1562                            if (!Validator.equals(uuid, assetCategory.getUuid()) ||
1563                                            (groupId != assetCategory.getGroupId())) {
1564                                    result = null;
1565                            }
1566                    }
1567    
1568                    if (result == null) {
1569                            StringBundler query = new StringBundler(4);
1570    
1571                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1572    
1573                            if (uuid == null) {
1574                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1575                            }
1576                            else {
1577                                    if (uuid.equals(StringPool.BLANK)) {
1578                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1579                                    }
1580                                    else {
1581                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1582                                    }
1583                            }
1584    
1585                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1586    
1587                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1588    
1589                            String sql = query.toString();
1590    
1591                            Session session = null;
1592    
1593                            try {
1594                                    session = openSession();
1595    
1596                                    Query q = session.createQuery(sql);
1597    
1598                                    QueryPos qPos = QueryPos.getInstance(q);
1599    
1600                                    if (uuid != null) {
1601                                            qPos.add(uuid);
1602                                    }
1603    
1604                                    qPos.add(groupId);
1605    
1606                                    List<AssetCategory> list = q.list();
1607    
1608                                    result = list;
1609    
1610                                    AssetCategory assetCategory = null;
1611    
1612                                    if (list.isEmpty()) {
1613                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1614                                                    finderArgs, list);
1615                                    }
1616                                    else {
1617                                            assetCategory = list.get(0);
1618    
1619                                            cacheResult(assetCategory);
1620    
1621                                            if ((assetCategory.getUuid() == null) ||
1622                                                            !assetCategory.getUuid().equals(uuid) ||
1623                                                            (assetCategory.getGroupId() != groupId)) {
1624                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1625                                                            finderArgs, assetCategory);
1626                                            }
1627                                    }
1628    
1629                                    return assetCategory;
1630                            }
1631                            catch (Exception e) {
1632                                    throw processException(e);
1633                            }
1634                            finally {
1635                                    if (result == null) {
1636                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1637                                                    finderArgs);
1638                                    }
1639    
1640                                    closeSession(session);
1641                            }
1642                    }
1643                    else {
1644                            if (result instanceof List<?>) {
1645                                    return null;
1646                            }
1647                            else {
1648                                    return (AssetCategory)result;
1649                            }
1650                    }
1651            }
1652    
1653            /**
1654             * Returns all the asset categories where groupId = &#63;.
1655             *
1656             * @param groupId the group ID
1657             * @return the matching asset categories
1658             * @throws SystemException if a system exception occurred
1659             */
1660            public List<AssetCategory> findByGroupId(long groupId)
1661                    throws SystemException {
1662                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1663            }
1664    
1665            /**
1666             * Returns a range of all the asset categories where groupId = &#63;.
1667             *
1668             * <p>
1669             * 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.
1670             * </p>
1671             *
1672             * @param groupId the group ID
1673             * @param start the lower bound of the range of asset categories
1674             * @param end the upper bound of the range of asset categories (not inclusive)
1675             * @return the range of matching asset categories
1676             * @throws SystemException if a system exception occurred
1677             */
1678            public List<AssetCategory> findByGroupId(long groupId, int start, int end)
1679                    throws SystemException {
1680                    return findByGroupId(groupId, start, end, null);
1681            }
1682    
1683            /**
1684             * Returns an ordered range of all the asset categories where groupId = &#63;.
1685             *
1686             * <p>
1687             * 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.
1688             * </p>
1689             *
1690             * @param groupId the group ID
1691             * @param start the lower bound of the range of asset categories
1692             * @param end the upper bound of the range of asset categories (not inclusive)
1693             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1694             * @return the ordered range of matching asset categories
1695             * @throws SystemException if a system exception occurred
1696             */
1697            public List<AssetCategory> findByGroupId(long groupId, int start, int end,
1698                    OrderByComparator orderByComparator) throws SystemException {
1699                    FinderPath finderPath = null;
1700                    Object[] finderArgs = null;
1701    
1702                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1703                                    (orderByComparator == null)) {
1704                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1705                            finderArgs = new Object[] { groupId };
1706                    }
1707                    else {
1708                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1709                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1710                    }
1711    
1712                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
1713                                    finderArgs, this);
1714    
1715                    if ((list != null) && !list.isEmpty()) {
1716                            for (AssetCategory assetCategory : list) {
1717                                    if ((groupId != assetCategory.getGroupId())) {
1718                                            list = null;
1719    
1720                                            break;
1721                                    }
1722                            }
1723                    }
1724    
1725                    if (list == null) {
1726                            StringBundler query = null;
1727    
1728                            if (orderByComparator != null) {
1729                                    query = new StringBundler(3 +
1730                                                    (orderByComparator.getOrderByFields().length * 3));
1731                            }
1732                            else {
1733                                    query = new StringBundler(3);
1734                            }
1735    
1736                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1737    
1738                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1739    
1740                            if (orderByComparator != null) {
1741                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1742                                            orderByComparator);
1743                            }
1744    
1745                            else {
1746                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
1747                            }
1748    
1749                            String sql = query.toString();
1750    
1751                            Session session = null;
1752    
1753                            try {
1754                                    session = openSession();
1755    
1756                                    Query q = session.createQuery(sql);
1757    
1758                                    QueryPos qPos = QueryPos.getInstance(q);
1759    
1760                                    qPos.add(groupId);
1761    
1762                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
1763                                                    start, end);
1764                            }
1765                            catch (Exception e) {
1766                                    throw processException(e);
1767                            }
1768                            finally {
1769                                    if (list == null) {
1770                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1771                                    }
1772                                    else {
1773                                            cacheResult(list);
1774    
1775                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1776                                    }
1777    
1778                                    closeSession(session);
1779                            }
1780                    }
1781    
1782                    return list;
1783            }
1784    
1785            /**
1786             * Returns the first asset category in the ordered set where groupId = &#63;.
1787             *
1788             * @param groupId the group ID
1789             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1790             * @return the first matching asset category
1791             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1792             * @throws SystemException if a system exception occurred
1793             */
1794            public AssetCategory findByGroupId_First(long groupId,
1795                    OrderByComparator orderByComparator)
1796                    throws NoSuchCategoryException, SystemException {
1797                    AssetCategory assetCategory = fetchByGroupId_First(groupId,
1798                                    orderByComparator);
1799    
1800                    if (assetCategory != null) {
1801                            return assetCategory;
1802                    }
1803    
1804                    StringBundler msg = new StringBundler(4);
1805    
1806                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1807    
1808                    msg.append("groupId=");
1809                    msg.append(groupId);
1810    
1811                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1812    
1813                    throw new NoSuchCategoryException(msg.toString());
1814            }
1815    
1816            /**
1817             * Returns the first asset category in the ordered set where groupId = &#63;.
1818             *
1819             * @param groupId the group ID
1820             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1821             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
1822             * @throws SystemException if a system exception occurred
1823             */
1824            public AssetCategory fetchByGroupId_First(long groupId,
1825                    OrderByComparator orderByComparator) throws SystemException {
1826                    List<AssetCategory> list = findByGroupId(groupId, 0, 1,
1827                                    orderByComparator);
1828    
1829                    if (!list.isEmpty()) {
1830                            return list.get(0);
1831                    }
1832    
1833                    return null;
1834            }
1835    
1836            /**
1837             * Returns the last asset category in the ordered set where groupId = &#63;.
1838             *
1839             * @param groupId the group ID
1840             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1841             * @return the last matching asset category
1842             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
1843             * @throws SystemException if a system exception occurred
1844             */
1845            public AssetCategory findByGroupId_Last(long groupId,
1846                    OrderByComparator orderByComparator)
1847                    throws NoSuchCategoryException, SystemException {
1848                    AssetCategory assetCategory = fetchByGroupId_Last(groupId,
1849                                    orderByComparator);
1850    
1851                    if (assetCategory != null) {
1852                            return assetCategory;
1853                    }
1854    
1855                    StringBundler msg = new StringBundler(4);
1856    
1857                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1858    
1859                    msg.append("groupId=");
1860                    msg.append(groupId);
1861    
1862                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1863    
1864                    throw new NoSuchCategoryException(msg.toString());
1865            }
1866    
1867            /**
1868             * Returns the last asset category in the ordered set where groupId = &#63;.
1869             *
1870             * @param groupId the group ID
1871             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1872             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
1873             * @throws SystemException if a system exception occurred
1874             */
1875            public AssetCategory fetchByGroupId_Last(long groupId,
1876                    OrderByComparator orderByComparator) throws SystemException {
1877                    int count = countByGroupId(groupId);
1878    
1879                    List<AssetCategory> list = findByGroupId(groupId, count - 1, count,
1880                                    orderByComparator);
1881    
1882                    if (!list.isEmpty()) {
1883                            return list.get(0);
1884                    }
1885    
1886                    return null;
1887            }
1888    
1889            /**
1890             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63;.
1891             *
1892             * @param categoryId the primary key of the current asset category
1893             * @param groupId the group ID
1894             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1895             * @return the previous, current, and next asset category
1896             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
1897             * @throws SystemException if a system exception occurred
1898             */
1899            public AssetCategory[] findByGroupId_PrevAndNext(long categoryId,
1900                    long groupId, OrderByComparator orderByComparator)
1901                    throws NoSuchCategoryException, SystemException {
1902                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
1903    
1904                    Session session = null;
1905    
1906                    try {
1907                            session = openSession();
1908    
1909                            AssetCategory[] array = new AssetCategoryImpl[3];
1910    
1911                            array[0] = getByGroupId_PrevAndNext(session, assetCategory,
1912                                            groupId, orderByComparator, true);
1913    
1914                            array[1] = assetCategory;
1915    
1916                            array[2] = getByGroupId_PrevAndNext(session, assetCategory,
1917                                            groupId, orderByComparator, false);
1918    
1919                            return array;
1920                    }
1921                    catch (Exception e) {
1922                            throw processException(e);
1923                    }
1924                    finally {
1925                            closeSession(session);
1926                    }
1927            }
1928    
1929            protected AssetCategory getByGroupId_PrevAndNext(Session session,
1930                    AssetCategory assetCategory, long groupId,
1931                    OrderByComparator orderByComparator, boolean previous) {
1932                    StringBundler query = null;
1933    
1934                    if (orderByComparator != null) {
1935                            query = new StringBundler(6 +
1936                                            (orderByComparator.getOrderByFields().length * 6));
1937                    }
1938                    else {
1939                            query = new StringBundler(3);
1940                    }
1941    
1942                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
1943    
1944                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1945    
1946                    if (orderByComparator != null) {
1947                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1948    
1949                            if (orderByConditionFields.length > 0) {
1950                                    query.append(WHERE_AND);
1951                            }
1952    
1953                            for (int i = 0; i < orderByConditionFields.length; i++) {
1954                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1955                                    query.append(orderByConditionFields[i]);
1956    
1957                                    if ((i + 1) < orderByConditionFields.length) {
1958                                            if (orderByComparator.isAscending() ^ previous) {
1959                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1960                                            }
1961                                            else {
1962                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1963                                            }
1964                                    }
1965                                    else {
1966                                            if (orderByComparator.isAscending() ^ previous) {
1967                                                    query.append(WHERE_GREATER_THAN);
1968                                            }
1969                                            else {
1970                                                    query.append(WHERE_LESSER_THAN);
1971                                            }
1972                                    }
1973                            }
1974    
1975                            query.append(ORDER_BY_CLAUSE);
1976    
1977                            String[] orderByFields = orderByComparator.getOrderByFields();
1978    
1979                            for (int i = 0; i < orderByFields.length; i++) {
1980                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1981                                    query.append(orderByFields[i]);
1982    
1983                                    if ((i + 1) < orderByFields.length) {
1984                                            if (orderByComparator.isAscending() ^ previous) {
1985                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1986                                            }
1987                                            else {
1988                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1989                                            }
1990                                    }
1991                                    else {
1992                                            if (orderByComparator.isAscending() ^ previous) {
1993                                                    query.append(ORDER_BY_ASC);
1994                                            }
1995                                            else {
1996                                                    query.append(ORDER_BY_DESC);
1997                                            }
1998                                    }
1999                            }
2000                    }
2001    
2002                    else {
2003                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2004                    }
2005    
2006                    String sql = query.toString();
2007    
2008                    Query q = session.createQuery(sql);
2009    
2010                    q.setFirstResult(0);
2011                    q.setMaxResults(2);
2012    
2013                    QueryPos qPos = QueryPos.getInstance(q);
2014    
2015                    qPos.add(groupId);
2016    
2017                    if (orderByComparator != null) {
2018                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2019    
2020                            for (Object value : values) {
2021                                    qPos.add(value);
2022                            }
2023                    }
2024    
2025                    List<AssetCategory> list = q.list();
2026    
2027                    if (list.size() == 2) {
2028                            return list.get(1);
2029                    }
2030                    else {
2031                            return null;
2032                    }
2033            }
2034    
2035            /**
2036             * Returns all the asset categories that the user has permission to view where groupId = &#63;.
2037             *
2038             * @param groupId the group ID
2039             * @return the matching asset categories that the user has permission to view
2040             * @throws SystemException if a system exception occurred
2041             */
2042            public List<AssetCategory> filterFindByGroupId(long groupId)
2043                    throws SystemException {
2044                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
2045                            QueryUtil.ALL_POS, null);
2046            }
2047    
2048            /**
2049             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63;.
2050             *
2051             * <p>
2052             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2053             * </p>
2054             *
2055             * @param groupId the group ID
2056             * @param start the lower bound of the range of asset categories
2057             * @param end the upper bound of the range of asset categories (not inclusive)
2058             * @return the range of matching asset categories that the user has permission to view
2059             * @throws SystemException if a system exception occurred
2060             */
2061            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2062                    int end) throws SystemException {
2063                    return filterFindByGroupId(groupId, start, end, null);
2064            }
2065    
2066            /**
2067             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63;.
2068             *
2069             * <p>
2070             * 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.
2071             * </p>
2072             *
2073             * @param groupId the group ID
2074             * @param start the lower bound of the range of asset categories
2075             * @param end the upper bound of the range of asset categories (not inclusive)
2076             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2077             * @return the ordered range of matching asset categories that the user has permission to view
2078             * @throws SystemException if a system exception occurred
2079             */
2080            public List<AssetCategory> filterFindByGroupId(long groupId, int start,
2081                    int end, OrderByComparator orderByComparator) throws SystemException {
2082                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2083                            return findByGroupId(groupId, start, end, orderByComparator);
2084                    }
2085    
2086                    StringBundler query = null;
2087    
2088                    if (orderByComparator != null) {
2089                            query = new StringBundler(3 +
2090                                            (orderByComparator.getOrderByFields().length * 3));
2091                    }
2092                    else {
2093                            query = new StringBundler(3);
2094                    }
2095    
2096                    if (getDB().isSupportsInlineDistinct()) {
2097                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2098                    }
2099                    else {
2100                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2101                    }
2102    
2103                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2104    
2105                    if (!getDB().isSupportsInlineDistinct()) {
2106                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2107                    }
2108    
2109                    if (orderByComparator != null) {
2110                            if (getDB().isSupportsInlineDistinct()) {
2111                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2112                                            orderByComparator);
2113                            }
2114                            else {
2115                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2116                                            orderByComparator);
2117                            }
2118                    }
2119    
2120                    else {
2121                            if (getDB().isSupportsInlineDistinct()) {
2122                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2123                            }
2124                            else {
2125                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2126                            }
2127                    }
2128    
2129                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2130                                    AssetCategory.class.getName(),
2131                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2132    
2133                    Session session = null;
2134    
2135                    try {
2136                            session = openSession();
2137    
2138                            SQLQuery q = session.createSQLQuery(sql);
2139    
2140                            if (getDB().isSupportsInlineDistinct()) {
2141                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2142                            }
2143                            else {
2144                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2145                            }
2146    
2147                            QueryPos qPos = QueryPos.getInstance(q);
2148    
2149                            qPos.add(groupId);
2150    
2151                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
2152                                    end);
2153                    }
2154                    catch (Exception e) {
2155                            throw processException(e);
2156                    }
2157                    finally {
2158                            closeSession(session);
2159                    }
2160            }
2161    
2162            /**
2163             * 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;.
2164             *
2165             * @param categoryId the primary key of the current asset category
2166             * @param groupId the group ID
2167             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2168             * @return the previous, current, and next asset category
2169             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2170             * @throws SystemException if a system exception occurred
2171             */
2172            public AssetCategory[] filterFindByGroupId_PrevAndNext(long categoryId,
2173                    long groupId, OrderByComparator orderByComparator)
2174                    throws NoSuchCategoryException, SystemException {
2175                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2176                            return findByGroupId_PrevAndNext(categoryId, groupId,
2177                                    orderByComparator);
2178                    }
2179    
2180                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2181    
2182                    Session session = null;
2183    
2184                    try {
2185                            session = openSession();
2186    
2187                            AssetCategory[] array = new AssetCategoryImpl[3];
2188    
2189                            array[0] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2190                                            groupId, orderByComparator, true);
2191    
2192                            array[1] = assetCategory;
2193    
2194                            array[2] = filterGetByGroupId_PrevAndNext(session, assetCategory,
2195                                            groupId, orderByComparator, false);
2196    
2197                            return array;
2198                    }
2199                    catch (Exception e) {
2200                            throw processException(e);
2201                    }
2202                    finally {
2203                            closeSession(session);
2204                    }
2205            }
2206    
2207            protected AssetCategory filterGetByGroupId_PrevAndNext(Session session,
2208                    AssetCategory assetCategory, long groupId,
2209                    OrderByComparator orderByComparator, boolean previous) {
2210                    StringBundler query = null;
2211    
2212                    if (orderByComparator != null) {
2213                            query = new StringBundler(6 +
2214                                            (orderByComparator.getOrderByFields().length * 6));
2215                    }
2216                    else {
2217                            query = new StringBundler(3);
2218                    }
2219    
2220                    if (getDB().isSupportsInlineDistinct()) {
2221                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
2222                    }
2223                    else {
2224                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
2225                    }
2226    
2227                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2228    
2229                    if (!getDB().isSupportsInlineDistinct()) {
2230                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
2231                    }
2232    
2233                    if (orderByComparator != null) {
2234                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2235    
2236                            if (orderByConditionFields.length > 0) {
2237                                    query.append(WHERE_AND);
2238                            }
2239    
2240                            for (int i = 0; i < orderByConditionFields.length; i++) {
2241                                    if (getDB().isSupportsInlineDistinct()) {
2242                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2243                                    }
2244                                    else {
2245                                            query.append(_ORDER_BY_ENTITY_TABLE);
2246                                    }
2247    
2248                                    query.append(orderByConditionFields[i]);
2249    
2250                                    if ((i + 1) < orderByConditionFields.length) {
2251                                            if (orderByComparator.isAscending() ^ previous) {
2252                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2253                                            }
2254                                            else {
2255                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2256                                            }
2257                                    }
2258                                    else {
2259                                            if (orderByComparator.isAscending() ^ previous) {
2260                                                    query.append(WHERE_GREATER_THAN);
2261                                            }
2262                                            else {
2263                                                    query.append(WHERE_LESSER_THAN);
2264                                            }
2265                                    }
2266                            }
2267    
2268                            query.append(ORDER_BY_CLAUSE);
2269    
2270                            String[] orderByFields = orderByComparator.getOrderByFields();
2271    
2272                            for (int i = 0; i < orderByFields.length; i++) {
2273                                    if (getDB().isSupportsInlineDistinct()) {
2274                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2275                                    }
2276                                    else {
2277                                            query.append(_ORDER_BY_ENTITY_TABLE);
2278                                    }
2279    
2280                                    query.append(orderByFields[i]);
2281    
2282                                    if ((i + 1) < orderByFields.length) {
2283                                            if (orderByComparator.isAscending() ^ previous) {
2284                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2285                                            }
2286                                            else {
2287                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2288                                            }
2289                                    }
2290                                    else {
2291                                            if (orderByComparator.isAscending() ^ previous) {
2292                                                    query.append(ORDER_BY_ASC);
2293                                            }
2294                                            else {
2295                                                    query.append(ORDER_BY_DESC);
2296                                            }
2297                                    }
2298                            }
2299                    }
2300    
2301                    else {
2302                            if (getDB().isSupportsInlineDistinct()) {
2303                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2304                            }
2305                            else {
2306                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
2307                            }
2308                    }
2309    
2310                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2311                                    AssetCategory.class.getName(),
2312                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2313    
2314                    SQLQuery q = session.createSQLQuery(sql);
2315    
2316                    q.setFirstResult(0);
2317                    q.setMaxResults(2);
2318    
2319                    if (getDB().isSupportsInlineDistinct()) {
2320                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
2321                    }
2322                    else {
2323                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
2324                    }
2325    
2326                    QueryPos qPos = QueryPos.getInstance(q);
2327    
2328                    qPos.add(groupId);
2329    
2330                    if (orderByComparator != null) {
2331                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2332    
2333                            for (Object value : values) {
2334                                    qPos.add(value);
2335                            }
2336                    }
2337    
2338                    List<AssetCategory> list = q.list();
2339    
2340                    if (list.size() == 2) {
2341                            return list.get(1);
2342                    }
2343                    else {
2344                            return null;
2345                    }
2346            }
2347    
2348            /**
2349             * Returns all the asset categories where parentCategoryId = &#63;.
2350             *
2351             * @param parentCategoryId the parent category ID
2352             * @return the matching asset categories
2353             * @throws SystemException if a system exception occurred
2354             */
2355            public List<AssetCategory> findByParentCategoryId(long parentCategoryId)
2356                    throws SystemException {
2357                    return findByParentCategoryId(parentCategoryId, QueryUtil.ALL_POS,
2358                            QueryUtil.ALL_POS, null);
2359            }
2360    
2361            /**
2362             * Returns a range of all the asset categories where parentCategoryId = &#63;.
2363             *
2364             * <p>
2365             * 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.
2366             * </p>
2367             *
2368             * @param parentCategoryId the parent category ID
2369             * @param start the lower bound of the range of asset categories
2370             * @param end the upper bound of the range of asset categories (not inclusive)
2371             * @return the range of matching asset categories
2372             * @throws SystemException if a system exception occurred
2373             */
2374            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2375                    int start, int end) throws SystemException {
2376                    return findByParentCategoryId(parentCategoryId, start, end, null);
2377            }
2378    
2379            /**
2380             * Returns an ordered range of all the asset categories where parentCategoryId = &#63;.
2381             *
2382             * <p>
2383             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2384             * </p>
2385             *
2386             * @param parentCategoryId the parent category ID
2387             * @param start the lower bound of the range of asset categories
2388             * @param end the upper bound of the range of asset categories (not inclusive)
2389             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2390             * @return the ordered range of matching asset categories
2391             * @throws SystemException if a system exception occurred
2392             */
2393            public List<AssetCategory> findByParentCategoryId(long parentCategoryId,
2394                    int start, int end, OrderByComparator orderByComparator)
2395                    throws SystemException {
2396                    FinderPath finderPath = null;
2397                    Object[] finderArgs = null;
2398    
2399                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2400                                    (orderByComparator == null)) {
2401                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_PARENTCATEGORYID;
2402                            finderArgs = new Object[] { parentCategoryId };
2403                    }
2404                    else {
2405                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_PARENTCATEGORYID;
2406                            finderArgs = new Object[] {
2407                                            parentCategoryId,
2408                                            
2409                                            start, end, orderByComparator
2410                                    };
2411                    }
2412    
2413                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2414                                    finderArgs, this);
2415    
2416                    if ((list != null) && !list.isEmpty()) {
2417                            for (AssetCategory assetCategory : list) {
2418                                    if ((parentCategoryId != assetCategory.getParentCategoryId())) {
2419                                            list = null;
2420    
2421                                            break;
2422                                    }
2423                            }
2424                    }
2425    
2426                    if (list == null) {
2427                            StringBundler query = null;
2428    
2429                            if (orderByComparator != null) {
2430                                    query = new StringBundler(3 +
2431                                                    (orderByComparator.getOrderByFields().length * 3));
2432                            }
2433                            else {
2434                                    query = new StringBundler(3);
2435                            }
2436    
2437                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2438    
2439                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2440    
2441                            if (orderByComparator != null) {
2442                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2443                                            orderByComparator);
2444                            }
2445    
2446                            else {
2447                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2448                            }
2449    
2450                            String sql = query.toString();
2451    
2452                            Session session = null;
2453    
2454                            try {
2455                                    session = openSession();
2456    
2457                                    Query q = session.createQuery(sql);
2458    
2459                                    QueryPos qPos = QueryPos.getInstance(q);
2460    
2461                                    qPos.add(parentCategoryId);
2462    
2463                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2464                                                    start, end);
2465                            }
2466                            catch (Exception e) {
2467                                    throw processException(e);
2468                            }
2469                            finally {
2470                                    if (list == null) {
2471                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2472                                    }
2473                                    else {
2474                                            cacheResult(list);
2475    
2476                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2477                                    }
2478    
2479                                    closeSession(session);
2480                            }
2481                    }
2482    
2483                    return list;
2484            }
2485    
2486            /**
2487             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2488             *
2489             * @param parentCategoryId the parent category ID
2490             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2491             * @return the first matching asset category
2492             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2493             * @throws SystemException if a system exception occurred
2494             */
2495            public AssetCategory findByParentCategoryId_First(long parentCategoryId,
2496                    OrderByComparator orderByComparator)
2497                    throws NoSuchCategoryException, SystemException {
2498                    AssetCategory assetCategory = fetchByParentCategoryId_First(parentCategoryId,
2499                                    orderByComparator);
2500    
2501                    if (assetCategory != null) {
2502                            return assetCategory;
2503                    }
2504    
2505                    StringBundler msg = new StringBundler(4);
2506    
2507                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2508    
2509                    msg.append("parentCategoryId=");
2510                    msg.append(parentCategoryId);
2511    
2512                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2513    
2514                    throw new NoSuchCategoryException(msg.toString());
2515            }
2516    
2517            /**
2518             * Returns the first asset category in the ordered set where parentCategoryId = &#63;.
2519             *
2520             * @param parentCategoryId the parent category ID
2521             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2522             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
2523             * @throws SystemException if a system exception occurred
2524             */
2525            public AssetCategory fetchByParentCategoryId_First(long parentCategoryId,
2526                    OrderByComparator orderByComparator) throws SystemException {
2527                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId, 0,
2528                                    1, orderByComparator);
2529    
2530                    if (!list.isEmpty()) {
2531                            return list.get(0);
2532                    }
2533    
2534                    return null;
2535            }
2536    
2537            /**
2538             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2539             *
2540             * @param parentCategoryId the parent category ID
2541             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2542             * @return the last matching asset category
2543             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2544             * @throws SystemException if a system exception occurred
2545             */
2546            public AssetCategory findByParentCategoryId_Last(long parentCategoryId,
2547                    OrderByComparator orderByComparator)
2548                    throws NoSuchCategoryException, SystemException {
2549                    AssetCategory assetCategory = fetchByParentCategoryId_Last(parentCategoryId,
2550                                    orderByComparator);
2551    
2552                    if (assetCategory != null) {
2553                            return assetCategory;
2554                    }
2555    
2556                    StringBundler msg = new StringBundler(4);
2557    
2558                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2559    
2560                    msg.append("parentCategoryId=");
2561                    msg.append(parentCategoryId);
2562    
2563                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2564    
2565                    throw new NoSuchCategoryException(msg.toString());
2566            }
2567    
2568            /**
2569             * Returns the last asset category in the ordered set where parentCategoryId = &#63;.
2570             *
2571             * @param parentCategoryId the parent category ID
2572             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2573             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
2574             * @throws SystemException if a system exception occurred
2575             */
2576            public AssetCategory fetchByParentCategoryId_Last(long parentCategoryId,
2577                    OrderByComparator orderByComparator) throws SystemException {
2578                    int count = countByParentCategoryId(parentCategoryId);
2579    
2580                    List<AssetCategory> list = findByParentCategoryId(parentCategoryId,
2581                                    count - 1, count, orderByComparator);
2582    
2583                    if (!list.isEmpty()) {
2584                            return list.get(0);
2585                    }
2586    
2587                    return null;
2588            }
2589    
2590            /**
2591             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63;.
2592             *
2593             * @param categoryId the primary key of the current asset category
2594             * @param parentCategoryId the parent category ID
2595             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2596             * @return the previous, current, and next asset category
2597             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2598             * @throws SystemException if a system exception occurred
2599             */
2600            public AssetCategory[] findByParentCategoryId_PrevAndNext(long categoryId,
2601                    long parentCategoryId, OrderByComparator orderByComparator)
2602                    throws NoSuchCategoryException, SystemException {
2603                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2604    
2605                    Session session = null;
2606    
2607                    try {
2608                            session = openSession();
2609    
2610                            AssetCategory[] array = new AssetCategoryImpl[3];
2611    
2612                            array[0] = getByParentCategoryId_PrevAndNext(session,
2613                                            assetCategory, parentCategoryId, orderByComparator, true);
2614    
2615                            array[1] = assetCategory;
2616    
2617                            array[2] = getByParentCategoryId_PrevAndNext(session,
2618                                            assetCategory, parentCategoryId, orderByComparator, false);
2619    
2620                            return array;
2621                    }
2622                    catch (Exception e) {
2623                            throw processException(e);
2624                    }
2625                    finally {
2626                            closeSession(session);
2627                    }
2628            }
2629    
2630            protected AssetCategory getByParentCategoryId_PrevAndNext(Session session,
2631                    AssetCategory assetCategory, long parentCategoryId,
2632                    OrderByComparator orderByComparator, boolean previous) {
2633                    StringBundler query = null;
2634    
2635                    if (orderByComparator != null) {
2636                            query = new StringBundler(6 +
2637                                            (orderByComparator.getOrderByFields().length * 6));
2638                    }
2639                    else {
2640                            query = new StringBundler(3);
2641                    }
2642    
2643                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2644    
2645                    query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
2646    
2647                    if (orderByComparator != null) {
2648                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2649    
2650                            if (orderByConditionFields.length > 0) {
2651                                    query.append(WHERE_AND);
2652                            }
2653    
2654                            for (int i = 0; i < orderByConditionFields.length; i++) {
2655                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2656                                    query.append(orderByConditionFields[i]);
2657    
2658                                    if ((i + 1) < orderByConditionFields.length) {
2659                                            if (orderByComparator.isAscending() ^ previous) {
2660                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2661                                            }
2662                                            else {
2663                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2664                                            }
2665                                    }
2666                                    else {
2667                                            if (orderByComparator.isAscending() ^ previous) {
2668                                                    query.append(WHERE_GREATER_THAN);
2669                                            }
2670                                            else {
2671                                                    query.append(WHERE_LESSER_THAN);
2672                                            }
2673                                    }
2674                            }
2675    
2676                            query.append(ORDER_BY_CLAUSE);
2677    
2678                            String[] orderByFields = orderByComparator.getOrderByFields();
2679    
2680                            for (int i = 0; i < orderByFields.length; i++) {
2681                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2682                                    query.append(orderByFields[i]);
2683    
2684                                    if ((i + 1) < orderByFields.length) {
2685                                            if (orderByComparator.isAscending() ^ previous) {
2686                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2687                                            }
2688                                            else {
2689                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2690                                            }
2691                                    }
2692                                    else {
2693                                            if (orderByComparator.isAscending() ^ previous) {
2694                                                    query.append(ORDER_BY_ASC);
2695                                            }
2696                                            else {
2697                                                    query.append(ORDER_BY_DESC);
2698                                            }
2699                                    }
2700                            }
2701                    }
2702    
2703                    else {
2704                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2705                    }
2706    
2707                    String sql = query.toString();
2708    
2709                    Query q = session.createQuery(sql);
2710    
2711                    q.setFirstResult(0);
2712                    q.setMaxResults(2);
2713    
2714                    QueryPos qPos = QueryPos.getInstance(q);
2715    
2716                    qPos.add(parentCategoryId);
2717    
2718                    if (orderByComparator != null) {
2719                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
2720    
2721                            for (Object value : values) {
2722                                    qPos.add(value);
2723                            }
2724                    }
2725    
2726                    List<AssetCategory> list = q.list();
2727    
2728                    if (list.size() == 2) {
2729                            return list.get(1);
2730                    }
2731                    else {
2732                            return null;
2733                    }
2734            }
2735    
2736            /**
2737             * Returns all the asset categories where vocabularyId = &#63;.
2738             *
2739             * @param vocabularyId the vocabulary ID
2740             * @return the matching asset categories
2741             * @throws SystemException if a system exception occurred
2742             */
2743            public List<AssetCategory> findByVocabularyId(long vocabularyId)
2744                    throws SystemException {
2745                    return findByVocabularyId(vocabularyId, QueryUtil.ALL_POS,
2746                            QueryUtil.ALL_POS, null);
2747            }
2748    
2749            /**
2750             * Returns a range of all the asset categories where vocabularyId = &#63;.
2751             *
2752             * <p>
2753             * 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.
2754             * </p>
2755             *
2756             * @param vocabularyId the vocabulary ID
2757             * @param start the lower bound of the range of asset categories
2758             * @param end the upper bound of the range of asset categories (not inclusive)
2759             * @return the range of matching asset categories
2760             * @throws SystemException if a system exception occurred
2761             */
2762            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2763                    int end) throws SystemException {
2764                    return findByVocabularyId(vocabularyId, start, end, null);
2765            }
2766    
2767            /**
2768             * Returns an ordered range of all the asset categories where vocabularyId = &#63;.
2769             *
2770             * <p>
2771             * 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.
2772             * </p>
2773             *
2774             * @param vocabularyId the vocabulary ID
2775             * @param start the lower bound of the range of asset categories
2776             * @param end the upper bound of the range of asset categories (not inclusive)
2777             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2778             * @return the ordered range of matching asset categories
2779             * @throws SystemException if a system exception occurred
2780             */
2781            public List<AssetCategory> findByVocabularyId(long vocabularyId, int start,
2782                    int end, OrderByComparator orderByComparator) throws SystemException {
2783                    FinderPath finderPath = null;
2784                    Object[] finderArgs = null;
2785    
2786                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2787                                    (orderByComparator == null)) {
2788                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_VOCABULARYID;
2789                            finderArgs = new Object[] { vocabularyId };
2790                    }
2791                    else {
2792                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_VOCABULARYID;
2793                            finderArgs = new Object[] {
2794                                            vocabularyId,
2795                                            
2796                                            start, end, orderByComparator
2797                                    };
2798                    }
2799    
2800                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
2801                                    finderArgs, this);
2802    
2803                    if ((list != null) && !list.isEmpty()) {
2804                            for (AssetCategory assetCategory : list) {
2805                                    if ((vocabularyId != assetCategory.getVocabularyId())) {
2806                                            list = null;
2807    
2808                                            break;
2809                                    }
2810                            }
2811                    }
2812    
2813                    if (list == null) {
2814                            StringBundler query = null;
2815    
2816                            if (orderByComparator != null) {
2817                                    query = new StringBundler(3 +
2818                                                    (orderByComparator.getOrderByFields().length * 3));
2819                            }
2820                            else {
2821                                    query = new StringBundler(3);
2822                            }
2823    
2824                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
2825    
2826                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
2827    
2828                            if (orderByComparator != null) {
2829                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2830                                            orderByComparator);
2831                            }
2832    
2833                            else {
2834                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
2835                            }
2836    
2837                            String sql = query.toString();
2838    
2839                            Session session = null;
2840    
2841                            try {
2842                                    session = openSession();
2843    
2844                                    Query q = session.createQuery(sql);
2845    
2846                                    QueryPos qPos = QueryPos.getInstance(q);
2847    
2848                                    qPos.add(vocabularyId);
2849    
2850                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
2851                                                    start, end);
2852                            }
2853                            catch (Exception e) {
2854                                    throw processException(e);
2855                            }
2856                            finally {
2857                                    if (list == null) {
2858                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2859                                    }
2860                                    else {
2861                                            cacheResult(list);
2862    
2863                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2864                                    }
2865    
2866                                    closeSession(session);
2867                            }
2868                    }
2869    
2870                    return list;
2871            }
2872    
2873            /**
2874             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
2875             *
2876             * @param vocabularyId the vocabulary ID
2877             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2878             * @return the first matching asset category
2879             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2880             * @throws SystemException if a system exception occurred
2881             */
2882            public AssetCategory findByVocabularyId_First(long vocabularyId,
2883                    OrderByComparator orderByComparator)
2884                    throws NoSuchCategoryException, SystemException {
2885                    AssetCategory assetCategory = fetchByVocabularyId_First(vocabularyId,
2886                                    orderByComparator);
2887    
2888                    if (assetCategory != null) {
2889                            return assetCategory;
2890                    }
2891    
2892                    StringBundler msg = new StringBundler(4);
2893    
2894                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2895    
2896                    msg.append("vocabularyId=");
2897                    msg.append(vocabularyId);
2898    
2899                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2900    
2901                    throw new NoSuchCategoryException(msg.toString());
2902            }
2903    
2904            /**
2905             * Returns the first asset category in the ordered set where vocabularyId = &#63;.
2906             *
2907             * @param vocabularyId the vocabulary ID
2908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2909             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
2910             * @throws SystemException if a system exception occurred
2911             */
2912            public AssetCategory fetchByVocabularyId_First(long vocabularyId,
2913                    OrderByComparator orderByComparator) throws SystemException {
2914                    List<AssetCategory> list = findByVocabularyId(vocabularyId, 0, 1,
2915                                    orderByComparator);
2916    
2917                    if (!list.isEmpty()) {
2918                            return list.get(0);
2919                    }
2920    
2921                    return null;
2922            }
2923    
2924            /**
2925             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
2926             *
2927             * @param vocabularyId the vocabulary ID
2928             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2929             * @return the last matching asset category
2930             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
2931             * @throws SystemException if a system exception occurred
2932             */
2933            public AssetCategory findByVocabularyId_Last(long vocabularyId,
2934                    OrderByComparator orderByComparator)
2935                    throws NoSuchCategoryException, SystemException {
2936                    AssetCategory assetCategory = fetchByVocabularyId_Last(vocabularyId,
2937                                    orderByComparator);
2938    
2939                    if (assetCategory != null) {
2940                            return assetCategory;
2941                    }
2942    
2943                    StringBundler msg = new StringBundler(4);
2944    
2945                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2946    
2947                    msg.append("vocabularyId=");
2948                    msg.append(vocabularyId);
2949    
2950                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2951    
2952                    throw new NoSuchCategoryException(msg.toString());
2953            }
2954    
2955            /**
2956             * Returns the last asset category in the ordered set where vocabularyId = &#63;.
2957             *
2958             * @param vocabularyId the vocabulary ID
2959             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2960             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
2961             * @throws SystemException if a system exception occurred
2962             */
2963            public AssetCategory fetchByVocabularyId_Last(long vocabularyId,
2964                    OrderByComparator orderByComparator) throws SystemException {
2965                    int count = countByVocabularyId(vocabularyId);
2966    
2967                    List<AssetCategory> list = findByVocabularyId(vocabularyId, count - 1,
2968                                    count, orderByComparator);
2969    
2970                    if (!list.isEmpty()) {
2971                            return list.get(0);
2972                    }
2973    
2974                    return null;
2975            }
2976    
2977            /**
2978             * Returns the asset categories before and after the current asset category in the ordered set where vocabularyId = &#63;.
2979             *
2980             * @param categoryId the primary key of the current asset category
2981             * @param vocabularyId the vocabulary ID
2982             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2983             * @return the previous, current, and next asset category
2984             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
2985             * @throws SystemException if a system exception occurred
2986             */
2987            public AssetCategory[] findByVocabularyId_PrevAndNext(long categoryId,
2988                    long vocabularyId, OrderByComparator orderByComparator)
2989                    throws NoSuchCategoryException, SystemException {
2990                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
2991    
2992                    Session session = null;
2993    
2994                    try {
2995                            session = openSession();
2996    
2997                            AssetCategory[] array = new AssetCategoryImpl[3];
2998    
2999                            array[0] = getByVocabularyId_PrevAndNext(session, assetCategory,
3000                                            vocabularyId, orderByComparator, true);
3001    
3002                            array[1] = assetCategory;
3003    
3004                            array[2] = getByVocabularyId_PrevAndNext(session, assetCategory,
3005                                            vocabularyId, orderByComparator, false);
3006    
3007                            return array;
3008                    }
3009                    catch (Exception e) {
3010                            throw processException(e);
3011                    }
3012                    finally {
3013                            closeSession(session);
3014                    }
3015            }
3016    
3017            protected AssetCategory getByVocabularyId_PrevAndNext(Session session,
3018                    AssetCategory assetCategory, long vocabularyId,
3019                    OrderByComparator orderByComparator, boolean previous) {
3020                    StringBundler query = null;
3021    
3022                    if (orderByComparator != null) {
3023                            query = new StringBundler(6 +
3024                                            (orderByComparator.getOrderByFields().length * 6));
3025                    }
3026                    else {
3027                            query = new StringBundler(3);
3028                    }
3029    
3030                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3031    
3032                    query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
3033    
3034                    if (orderByComparator != null) {
3035                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3036    
3037                            if (orderByConditionFields.length > 0) {
3038                                    query.append(WHERE_AND);
3039                            }
3040    
3041                            for (int i = 0; i < orderByConditionFields.length; i++) {
3042                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3043                                    query.append(orderByConditionFields[i]);
3044    
3045                                    if ((i + 1) < orderByConditionFields.length) {
3046                                            if (orderByComparator.isAscending() ^ previous) {
3047                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3048                                            }
3049                                            else {
3050                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3051                                            }
3052                                    }
3053                                    else {
3054                                            if (orderByComparator.isAscending() ^ previous) {
3055                                                    query.append(WHERE_GREATER_THAN);
3056                                            }
3057                                            else {
3058                                                    query.append(WHERE_LESSER_THAN);
3059                                            }
3060                                    }
3061                            }
3062    
3063                            query.append(ORDER_BY_CLAUSE);
3064    
3065                            String[] orderByFields = orderByComparator.getOrderByFields();
3066    
3067                            for (int i = 0; i < orderByFields.length; i++) {
3068                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3069                                    query.append(orderByFields[i]);
3070    
3071                                    if ((i + 1) < orderByFields.length) {
3072                                            if (orderByComparator.isAscending() ^ previous) {
3073                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3074                                            }
3075                                            else {
3076                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3077                                            }
3078                                    }
3079                                    else {
3080                                            if (orderByComparator.isAscending() ^ previous) {
3081                                                    query.append(ORDER_BY_ASC);
3082                                            }
3083                                            else {
3084                                                    query.append(ORDER_BY_DESC);
3085                                            }
3086                                    }
3087                            }
3088                    }
3089    
3090                    else {
3091                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3092                    }
3093    
3094                    String sql = query.toString();
3095    
3096                    Query q = session.createQuery(sql);
3097    
3098                    q.setFirstResult(0);
3099                    q.setMaxResults(2);
3100    
3101                    QueryPos qPos = QueryPos.getInstance(q);
3102    
3103                    qPos.add(vocabularyId);
3104    
3105                    if (orderByComparator != null) {
3106                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3107    
3108                            for (Object value : values) {
3109                                    qPos.add(value);
3110                            }
3111                    }
3112    
3113                    List<AssetCategory> list = q.list();
3114    
3115                    if (list.size() == 2) {
3116                            return list.get(1);
3117                    }
3118                    else {
3119                            return null;
3120                    }
3121            }
3122    
3123            /**
3124             * Returns all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3125             *
3126             * @param groupId the group ID
3127             * @param vocabularyId the vocabulary ID
3128             * @return the matching asset categories
3129             * @throws SystemException if a system exception occurred
3130             */
3131            public List<AssetCategory> findByG_V(long groupId, long vocabularyId)
3132                    throws SystemException {
3133                    return findByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3134                            QueryUtil.ALL_POS, null);
3135            }
3136    
3137            /**
3138             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3139             *
3140             * <p>
3141             * 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.
3142             * </p>
3143             *
3144             * @param groupId the group ID
3145             * @param vocabularyId the vocabulary ID
3146             * @param start the lower bound of the range of asset categories
3147             * @param end the upper bound of the range of asset categories (not inclusive)
3148             * @return the range of matching asset categories
3149             * @throws SystemException if a system exception occurred
3150             */
3151            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3152                    int start, int end) throws SystemException {
3153                    return findByG_V(groupId, vocabularyId, start, end, null);
3154            }
3155    
3156            /**
3157             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = &#63;.
3158             *
3159             * <p>
3160             * 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.
3161             * </p>
3162             *
3163             * @param groupId the group ID
3164             * @param vocabularyId the vocabulary ID
3165             * @param start the lower bound of the range of asset categories
3166             * @param end the upper bound of the range of asset categories (not inclusive)
3167             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3168             * @return the ordered range of matching asset categories
3169             * @throws SystemException if a system exception occurred
3170             */
3171            public List<AssetCategory> findByG_V(long groupId, long vocabularyId,
3172                    int start, int end, OrderByComparator orderByComparator)
3173                    throws SystemException {
3174                    FinderPath finderPath = null;
3175                    Object[] finderArgs = null;
3176    
3177                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3178                                    (orderByComparator == null)) {
3179                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_V;
3180                            finderArgs = new Object[] { groupId, vocabularyId };
3181                    }
3182                    else {
3183                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3184                            finderArgs = new Object[] {
3185                                            groupId, vocabularyId,
3186                                            
3187                                            start, end, orderByComparator
3188                                    };
3189                    }
3190    
3191                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3192                                    finderArgs, this);
3193    
3194                    if ((list != null) && !list.isEmpty()) {
3195                            for (AssetCategory assetCategory : list) {
3196                                    if ((groupId != assetCategory.getGroupId()) ||
3197                                                    (vocabularyId != assetCategory.getVocabularyId())) {
3198                                            list = null;
3199    
3200                                            break;
3201                                    }
3202                            }
3203                    }
3204    
3205                    if (list == null) {
3206                            StringBundler query = null;
3207    
3208                            if (orderByComparator != null) {
3209                                    query = new StringBundler(4 +
3210                                                    (orderByComparator.getOrderByFields().length * 3));
3211                            }
3212                            else {
3213                                    query = new StringBundler(4);
3214                            }
3215    
3216                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3217    
3218                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3219    
3220                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3221    
3222                            if (orderByComparator != null) {
3223                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3224                                            orderByComparator);
3225                            }
3226    
3227                            else {
3228                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3229                            }
3230    
3231                            String sql = query.toString();
3232    
3233                            Session session = null;
3234    
3235                            try {
3236                                    session = openSession();
3237    
3238                                    Query q = session.createQuery(sql);
3239    
3240                                    QueryPos qPos = QueryPos.getInstance(q);
3241    
3242                                    qPos.add(groupId);
3243    
3244                                    qPos.add(vocabularyId);
3245    
3246                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3247                                                    start, end);
3248                            }
3249                            catch (Exception e) {
3250                                    throw processException(e);
3251                            }
3252                            finally {
3253                                    if (list == null) {
3254                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3255                                    }
3256                                    else {
3257                                            cacheResult(list);
3258    
3259                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3260                                    }
3261    
3262                                    closeSession(session);
3263                            }
3264                    }
3265    
3266                    return list;
3267            }
3268    
3269            /**
3270             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3271             *
3272             * @param groupId the group ID
3273             * @param vocabularyId the vocabulary ID
3274             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3275             * @return the first matching asset category
3276             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3277             * @throws SystemException if a system exception occurred
3278             */
3279            public AssetCategory findByG_V_First(long groupId, long vocabularyId,
3280                    OrderByComparator orderByComparator)
3281                    throws NoSuchCategoryException, SystemException {
3282                    AssetCategory assetCategory = fetchByG_V_First(groupId, vocabularyId,
3283                                    orderByComparator);
3284    
3285                    if (assetCategory != null) {
3286                            return assetCategory;
3287                    }
3288    
3289                    StringBundler msg = new StringBundler(6);
3290    
3291                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3292    
3293                    msg.append("groupId=");
3294                    msg.append(groupId);
3295    
3296                    msg.append(", vocabularyId=");
3297                    msg.append(vocabularyId);
3298    
3299                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3300    
3301                    throw new NoSuchCategoryException(msg.toString());
3302            }
3303    
3304            /**
3305             * Returns the first asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3306             *
3307             * @param groupId the group ID
3308             * @param vocabularyId the vocabulary ID
3309             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3310             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
3311             * @throws SystemException if a system exception occurred
3312             */
3313            public AssetCategory fetchByG_V_First(long groupId, long vocabularyId,
3314                    OrderByComparator orderByComparator) throws SystemException {
3315                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, 0, 1,
3316                                    orderByComparator);
3317    
3318                    if (!list.isEmpty()) {
3319                            return list.get(0);
3320                    }
3321    
3322                    return null;
3323            }
3324    
3325            /**
3326             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3327             *
3328             * @param groupId the group ID
3329             * @param vocabularyId the vocabulary ID
3330             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3331             * @return the last matching asset category
3332             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
3333             * @throws SystemException if a system exception occurred
3334             */
3335            public AssetCategory findByG_V_Last(long groupId, long vocabularyId,
3336                    OrderByComparator orderByComparator)
3337                    throws NoSuchCategoryException, SystemException {
3338                    AssetCategory assetCategory = fetchByG_V_Last(groupId, vocabularyId,
3339                                    orderByComparator);
3340    
3341                    if (assetCategory != null) {
3342                            return assetCategory;
3343                    }
3344    
3345                    StringBundler msg = new StringBundler(6);
3346    
3347                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3348    
3349                    msg.append("groupId=");
3350                    msg.append(groupId);
3351    
3352                    msg.append(", vocabularyId=");
3353                    msg.append(vocabularyId);
3354    
3355                    msg.append(StringPool.CLOSE_CURLY_BRACE);
3356    
3357                    throw new NoSuchCategoryException(msg.toString());
3358            }
3359    
3360            /**
3361             * Returns the last asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3362             *
3363             * @param groupId the group ID
3364             * @param vocabularyId the vocabulary ID
3365             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3366             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
3367             * @throws SystemException if a system exception occurred
3368             */
3369            public AssetCategory fetchByG_V_Last(long groupId, long vocabularyId,
3370                    OrderByComparator orderByComparator) throws SystemException {
3371                    int count = countByG_V(groupId, vocabularyId);
3372    
3373                    List<AssetCategory> list = findByG_V(groupId, vocabularyId, count - 1,
3374                                    count, orderByComparator);
3375    
3376                    if (!list.isEmpty()) {
3377                            return list.get(0);
3378                    }
3379    
3380                    return null;
3381            }
3382    
3383            /**
3384             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and vocabularyId = &#63;.
3385             *
3386             * @param categoryId the primary key of the current asset category
3387             * @param groupId the group ID
3388             * @param vocabularyId the vocabulary ID
3389             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3390             * @return the previous, current, and next asset category
3391             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3392             * @throws SystemException if a system exception occurred
3393             */
3394            public AssetCategory[] findByG_V_PrevAndNext(long categoryId, long groupId,
3395                    long vocabularyId, OrderByComparator orderByComparator)
3396                    throws NoSuchCategoryException, SystemException {
3397                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3398    
3399                    Session session = null;
3400    
3401                    try {
3402                            session = openSession();
3403    
3404                            AssetCategory[] array = new AssetCategoryImpl[3];
3405    
3406                            array[0] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3407                                            vocabularyId, orderByComparator, true);
3408    
3409                            array[1] = assetCategory;
3410    
3411                            array[2] = getByG_V_PrevAndNext(session, assetCategory, groupId,
3412                                            vocabularyId, orderByComparator, false);
3413    
3414                            return array;
3415                    }
3416                    catch (Exception e) {
3417                            throw processException(e);
3418                    }
3419                    finally {
3420                            closeSession(session);
3421                    }
3422            }
3423    
3424            protected AssetCategory getByG_V_PrevAndNext(Session session,
3425                    AssetCategory assetCategory, long groupId, long vocabularyId,
3426                    OrderByComparator orderByComparator, boolean previous) {
3427                    StringBundler query = null;
3428    
3429                    if (orderByComparator != null) {
3430                            query = new StringBundler(6 +
3431                                            (orderByComparator.getOrderByFields().length * 6));
3432                    }
3433                    else {
3434                            query = new StringBundler(3);
3435                    }
3436    
3437                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3438    
3439                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3440    
3441                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3442    
3443                    if (orderByComparator != null) {
3444                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3445    
3446                            if (orderByConditionFields.length > 0) {
3447                                    query.append(WHERE_AND);
3448                            }
3449    
3450                            for (int i = 0; i < orderByConditionFields.length; i++) {
3451                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3452                                    query.append(orderByConditionFields[i]);
3453    
3454                                    if ((i + 1) < orderByConditionFields.length) {
3455                                            if (orderByComparator.isAscending() ^ previous) {
3456                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3457                                            }
3458                                            else {
3459                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3460                                            }
3461                                    }
3462                                    else {
3463                                            if (orderByComparator.isAscending() ^ previous) {
3464                                                    query.append(WHERE_GREATER_THAN);
3465                                            }
3466                                            else {
3467                                                    query.append(WHERE_LESSER_THAN);
3468                                            }
3469                                    }
3470                            }
3471    
3472                            query.append(ORDER_BY_CLAUSE);
3473    
3474                            String[] orderByFields = orderByComparator.getOrderByFields();
3475    
3476                            for (int i = 0; i < orderByFields.length; i++) {
3477                                    query.append(_ORDER_BY_ENTITY_ALIAS);
3478                                    query.append(orderByFields[i]);
3479    
3480                                    if ((i + 1) < orderByFields.length) {
3481                                            if (orderByComparator.isAscending() ^ previous) {
3482                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3483                                            }
3484                                            else {
3485                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3486                                            }
3487                                    }
3488                                    else {
3489                                            if (orderByComparator.isAscending() ^ previous) {
3490                                                    query.append(ORDER_BY_ASC);
3491                                            }
3492                                            else {
3493                                                    query.append(ORDER_BY_DESC);
3494                                            }
3495                                    }
3496                            }
3497                    }
3498    
3499                    else {
3500                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3501                    }
3502    
3503                    String sql = query.toString();
3504    
3505                    Query q = session.createQuery(sql);
3506    
3507                    q.setFirstResult(0);
3508                    q.setMaxResults(2);
3509    
3510                    QueryPos qPos = QueryPos.getInstance(q);
3511    
3512                    qPos.add(groupId);
3513    
3514                    qPos.add(vocabularyId);
3515    
3516                    if (orderByComparator != null) {
3517                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
3518    
3519                            for (Object value : values) {
3520                                    qPos.add(value);
3521                            }
3522                    }
3523    
3524                    List<AssetCategory> list = q.list();
3525    
3526                    if (list.size() == 2) {
3527                            return list.get(1);
3528                    }
3529                    else {
3530                            return null;
3531                    }
3532            }
3533    
3534            /**
3535             * Returns all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
3536             *
3537             * <p>
3538             * 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.
3539             * </p>
3540             *
3541             * @param groupId the group ID
3542             * @param vocabularyIds the vocabulary IDs
3543             * @return the matching asset categories
3544             * @throws SystemException if a system exception occurred
3545             */
3546            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds)
3547                    throws SystemException {
3548                    return findByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
3549                            QueryUtil.ALL_POS, null);
3550            }
3551    
3552            /**
3553             * Returns a range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
3554             *
3555             * <p>
3556             * 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.
3557             * </p>
3558             *
3559             * @param groupId the group ID
3560             * @param vocabularyIds the vocabulary IDs
3561             * @param start the lower bound of the range of asset categories
3562             * @param end the upper bound of the range of asset categories (not inclusive)
3563             * @return the range of matching asset categories
3564             * @throws SystemException if a system exception occurred
3565             */
3566            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
3567                    int start, int end) throws SystemException {
3568                    return findByG_V(groupId, vocabularyIds, start, end, null);
3569            }
3570    
3571            /**
3572             * Returns an ordered range of all the asset categories where groupId = &#63; and vocabularyId = any &#63;.
3573             *
3574             * <p>
3575             * 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.
3576             * </p>
3577             *
3578             * @param groupId the group ID
3579             * @param vocabularyIds the vocabulary IDs
3580             * @param start the lower bound of the range of asset categories
3581             * @param end the upper bound of the range of asset categories (not inclusive)
3582             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3583             * @return the ordered range of matching asset categories
3584             * @throws SystemException if a system exception occurred
3585             */
3586            public List<AssetCategory> findByG_V(long groupId, long[] vocabularyIds,
3587                    int start, int end, OrderByComparator orderByComparator)
3588                    throws SystemException {
3589                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_V;
3590                    Object[] finderArgs = null;
3591    
3592                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3593                                    (orderByComparator == null)) {
3594                            finderArgs = new Object[] { groupId, StringUtil.merge(vocabularyIds) };
3595                    }
3596                    else {
3597                            finderArgs = new Object[] {
3598                                            groupId, StringUtil.merge(vocabularyIds),
3599                                            
3600                                            start, end, orderByComparator
3601                                    };
3602                    }
3603    
3604                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
3605                                    finderArgs, this);
3606    
3607                    if ((list != null) && !list.isEmpty()) {
3608                            for (AssetCategory assetCategory : list) {
3609                                    if ((groupId != assetCategory.getGroupId()) ||
3610                                                    !ArrayUtil.contains(vocabularyIds,
3611                                                            assetCategory.getVocabularyId())) {
3612                                            list = null;
3613    
3614                                            break;
3615                                    }
3616                            }
3617                    }
3618    
3619                    if (list == null) {
3620                            StringBundler query = new StringBundler();
3621    
3622                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
3623    
3624                            boolean conjunctionable = false;
3625    
3626                            if (conjunctionable) {
3627                                    query.append(WHERE_AND);
3628                            }
3629    
3630                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
3631    
3632                            conjunctionable = true;
3633    
3634                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
3635                                    if (conjunctionable) {
3636                                            query.append(WHERE_AND);
3637                                    }
3638    
3639                                    query.append(StringPool.OPEN_PARENTHESIS);
3640    
3641                                    for (int i = 0; i < vocabularyIds.length; i++) {
3642                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
3643    
3644                                            if ((i + 1) < vocabularyIds.length) {
3645                                                    query.append(WHERE_OR);
3646                                            }
3647                                    }
3648    
3649                                    query.append(StringPool.CLOSE_PARENTHESIS);
3650    
3651                                    conjunctionable = true;
3652                            }
3653    
3654                            if (orderByComparator != null) {
3655                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3656                                            orderByComparator);
3657                            }
3658    
3659                            else {
3660                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3661                            }
3662    
3663                            String sql = query.toString();
3664    
3665                            Session session = null;
3666    
3667                            try {
3668                                    session = openSession();
3669    
3670                                    Query q = session.createQuery(sql);
3671    
3672                                    QueryPos qPos = QueryPos.getInstance(q);
3673    
3674                                    qPos.add(groupId);
3675    
3676                                    if (vocabularyIds != null) {
3677                                            qPos.add(vocabularyIds);
3678                                    }
3679    
3680                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
3681                                                    start, end);
3682                            }
3683                            catch (Exception e) {
3684                                    throw processException(e);
3685                            }
3686                            finally {
3687                                    if (list == null) {
3688                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
3689                                    }
3690                                    else {
3691                                            cacheResult(list);
3692    
3693                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
3694                                    }
3695    
3696                                    closeSession(session);
3697                            }
3698                    }
3699    
3700                    return list;
3701            }
3702    
3703            /**
3704             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3705             *
3706             * @param groupId the group ID
3707             * @param vocabularyId the vocabulary ID
3708             * @return the matching asset categories that the user has permission to view
3709             * @throws SystemException if a system exception occurred
3710             */
3711            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId)
3712                    throws SystemException {
3713                    return filterFindByG_V(groupId, vocabularyId, QueryUtil.ALL_POS,
3714                            QueryUtil.ALL_POS, null);
3715            }
3716    
3717            /**
3718             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
3719             *
3720             * <p>
3721             * 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.
3722             * </p>
3723             *
3724             * @param groupId the group ID
3725             * @param vocabularyId the vocabulary ID
3726             * @param start the lower bound of the range of asset categories
3727             * @param end the upper bound of the range of asset categories (not inclusive)
3728             * @return the range of matching asset categories that the user has permission to view
3729             * @throws SystemException if a system exception occurred
3730             */
3731            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3732                    int start, int end) throws SystemException {
3733                    return filterFindByG_V(groupId, vocabularyId, start, end, null);
3734            }
3735    
3736            /**
3737             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and vocabularyId = &#63;.
3738             *
3739             * <p>
3740             * 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.
3741             * </p>
3742             *
3743             * @param groupId the group ID
3744             * @param vocabularyId the vocabulary ID
3745             * @param start the lower bound of the range of asset categories
3746             * @param end the upper bound of the range of asset categories (not inclusive)
3747             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3748             * @return the ordered range of matching asset categories that the user has permission to view
3749             * @throws SystemException if a system exception occurred
3750             */
3751            public List<AssetCategory> filterFindByG_V(long groupId, long vocabularyId,
3752                    int start, int end, OrderByComparator orderByComparator)
3753                    throws SystemException {
3754                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3755                            return findByG_V(groupId, vocabularyId, start, end,
3756                                    orderByComparator);
3757                    }
3758    
3759                    StringBundler query = null;
3760    
3761                    if (orderByComparator != null) {
3762                            query = new StringBundler(4 +
3763                                            (orderByComparator.getOrderByFields().length * 3));
3764                    }
3765                    else {
3766                            query = new StringBundler(4);
3767                    }
3768    
3769                    if (getDB().isSupportsInlineDistinct()) {
3770                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3771                    }
3772                    else {
3773                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3774                    }
3775    
3776                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3777    
3778                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3779    
3780                    if (!getDB().isSupportsInlineDistinct()) {
3781                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3782                    }
3783    
3784                    if (orderByComparator != null) {
3785                            if (getDB().isSupportsInlineDistinct()) {
3786                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3787                                            orderByComparator);
3788                            }
3789                            else {
3790                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3791                                            orderByComparator);
3792                            }
3793                    }
3794    
3795                    else {
3796                            if (getDB().isSupportsInlineDistinct()) {
3797                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3798                            }
3799                            else {
3800                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3801                            }
3802                    }
3803    
3804                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3805                                    AssetCategory.class.getName(),
3806                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3807    
3808                    Session session = null;
3809    
3810                    try {
3811                            session = openSession();
3812    
3813                            SQLQuery q = session.createSQLQuery(sql);
3814    
3815                            if (getDB().isSupportsInlineDistinct()) {
3816                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
3817                            }
3818                            else {
3819                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
3820                            }
3821    
3822                            QueryPos qPos = QueryPos.getInstance(q);
3823    
3824                            qPos.add(groupId);
3825    
3826                            qPos.add(vocabularyId);
3827    
3828                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
3829                                    end);
3830                    }
3831                    catch (Exception e) {
3832                            throw processException(e);
3833                    }
3834                    finally {
3835                            closeSession(session);
3836                    }
3837            }
3838    
3839            /**
3840             * 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;.
3841             *
3842             * @param categoryId the primary key of the current asset category
3843             * @param groupId the group ID
3844             * @param vocabularyId the vocabulary ID
3845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
3846             * @return the previous, current, and next asset category
3847             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
3848             * @throws SystemException if a system exception occurred
3849             */
3850            public AssetCategory[] filterFindByG_V_PrevAndNext(long categoryId,
3851                    long groupId, long vocabularyId, OrderByComparator orderByComparator)
3852                    throws NoSuchCategoryException, SystemException {
3853                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3854                            return findByG_V_PrevAndNext(categoryId, groupId, vocabularyId,
3855                                    orderByComparator);
3856                    }
3857    
3858                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
3859    
3860                    Session session = null;
3861    
3862                    try {
3863                            session = openSession();
3864    
3865                            AssetCategory[] array = new AssetCategoryImpl[3];
3866    
3867                            array[0] = filterGetByG_V_PrevAndNext(session, assetCategory,
3868                                            groupId, vocabularyId, orderByComparator, true);
3869    
3870                            array[1] = assetCategory;
3871    
3872                            array[2] = filterGetByG_V_PrevAndNext(session, assetCategory,
3873                                            groupId, vocabularyId, orderByComparator, false);
3874    
3875                            return array;
3876                    }
3877                    catch (Exception e) {
3878                            throw processException(e);
3879                    }
3880                    finally {
3881                            closeSession(session);
3882                    }
3883            }
3884    
3885            protected AssetCategory filterGetByG_V_PrevAndNext(Session session,
3886                    AssetCategory assetCategory, long groupId, long vocabularyId,
3887                    OrderByComparator orderByComparator, boolean previous) {
3888                    StringBundler query = null;
3889    
3890                    if (orderByComparator != null) {
3891                            query = new StringBundler(6 +
3892                                            (orderByComparator.getOrderByFields().length * 6));
3893                    }
3894                    else {
3895                            query = new StringBundler(3);
3896                    }
3897    
3898                    if (getDB().isSupportsInlineDistinct()) {
3899                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
3900                    }
3901                    else {
3902                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
3903                    }
3904    
3905                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
3906    
3907                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
3908    
3909                    if (!getDB().isSupportsInlineDistinct()) {
3910                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
3911                    }
3912    
3913                    if (orderByComparator != null) {
3914                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3915    
3916                            if (orderByConditionFields.length > 0) {
3917                                    query.append(WHERE_AND);
3918                            }
3919    
3920                            for (int i = 0; i < orderByConditionFields.length; i++) {
3921                                    if (getDB().isSupportsInlineDistinct()) {
3922                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3923                                    }
3924                                    else {
3925                                            query.append(_ORDER_BY_ENTITY_TABLE);
3926                                    }
3927    
3928                                    query.append(orderByConditionFields[i]);
3929    
3930                                    if ((i + 1) < orderByConditionFields.length) {
3931                                            if (orderByComparator.isAscending() ^ previous) {
3932                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
3933                                            }
3934                                            else {
3935                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
3936                                            }
3937                                    }
3938                                    else {
3939                                            if (orderByComparator.isAscending() ^ previous) {
3940                                                    query.append(WHERE_GREATER_THAN);
3941                                            }
3942                                            else {
3943                                                    query.append(WHERE_LESSER_THAN);
3944                                            }
3945                                    }
3946                            }
3947    
3948                            query.append(ORDER_BY_CLAUSE);
3949    
3950                            String[] orderByFields = orderByComparator.getOrderByFields();
3951    
3952                            for (int i = 0; i < orderByFields.length; i++) {
3953                                    if (getDB().isSupportsInlineDistinct()) {
3954                                            query.append(_ORDER_BY_ENTITY_ALIAS);
3955                                    }
3956                                    else {
3957                                            query.append(_ORDER_BY_ENTITY_TABLE);
3958                                    }
3959    
3960                                    query.append(orderByFields[i]);
3961    
3962                                    if ((i + 1) < orderByFields.length) {
3963                                            if (orderByComparator.isAscending() ^ previous) {
3964                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
3965                                            }
3966                                            else {
3967                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
3968                                            }
3969                                    }
3970                                    else {
3971                                            if (orderByComparator.isAscending() ^ previous) {
3972                                                    query.append(ORDER_BY_ASC);
3973                                            }
3974                                            else {
3975                                                    query.append(ORDER_BY_DESC);
3976                                            }
3977                                    }
3978                            }
3979                    }
3980    
3981                    else {
3982                            if (getDB().isSupportsInlineDistinct()) {
3983                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
3984                            }
3985                            else {
3986                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
3987                            }
3988                    }
3989    
3990                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3991                                    AssetCategory.class.getName(),
3992                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3993    
3994                    SQLQuery q = session.createSQLQuery(sql);
3995    
3996                    q.setFirstResult(0);
3997                    q.setMaxResults(2);
3998    
3999                    if (getDB().isSupportsInlineDistinct()) {
4000                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4001                    }
4002                    else {
4003                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4004                    }
4005    
4006                    QueryPos qPos = QueryPos.getInstance(q);
4007    
4008                    qPos.add(groupId);
4009    
4010                    qPos.add(vocabularyId);
4011    
4012                    if (orderByComparator != null) {
4013                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4014    
4015                            for (Object value : values) {
4016                                    qPos.add(value);
4017                            }
4018                    }
4019    
4020                    List<AssetCategory> list = q.list();
4021    
4022                    if (list.size() == 2) {
4023                            return list.get(1);
4024                    }
4025                    else {
4026                            return null;
4027                    }
4028            }
4029    
4030            /**
4031             * Returns all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4032             *
4033             * @param groupId the group ID
4034             * @param vocabularyIds the vocabulary IDs
4035             * @return the matching asset categories that the user has permission to view
4036             * @throws SystemException if a system exception occurred
4037             */
4038            public List<AssetCategory> filterFindByG_V(long groupId,
4039                    long[] vocabularyIds) throws SystemException {
4040                    return filterFindByG_V(groupId, vocabularyIds, QueryUtil.ALL_POS,
4041                            QueryUtil.ALL_POS, null);
4042            }
4043    
4044            /**
4045             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4046             *
4047             * <p>
4048             * 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.
4049             * </p>
4050             *
4051             * @param groupId the group ID
4052             * @param vocabularyIds the vocabulary IDs
4053             * @param start the lower bound of the range of asset categories
4054             * @param end the upper bound of the range of asset categories (not inclusive)
4055             * @return the range of matching asset categories that the user has permission to view
4056             * @throws SystemException if a system exception occurred
4057             */
4058            public List<AssetCategory> filterFindByG_V(long groupId,
4059                    long[] vocabularyIds, int start, int end) throws SystemException {
4060                    return filterFindByG_V(groupId, vocabularyIds, start, end, null);
4061            }
4062    
4063            /**
4064             * Returns an ordered range of all the asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
4065             *
4066             * <p>
4067             * 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.
4068             * </p>
4069             *
4070             * @param groupId the group ID
4071             * @param vocabularyIds the vocabulary IDs
4072             * @param start the lower bound of the range of asset categories
4073             * @param end the upper bound of the range of asset categories (not inclusive)
4074             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4075             * @return the ordered range of matching asset categories that the user has permission to view
4076             * @throws SystemException if a system exception occurred
4077             */
4078            public List<AssetCategory> filterFindByG_V(long groupId,
4079                    long[] vocabularyIds, int start, int end,
4080                    OrderByComparator orderByComparator) throws SystemException {
4081                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4082                            return findByG_V(groupId, vocabularyIds, start, end,
4083                                    orderByComparator);
4084                    }
4085    
4086                    StringBundler query = new StringBundler();
4087    
4088                    if (getDB().isSupportsInlineDistinct()) {
4089                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
4090                    }
4091                    else {
4092                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
4093                    }
4094    
4095                    boolean conjunctionable = false;
4096    
4097                    if (conjunctionable) {
4098                            query.append(WHERE_AND);
4099                    }
4100    
4101                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
4102    
4103                    conjunctionable = true;
4104    
4105                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
4106                            if (conjunctionable) {
4107                                    query.append(WHERE_AND);
4108                            }
4109    
4110                            query.append(StringPool.OPEN_PARENTHESIS);
4111    
4112                            for (int i = 0; i < vocabularyIds.length; i++) {
4113                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
4114    
4115                                    if ((i + 1) < vocabularyIds.length) {
4116                                            query.append(WHERE_OR);
4117                                    }
4118                            }
4119    
4120                            query.append(StringPool.CLOSE_PARENTHESIS);
4121    
4122                            conjunctionable = true;
4123                    }
4124    
4125                    if (!getDB().isSupportsInlineDistinct()) {
4126                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
4127                    }
4128    
4129                    if (orderByComparator != null) {
4130                            if (getDB().isSupportsInlineDistinct()) {
4131                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4132                                            orderByComparator);
4133                            }
4134                            else {
4135                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
4136                                            orderByComparator);
4137                            }
4138                    }
4139    
4140                    else {
4141                            if (getDB().isSupportsInlineDistinct()) {
4142                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4143                            }
4144                            else {
4145                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
4146                            }
4147                    }
4148    
4149                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4150                                    AssetCategory.class.getName(),
4151                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4152    
4153                    Session session = null;
4154    
4155                    try {
4156                            session = openSession();
4157    
4158                            SQLQuery q = session.createSQLQuery(sql);
4159    
4160                            if (getDB().isSupportsInlineDistinct()) {
4161                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
4162                            }
4163                            else {
4164                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
4165                            }
4166    
4167                            QueryPos qPos = QueryPos.getInstance(q);
4168    
4169                            qPos.add(groupId);
4170    
4171                            if (vocabularyIds != null) {
4172                                    qPos.add(vocabularyIds);
4173                            }
4174    
4175                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
4176                                    end);
4177                    }
4178                    catch (Exception e) {
4179                            throw processException(e);
4180                    }
4181                    finally {
4182                            closeSession(session);
4183                    }
4184            }
4185    
4186            /**
4187             * Returns all the asset categories where parentCategoryId = &#63; and name = &#63;.
4188             *
4189             * @param parentCategoryId the parent category ID
4190             * @param name the name
4191             * @return the matching asset categories
4192             * @throws SystemException if a system exception occurred
4193             */
4194            public List<AssetCategory> findByP_N(long parentCategoryId, String name)
4195                    throws SystemException {
4196                    return findByP_N(parentCategoryId, name, QueryUtil.ALL_POS,
4197                            QueryUtil.ALL_POS, null);
4198            }
4199    
4200            /**
4201             * Returns a range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4202             *
4203             * <p>
4204             * 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.
4205             * </p>
4206             *
4207             * @param parentCategoryId the parent category ID
4208             * @param name the name
4209             * @param start the lower bound of the range of asset categories
4210             * @param end the upper bound of the range of asset categories (not inclusive)
4211             * @return the range of matching asset categories
4212             * @throws SystemException if a system exception occurred
4213             */
4214            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4215                    int start, int end) throws SystemException {
4216                    return findByP_N(parentCategoryId, name, start, end, null);
4217            }
4218    
4219            /**
4220             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and name = &#63;.
4221             *
4222             * <p>
4223             * 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.
4224             * </p>
4225             *
4226             * @param parentCategoryId the parent category ID
4227             * @param name the name
4228             * @param start the lower bound of the range of asset categories
4229             * @param end the upper bound of the range of asset categories (not inclusive)
4230             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4231             * @return the ordered range of matching asset categories
4232             * @throws SystemException if a system exception occurred
4233             */
4234            public List<AssetCategory> findByP_N(long parentCategoryId, String name,
4235                    int start, int end, OrderByComparator orderByComparator)
4236                    throws SystemException {
4237                    FinderPath finderPath = null;
4238                    Object[] finderArgs = null;
4239    
4240                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4241                                    (orderByComparator == null)) {
4242                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_N;
4243                            finderArgs = new Object[] { parentCategoryId, name };
4244                    }
4245                    else {
4246                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_N;
4247                            finderArgs = new Object[] {
4248                                            parentCategoryId, name,
4249                                            
4250                                            start, end, orderByComparator
4251                                    };
4252                    }
4253    
4254                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4255                                    finderArgs, this);
4256    
4257                    if ((list != null) && !list.isEmpty()) {
4258                            for (AssetCategory assetCategory : list) {
4259                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4260                                                    !Validator.equals(name, assetCategory.getName())) {
4261                                            list = null;
4262    
4263                                            break;
4264                                    }
4265                            }
4266                    }
4267    
4268                    if (list == null) {
4269                            StringBundler query = null;
4270    
4271                            if (orderByComparator != null) {
4272                                    query = new StringBundler(4 +
4273                                                    (orderByComparator.getOrderByFields().length * 3));
4274                            }
4275                            else {
4276                                    query = new StringBundler(4);
4277                            }
4278    
4279                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4280    
4281                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4282    
4283                            if (name == null) {
4284                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
4285                            }
4286                            else {
4287                                    if (name.equals(StringPool.BLANK)) {
4288                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
4289                                    }
4290                                    else {
4291                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
4292                                    }
4293                            }
4294    
4295                            if (orderByComparator != null) {
4296                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4297                                            orderByComparator);
4298                            }
4299    
4300                            else {
4301                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4302                            }
4303    
4304                            String sql = query.toString();
4305    
4306                            Session session = null;
4307    
4308                            try {
4309                                    session = openSession();
4310    
4311                                    Query q = session.createQuery(sql);
4312    
4313                                    QueryPos qPos = QueryPos.getInstance(q);
4314    
4315                                    qPos.add(parentCategoryId);
4316    
4317                                    if (name != null) {
4318                                            qPos.add(name);
4319                                    }
4320    
4321                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4322                                                    start, end);
4323                            }
4324                            catch (Exception e) {
4325                                    throw processException(e);
4326                            }
4327                            finally {
4328                                    if (list == null) {
4329                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4330                                    }
4331                                    else {
4332                                            cacheResult(list);
4333    
4334                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4335                                    }
4336    
4337                                    closeSession(session);
4338                            }
4339                    }
4340    
4341                    return list;
4342            }
4343    
4344            /**
4345             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4346             *
4347             * @param parentCategoryId the parent category ID
4348             * @param name the name
4349             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4350             * @return the first matching asset category
4351             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4352             * @throws SystemException if a system exception occurred
4353             */
4354            public AssetCategory findByP_N_First(long parentCategoryId, String name,
4355                    OrderByComparator orderByComparator)
4356                    throws NoSuchCategoryException, SystemException {
4357                    AssetCategory assetCategory = fetchByP_N_First(parentCategoryId, name,
4358                                    orderByComparator);
4359    
4360                    if (assetCategory != null) {
4361                            return assetCategory;
4362                    }
4363    
4364                    StringBundler msg = new StringBundler(6);
4365    
4366                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4367    
4368                    msg.append("parentCategoryId=");
4369                    msg.append(parentCategoryId);
4370    
4371                    msg.append(", name=");
4372                    msg.append(name);
4373    
4374                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4375    
4376                    throw new NoSuchCategoryException(msg.toString());
4377            }
4378    
4379            /**
4380             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4381             *
4382             * @param parentCategoryId the parent category ID
4383             * @param name the name
4384             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4385             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
4386             * @throws SystemException if a system exception occurred
4387             */
4388            public AssetCategory fetchByP_N_First(long parentCategoryId, String name,
4389                    OrderByComparator orderByComparator) throws SystemException {
4390                    List<AssetCategory> list = findByP_N(parentCategoryId, name, 0, 1,
4391                                    orderByComparator);
4392    
4393                    if (!list.isEmpty()) {
4394                            return list.get(0);
4395                    }
4396    
4397                    return null;
4398            }
4399    
4400            /**
4401             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4402             *
4403             * @param parentCategoryId the parent category ID
4404             * @param name the name
4405             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4406             * @return the last matching asset category
4407             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4408             * @throws SystemException if a system exception occurred
4409             */
4410            public AssetCategory findByP_N_Last(long parentCategoryId, String name,
4411                    OrderByComparator orderByComparator)
4412                    throws NoSuchCategoryException, SystemException {
4413                    AssetCategory assetCategory = fetchByP_N_Last(parentCategoryId, name,
4414                                    orderByComparator);
4415    
4416                    if (assetCategory != null) {
4417                            return assetCategory;
4418                    }
4419    
4420                    StringBundler msg = new StringBundler(6);
4421    
4422                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4423    
4424                    msg.append("parentCategoryId=");
4425                    msg.append(parentCategoryId);
4426    
4427                    msg.append(", name=");
4428                    msg.append(name);
4429    
4430                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4431    
4432                    throw new NoSuchCategoryException(msg.toString());
4433            }
4434    
4435            /**
4436             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4437             *
4438             * @param parentCategoryId the parent category ID
4439             * @param name the name
4440             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4441             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
4442             * @throws SystemException if a system exception occurred
4443             */
4444            public AssetCategory fetchByP_N_Last(long parentCategoryId, String name,
4445                    OrderByComparator orderByComparator) throws SystemException {
4446                    int count = countByP_N(parentCategoryId, name);
4447    
4448                    List<AssetCategory> list = findByP_N(parentCategoryId, name, count - 1,
4449                                    count, orderByComparator);
4450    
4451                    if (!list.isEmpty()) {
4452                            return list.get(0);
4453                    }
4454    
4455                    return null;
4456            }
4457    
4458            /**
4459             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and name = &#63;.
4460             *
4461             * @param categoryId the primary key of the current asset category
4462             * @param parentCategoryId the parent category ID
4463             * @param name the name
4464             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4465             * @return the previous, current, and next asset category
4466             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
4467             * @throws SystemException if a system exception occurred
4468             */
4469            public AssetCategory[] findByP_N_PrevAndNext(long categoryId,
4470                    long parentCategoryId, String name, OrderByComparator orderByComparator)
4471                    throws NoSuchCategoryException, SystemException {
4472                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
4473    
4474                    Session session = null;
4475    
4476                    try {
4477                            session = openSession();
4478    
4479                            AssetCategory[] array = new AssetCategoryImpl[3];
4480    
4481                            array[0] = getByP_N_PrevAndNext(session, assetCategory,
4482                                            parentCategoryId, name, orderByComparator, true);
4483    
4484                            array[1] = assetCategory;
4485    
4486                            array[2] = getByP_N_PrevAndNext(session, assetCategory,
4487                                            parentCategoryId, name, orderByComparator, false);
4488    
4489                            return array;
4490                    }
4491                    catch (Exception e) {
4492                            throw processException(e);
4493                    }
4494                    finally {
4495                            closeSession(session);
4496                    }
4497            }
4498    
4499            protected AssetCategory getByP_N_PrevAndNext(Session session,
4500                    AssetCategory assetCategory, long parentCategoryId, String name,
4501                    OrderByComparator orderByComparator, boolean previous) {
4502                    StringBundler query = null;
4503    
4504                    if (orderByComparator != null) {
4505                            query = new StringBundler(6 +
4506                                            (orderByComparator.getOrderByFields().length * 6));
4507                    }
4508                    else {
4509                            query = new StringBundler(3);
4510                    }
4511    
4512                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4513    
4514                    query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
4515    
4516                    if (name == null) {
4517                            query.append(_FINDER_COLUMN_P_N_NAME_1);
4518                    }
4519                    else {
4520                            if (name.equals(StringPool.BLANK)) {
4521                                    query.append(_FINDER_COLUMN_P_N_NAME_3);
4522                            }
4523                            else {
4524                                    query.append(_FINDER_COLUMN_P_N_NAME_2);
4525                            }
4526                    }
4527    
4528                    if (orderByComparator != null) {
4529                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4530    
4531                            if (orderByConditionFields.length > 0) {
4532                                    query.append(WHERE_AND);
4533                            }
4534    
4535                            for (int i = 0; i < orderByConditionFields.length; i++) {
4536                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4537                                    query.append(orderByConditionFields[i]);
4538    
4539                                    if ((i + 1) < orderByConditionFields.length) {
4540                                            if (orderByComparator.isAscending() ^ previous) {
4541                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4542                                            }
4543                                            else {
4544                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4545                                            }
4546                                    }
4547                                    else {
4548                                            if (orderByComparator.isAscending() ^ previous) {
4549                                                    query.append(WHERE_GREATER_THAN);
4550                                            }
4551                                            else {
4552                                                    query.append(WHERE_LESSER_THAN);
4553                                            }
4554                                    }
4555                            }
4556    
4557                            query.append(ORDER_BY_CLAUSE);
4558    
4559                            String[] orderByFields = orderByComparator.getOrderByFields();
4560    
4561                            for (int i = 0; i < orderByFields.length; i++) {
4562                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4563                                    query.append(orderByFields[i]);
4564    
4565                                    if ((i + 1) < orderByFields.length) {
4566                                            if (orderByComparator.isAscending() ^ previous) {
4567                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4568                                            }
4569                                            else {
4570                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4571                                            }
4572                                    }
4573                                    else {
4574                                            if (orderByComparator.isAscending() ^ previous) {
4575                                                    query.append(ORDER_BY_ASC);
4576                                            }
4577                                            else {
4578                                                    query.append(ORDER_BY_DESC);
4579                                            }
4580                                    }
4581                            }
4582                    }
4583    
4584                    else {
4585                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4586                    }
4587    
4588                    String sql = query.toString();
4589    
4590                    Query q = session.createQuery(sql);
4591    
4592                    q.setFirstResult(0);
4593                    q.setMaxResults(2);
4594    
4595                    QueryPos qPos = QueryPos.getInstance(q);
4596    
4597                    qPos.add(parentCategoryId);
4598    
4599                    if (name != null) {
4600                            qPos.add(name);
4601                    }
4602    
4603                    if (orderByComparator != null) {
4604                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
4605    
4606                            for (Object value : values) {
4607                                    qPos.add(value);
4608                            }
4609                    }
4610    
4611                    List<AssetCategory> list = q.list();
4612    
4613                    if (list.size() == 2) {
4614                            return list.get(1);
4615                    }
4616                    else {
4617                            return null;
4618                    }
4619            }
4620    
4621            /**
4622             * Returns all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
4623             *
4624             * @param parentCategoryId the parent category ID
4625             * @param vocabularyId the vocabulary ID
4626             * @return the matching asset categories
4627             * @throws SystemException if a system exception occurred
4628             */
4629            public List<AssetCategory> findByP_V(long parentCategoryId,
4630                    long vocabularyId) throws SystemException {
4631                    return findByP_V(parentCategoryId, vocabularyId, QueryUtil.ALL_POS,
4632                            QueryUtil.ALL_POS, null);
4633            }
4634    
4635            /**
4636             * Returns a range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
4637             *
4638             * <p>
4639             * 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.
4640             * </p>
4641             *
4642             * @param parentCategoryId the parent category ID
4643             * @param vocabularyId the vocabulary ID
4644             * @param start the lower bound of the range of asset categories
4645             * @param end the upper bound of the range of asset categories (not inclusive)
4646             * @return the range of matching asset categories
4647             * @throws SystemException if a system exception occurred
4648             */
4649            public List<AssetCategory> findByP_V(long parentCategoryId,
4650                    long vocabularyId, int start, int end) throws SystemException {
4651                    return findByP_V(parentCategoryId, vocabularyId, start, end, null);
4652            }
4653    
4654            /**
4655             * Returns an ordered range of all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
4656             *
4657             * <p>
4658             * 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.
4659             * </p>
4660             *
4661             * @param parentCategoryId the parent category ID
4662             * @param vocabularyId the vocabulary ID
4663             * @param start the lower bound of the range of asset categories
4664             * @param end the upper bound of the range of asset categories (not inclusive)
4665             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
4666             * @return the ordered range of matching asset categories
4667             * @throws SystemException if a system exception occurred
4668             */
4669            public List<AssetCategory> findByP_V(long parentCategoryId,
4670                    long vocabularyId, int start, int end,
4671                    OrderByComparator orderByComparator) throws SystemException {
4672                    FinderPath finderPath = null;
4673                    Object[] finderArgs = null;
4674    
4675                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
4676                                    (orderByComparator == null)) {
4677                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_P_V;
4678                            finderArgs = new Object[] { parentCategoryId, vocabularyId };
4679                    }
4680                    else {
4681                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_P_V;
4682                            finderArgs = new Object[] {
4683                                            parentCategoryId, vocabularyId,
4684                                            
4685                                            start, end, orderByComparator
4686                                    };
4687                    }
4688    
4689                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
4690                                    finderArgs, this);
4691    
4692                    if ((list != null) && !list.isEmpty()) {
4693                            for (AssetCategory assetCategory : list) {
4694                                    if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
4695                                                    (vocabularyId != assetCategory.getVocabularyId())) {
4696                                            list = null;
4697    
4698                                            break;
4699                                    }
4700                            }
4701                    }
4702    
4703                    if (list == null) {
4704                            StringBundler query = null;
4705    
4706                            if (orderByComparator != null) {
4707                                    query = new StringBundler(4 +
4708                                                    (orderByComparator.getOrderByFields().length * 3));
4709                            }
4710                            else {
4711                                    query = new StringBundler(4);
4712                            }
4713    
4714                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4715    
4716                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4717    
4718                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4719    
4720                            if (orderByComparator != null) {
4721                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
4722                                            orderByComparator);
4723                            }
4724    
4725                            else {
4726                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
4727                            }
4728    
4729                            String sql = query.toString();
4730    
4731                            Session session = null;
4732    
4733                            try {
4734                                    session = openSession();
4735    
4736                                    Query q = session.createQuery(sql);
4737    
4738                                    QueryPos qPos = QueryPos.getInstance(q);
4739    
4740                                    qPos.add(parentCategoryId);
4741    
4742                                    qPos.add(vocabularyId);
4743    
4744                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
4745                                                    start, end);
4746                            }
4747                            catch (Exception e) {
4748                                    throw processException(e);
4749                            }
4750                            finally {
4751                                    if (list == null) {
4752                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
4753                                    }
4754                                    else {
4755                                            cacheResult(list);
4756    
4757                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
4758                                    }
4759    
4760                                    closeSession(session);
4761                            }
4762                    }
4763    
4764                    return list;
4765            }
4766    
4767            /**
4768             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4769             *
4770             * @param parentCategoryId the parent category ID
4771             * @param vocabularyId the vocabulary ID
4772             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4773             * @return the first matching asset category
4774             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4775             * @throws SystemException if a system exception occurred
4776             */
4777            public AssetCategory findByP_V_First(long parentCategoryId,
4778                    long vocabularyId, OrderByComparator orderByComparator)
4779                    throws NoSuchCategoryException, SystemException {
4780                    AssetCategory assetCategory = fetchByP_V_First(parentCategoryId,
4781                                    vocabularyId, orderByComparator);
4782    
4783                    if (assetCategory != null) {
4784                            return assetCategory;
4785                    }
4786    
4787                    StringBundler msg = new StringBundler(6);
4788    
4789                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4790    
4791                    msg.append("parentCategoryId=");
4792                    msg.append(parentCategoryId);
4793    
4794                    msg.append(", vocabularyId=");
4795                    msg.append(vocabularyId);
4796    
4797                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4798    
4799                    throw new NoSuchCategoryException(msg.toString());
4800            }
4801    
4802            /**
4803             * Returns the first asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4804             *
4805             * @param parentCategoryId the parent category ID
4806             * @param vocabularyId the vocabulary ID
4807             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4808             * @return the first 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_V_First(long parentCategoryId,
4812                    long vocabularyId, OrderByComparator orderByComparator)
4813                    throws SystemException {
4814                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId, 0,
4815                                    1, orderByComparator);
4816    
4817                    if (!list.isEmpty()) {
4818                            return list.get(0);
4819                    }
4820    
4821                    return null;
4822            }
4823    
4824            /**
4825             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4826             *
4827             * @param parentCategoryId the parent category ID
4828             * @param vocabularyId the vocabulary ID
4829             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4830             * @return the last matching asset category
4831             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
4832             * @throws SystemException if a system exception occurred
4833             */
4834            public AssetCategory findByP_V_Last(long parentCategoryId,
4835                    long vocabularyId, OrderByComparator orderByComparator)
4836                    throws NoSuchCategoryException, SystemException {
4837                    AssetCategory assetCategory = fetchByP_V_Last(parentCategoryId,
4838                                    vocabularyId, orderByComparator);
4839    
4840                    if (assetCategory != null) {
4841                            return assetCategory;
4842                    }
4843    
4844                    StringBundler msg = new StringBundler(6);
4845    
4846                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
4847    
4848                    msg.append("parentCategoryId=");
4849                    msg.append(parentCategoryId);
4850    
4851                    msg.append(", vocabularyId=");
4852                    msg.append(vocabularyId);
4853    
4854                    msg.append(StringPool.CLOSE_CURLY_BRACE);
4855    
4856                    throw new NoSuchCategoryException(msg.toString());
4857            }
4858    
4859            /**
4860             * Returns the last asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4861             *
4862             * @param parentCategoryId the parent category ID
4863             * @param vocabularyId the vocabulary ID
4864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4865             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
4866             * @throws SystemException if a system exception occurred
4867             */
4868            public AssetCategory fetchByP_V_Last(long parentCategoryId,
4869                    long vocabularyId, OrderByComparator orderByComparator)
4870                    throws SystemException {
4871                    int count = countByP_V(parentCategoryId, vocabularyId);
4872    
4873                    List<AssetCategory> list = findByP_V(parentCategoryId, vocabularyId,
4874                                    count - 1, count, orderByComparator);
4875    
4876                    if (!list.isEmpty()) {
4877                            return list.get(0);
4878                    }
4879    
4880                    return null;
4881            }
4882    
4883            /**
4884             * Returns the asset categories before and after the current asset category in the ordered set where parentCategoryId = &#63; and vocabularyId = &#63;.
4885             *
4886             * @param categoryId the primary key of the current asset category
4887             * @param parentCategoryId the parent category ID
4888             * @param vocabularyId the vocabulary ID
4889             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
4890             * @return the previous, current, and next asset category
4891             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
4892             * @throws SystemException if a system exception occurred
4893             */
4894            public AssetCategory[] findByP_V_PrevAndNext(long categoryId,
4895                    long parentCategoryId, long vocabularyId,
4896                    OrderByComparator orderByComparator)
4897                    throws NoSuchCategoryException, SystemException {
4898                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
4899    
4900                    Session session = null;
4901    
4902                    try {
4903                            session = openSession();
4904    
4905                            AssetCategory[] array = new AssetCategoryImpl[3];
4906    
4907                            array[0] = getByP_V_PrevAndNext(session, assetCategory,
4908                                            parentCategoryId, vocabularyId, orderByComparator, true);
4909    
4910                            array[1] = assetCategory;
4911    
4912                            array[2] = getByP_V_PrevAndNext(session, assetCategory,
4913                                            parentCategoryId, vocabularyId, orderByComparator, false);
4914    
4915                            return array;
4916                    }
4917                    catch (Exception e) {
4918                            throw processException(e);
4919                    }
4920                    finally {
4921                            closeSession(session);
4922                    }
4923            }
4924    
4925            protected AssetCategory getByP_V_PrevAndNext(Session session,
4926                    AssetCategory assetCategory, long parentCategoryId, long vocabularyId,
4927                    OrderByComparator orderByComparator, boolean previous) {
4928                    StringBundler query = null;
4929    
4930                    if (orderByComparator != null) {
4931                            query = new StringBundler(6 +
4932                                            (orderByComparator.getOrderByFields().length * 6));
4933                    }
4934                    else {
4935                            query = new StringBundler(3);
4936                    }
4937    
4938                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
4939    
4940                    query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
4941    
4942                    query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
4943    
4944                    if (orderByComparator != null) {
4945                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
4946    
4947                            if (orderByConditionFields.length > 0) {
4948                                    query.append(WHERE_AND);
4949                            }
4950    
4951                            for (int i = 0; i < orderByConditionFields.length; i++) {
4952                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4953                                    query.append(orderByConditionFields[i]);
4954    
4955                                    if ((i + 1) < orderByConditionFields.length) {
4956                                            if (orderByComparator.isAscending() ^ previous) {
4957                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
4958                                            }
4959                                            else {
4960                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
4961                                            }
4962                                    }
4963                                    else {
4964                                            if (orderByComparator.isAscending() ^ previous) {
4965                                                    query.append(WHERE_GREATER_THAN);
4966                                            }
4967                                            else {
4968                                                    query.append(WHERE_LESSER_THAN);
4969                                            }
4970                                    }
4971                            }
4972    
4973                            query.append(ORDER_BY_CLAUSE);
4974    
4975                            String[] orderByFields = orderByComparator.getOrderByFields();
4976    
4977                            for (int i = 0; i < orderByFields.length; i++) {
4978                                    query.append(_ORDER_BY_ENTITY_ALIAS);
4979                                    query.append(orderByFields[i]);
4980    
4981                                    if ((i + 1) < orderByFields.length) {
4982                                            if (orderByComparator.isAscending() ^ previous) {
4983                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
4984                                            }
4985                                            else {
4986                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
4987                                            }
4988                                    }
4989                                    else {
4990                                            if (orderByComparator.isAscending() ^ previous) {
4991                                                    query.append(ORDER_BY_ASC);
4992                                            }
4993                                            else {
4994                                                    query.append(ORDER_BY_DESC);
4995                                            }
4996                                    }
4997                            }
4998                    }
4999    
5000                    else {
5001                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5002                    }
5003    
5004                    String sql = query.toString();
5005    
5006                    Query q = session.createQuery(sql);
5007    
5008                    q.setFirstResult(0);
5009                    q.setMaxResults(2);
5010    
5011                    QueryPos qPos = QueryPos.getInstance(q);
5012    
5013                    qPos.add(parentCategoryId);
5014    
5015                    qPos.add(vocabularyId);
5016    
5017                    if (orderByComparator != null) {
5018                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5019    
5020                            for (Object value : values) {
5021                                    qPos.add(value);
5022                            }
5023                    }
5024    
5025                    List<AssetCategory> list = q.list();
5026    
5027                    if (list.size() == 2) {
5028                            return list.get(1);
5029                    }
5030                    else {
5031                            return null;
5032                    }
5033            }
5034    
5035            /**
5036             * Returns all the asset categories where name = &#63; and vocabularyId = &#63;.
5037             *
5038             * @param name the name
5039             * @param vocabularyId the vocabulary ID
5040             * @return the matching asset categories
5041             * @throws SystemException if a system exception occurred
5042             */
5043            public List<AssetCategory> findByN_V(String name, long vocabularyId)
5044                    throws SystemException {
5045                    return findByN_V(name, vocabularyId, QueryUtil.ALL_POS,
5046                            QueryUtil.ALL_POS, null);
5047            }
5048    
5049            /**
5050             * Returns a range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5051             *
5052             * <p>
5053             * 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.
5054             * </p>
5055             *
5056             * @param name the name
5057             * @param vocabularyId the vocabulary ID
5058             * @param start the lower bound of the range of asset categories
5059             * @param end the upper bound of the range of asset categories (not inclusive)
5060             * @return the range of matching asset categories
5061             * @throws SystemException if a system exception occurred
5062             */
5063            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5064                    int start, int end) throws SystemException {
5065                    return findByN_V(name, vocabularyId, start, end, null);
5066            }
5067    
5068            /**
5069             * Returns an ordered range of all the asset categories where name = &#63; and vocabularyId = &#63;.
5070             *
5071             * <p>
5072             * 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.
5073             * </p>
5074             *
5075             * @param name the name
5076             * @param vocabularyId the vocabulary ID
5077             * @param start the lower bound of the range of asset categories
5078             * @param end the upper bound of the range of asset categories (not inclusive)
5079             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5080             * @return the ordered range of matching asset categories
5081             * @throws SystemException if a system exception occurred
5082             */
5083            public List<AssetCategory> findByN_V(String name, long vocabularyId,
5084                    int start, int end, OrderByComparator orderByComparator)
5085                    throws SystemException {
5086                    FinderPath finderPath = null;
5087                    Object[] finderArgs = null;
5088    
5089                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5090                                    (orderByComparator == null)) {
5091                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_N_V;
5092                            finderArgs = new Object[] { name, vocabularyId };
5093                    }
5094                    else {
5095                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_N_V;
5096                            finderArgs = new Object[] {
5097                                            name, vocabularyId,
5098                                            
5099                                            start, end, orderByComparator
5100                                    };
5101                    }
5102    
5103                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5104                                    finderArgs, this);
5105    
5106                    if ((list != null) && !list.isEmpty()) {
5107                            for (AssetCategory assetCategory : list) {
5108                                    if (!Validator.equals(name, assetCategory.getName()) ||
5109                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5110                                            list = null;
5111    
5112                                            break;
5113                                    }
5114                            }
5115                    }
5116    
5117                    if (list == null) {
5118                            StringBundler query = null;
5119    
5120                            if (orderByComparator != null) {
5121                                    query = new StringBundler(4 +
5122                                                    (orderByComparator.getOrderByFields().length * 3));
5123                            }
5124                            else {
5125                                    query = new StringBundler(4);
5126                            }
5127    
5128                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5129    
5130                            if (name == null) {
5131                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
5132                            }
5133                            else {
5134                                    if (name.equals(StringPool.BLANK)) {
5135                                            query.append(_FINDER_COLUMN_N_V_NAME_3);
5136                                    }
5137                                    else {
5138                                            query.append(_FINDER_COLUMN_N_V_NAME_2);
5139                                    }
5140                            }
5141    
5142                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5143    
5144                            if (orderByComparator != null) {
5145                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5146                                            orderByComparator);
5147                            }
5148    
5149                            else {
5150                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5151                            }
5152    
5153                            String sql = query.toString();
5154    
5155                            Session session = null;
5156    
5157                            try {
5158                                    session = openSession();
5159    
5160                                    Query q = session.createQuery(sql);
5161    
5162                                    QueryPos qPos = QueryPos.getInstance(q);
5163    
5164                                    if (name != null) {
5165                                            qPos.add(name);
5166                                    }
5167    
5168                                    qPos.add(vocabularyId);
5169    
5170                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5171                                                    start, end);
5172                            }
5173                            catch (Exception e) {
5174                                    throw processException(e);
5175                            }
5176                            finally {
5177                                    if (list == null) {
5178                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5179                                    }
5180                                    else {
5181                                            cacheResult(list);
5182    
5183                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5184                                    }
5185    
5186                                    closeSession(session);
5187                            }
5188                    }
5189    
5190                    return list;
5191            }
5192    
5193            /**
5194             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
5195             *
5196             * @param name the name
5197             * @param vocabularyId the vocabulary ID
5198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5199             * @return the first matching asset category
5200             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5201             * @throws SystemException if a system exception occurred
5202             */
5203            public AssetCategory findByN_V_First(String name, long vocabularyId,
5204                    OrderByComparator orderByComparator)
5205                    throws NoSuchCategoryException, SystemException {
5206                    AssetCategory assetCategory = fetchByN_V_First(name, vocabularyId,
5207                                    orderByComparator);
5208    
5209                    if (assetCategory != null) {
5210                            return assetCategory;
5211                    }
5212    
5213                    StringBundler msg = new StringBundler(6);
5214    
5215                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5216    
5217                    msg.append("name=");
5218                    msg.append(name);
5219    
5220                    msg.append(", vocabularyId=");
5221                    msg.append(vocabularyId);
5222    
5223                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5224    
5225                    throw new NoSuchCategoryException(msg.toString());
5226            }
5227    
5228            /**
5229             * Returns the first asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
5230             *
5231             * @param name the name
5232             * @param vocabularyId the vocabulary ID
5233             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5234             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5235             * @throws SystemException if a system exception occurred
5236             */
5237            public AssetCategory fetchByN_V_First(String name, long vocabularyId,
5238                    OrderByComparator orderByComparator) throws SystemException {
5239                    List<AssetCategory> list = findByN_V(name, vocabularyId, 0, 1,
5240                                    orderByComparator);
5241    
5242                    if (!list.isEmpty()) {
5243                            return list.get(0);
5244                    }
5245    
5246                    return null;
5247            }
5248    
5249            /**
5250             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
5251             *
5252             * @param name the name
5253             * @param vocabularyId the vocabulary ID
5254             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5255             * @return the last matching asset category
5256             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5257             * @throws SystemException if a system exception occurred
5258             */
5259            public AssetCategory findByN_V_Last(String name, long vocabularyId,
5260                    OrderByComparator orderByComparator)
5261                    throws NoSuchCategoryException, SystemException {
5262                    AssetCategory assetCategory = fetchByN_V_Last(name, vocabularyId,
5263                                    orderByComparator);
5264    
5265                    if (assetCategory != null) {
5266                            return assetCategory;
5267                    }
5268    
5269                    StringBundler msg = new StringBundler(6);
5270    
5271                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5272    
5273                    msg.append("name=");
5274                    msg.append(name);
5275    
5276                    msg.append(", vocabularyId=");
5277                    msg.append(vocabularyId);
5278    
5279                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5280    
5281                    throw new NoSuchCategoryException(msg.toString());
5282            }
5283    
5284            /**
5285             * Returns the last asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
5286             *
5287             * @param name the name
5288             * @param vocabularyId the vocabulary ID
5289             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5290             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5291             * @throws SystemException if a system exception occurred
5292             */
5293            public AssetCategory fetchByN_V_Last(String name, long vocabularyId,
5294                    OrderByComparator orderByComparator) throws SystemException {
5295                    int count = countByN_V(name, vocabularyId);
5296    
5297                    List<AssetCategory> list = findByN_V(name, vocabularyId, count - 1,
5298                                    count, orderByComparator);
5299    
5300                    if (!list.isEmpty()) {
5301                            return list.get(0);
5302                    }
5303    
5304                    return null;
5305            }
5306    
5307            /**
5308             * Returns the asset categories before and after the current asset category in the ordered set where name = &#63; and vocabularyId = &#63;.
5309             *
5310             * @param categoryId the primary key of the current asset category
5311             * @param name the name
5312             * @param vocabularyId the vocabulary ID
5313             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5314             * @return the previous, current, and next asset category
5315             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5316             * @throws SystemException if a system exception occurred
5317             */
5318            public AssetCategory[] findByN_V_PrevAndNext(long categoryId, String name,
5319                    long vocabularyId, OrderByComparator orderByComparator)
5320                    throws NoSuchCategoryException, SystemException {
5321                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5322    
5323                    Session session = null;
5324    
5325                    try {
5326                            session = openSession();
5327    
5328                            AssetCategory[] array = new AssetCategoryImpl[3];
5329    
5330                            array[0] = getByN_V_PrevAndNext(session, assetCategory, name,
5331                                            vocabularyId, orderByComparator, true);
5332    
5333                            array[1] = assetCategory;
5334    
5335                            array[2] = getByN_V_PrevAndNext(session, assetCategory, name,
5336                                            vocabularyId, orderByComparator, false);
5337    
5338                            return array;
5339                    }
5340                    catch (Exception e) {
5341                            throw processException(e);
5342                    }
5343                    finally {
5344                            closeSession(session);
5345                    }
5346            }
5347    
5348            protected AssetCategory getByN_V_PrevAndNext(Session session,
5349                    AssetCategory assetCategory, String name, long vocabularyId,
5350                    OrderByComparator orderByComparator, boolean previous) {
5351                    StringBundler query = null;
5352    
5353                    if (orderByComparator != null) {
5354                            query = new StringBundler(6 +
5355                                            (orderByComparator.getOrderByFields().length * 6));
5356                    }
5357                    else {
5358                            query = new StringBundler(3);
5359                    }
5360    
5361                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5362    
5363                    if (name == null) {
5364                            query.append(_FINDER_COLUMN_N_V_NAME_1);
5365                    }
5366                    else {
5367                            if (name.equals(StringPool.BLANK)) {
5368                                    query.append(_FINDER_COLUMN_N_V_NAME_3);
5369                            }
5370                            else {
5371                                    query.append(_FINDER_COLUMN_N_V_NAME_2);
5372                            }
5373                    }
5374    
5375                    query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
5376    
5377                    if (orderByComparator != null) {
5378                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5379    
5380                            if (orderByConditionFields.length > 0) {
5381                                    query.append(WHERE_AND);
5382                            }
5383    
5384                            for (int i = 0; i < orderByConditionFields.length; i++) {
5385                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5386                                    query.append(orderByConditionFields[i]);
5387    
5388                                    if ((i + 1) < orderByConditionFields.length) {
5389                                            if (orderByComparator.isAscending() ^ previous) {
5390                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5391                                            }
5392                                            else {
5393                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5394                                            }
5395                                    }
5396                                    else {
5397                                            if (orderByComparator.isAscending() ^ previous) {
5398                                                    query.append(WHERE_GREATER_THAN);
5399                                            }
5400                                            else {
5401                                                    query.append(WHERE_LESSER_THAN);
5402                                            }
5403                                    }
5404                            }
5405    
5406                            query.append(ORDER_BY_CLAUSE);
5407    
5408                            String[] orderByFields = orderByComparator.getOrderByFields();
5409    
5410                            for (int i = 0; i < orderByFields.length; i++) {
5411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5412                                    query.append(orderByFields[i]);
5413    
5414                                    if ((i + 1) < orderByFields.length) {
5415                                            if (orderByComparator.isAscending() ^ previous) {
5416                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5417                                            }
5418                                            else {
5419                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5420                                            }
5421                                    }
5422                                    else {
5423                                            if (orderByComparator.isAscending() ^ previous) {
5424                                                    query.append(ORDER_BY_ASC);
5425                                            }
5426                                            else {
5427                                                    query.append(ORDER_BY_DESC);
5428                                            }
5429                                    }
5430                            }
5431                    }
5432    
5433                    else {
5434                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5435                    }
5436    
5437                    String sql = query.toString();
5438    
5439                    Query q = session.createQuery(sql);
5440    
5441                    q.setFirstResult(0);
5442                    q.setMaxResults(2);
5443    
5444                    QueryPos qPos = QueryPos.getInstance(q);
5445    
5446                    if (name != null) {
5447                            qPos.add(name);
5448                    }
5449    
5450                    qPos.add(vocabularyId);
5451    
5452                    if (orderByComparator != null) {
5453                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5454    
5455                            for (Object value : values) {
5456                                    qPos.add(value);
5457                            }
5458                    }
5459    
5460                    List<AssetCategory> list = q.list();
5461    
5462                    if (list.size() == 2) {
5463                            return list.get(1);
5464                    }
5465                    else {
5466                            return null;
5467                    }
5468            }
5469    
5470            /**
5471             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5472             *
5473             * @param groupId the group ID
5474             * @param parentCategoryId the parent category ID
5475             * @param vocabularyId the vocabulary ID
5476             * @return the matching asset categories
5477             * @throws SystemException if a system exception occurred
5478             */
5479            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5480                    long vocabularyId) throws SystemException {
5481                    return findByG_P_V(groupId, parentCategoryId, vocabularyId,
5482                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5483            }
5484    
5485            /**
5486             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5487             *
5488             * <p>
5489             * 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.
5490             * </p>
5491             *
5492             * @param groupId the group ID
5493             * @param parentCategoryId the parent category ID
5494             * @param vocabularyId the vocabulary ID
5495             * @param start the lower bound of the range of asset categories
5496             * @param end the upper bound of the range of asset categories (not inclusive)
5497             * @return the range of matching asset categories
5498             * @throws SystemException if a system exception occurred
5499             */
5500            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5501                    long vocabularyId, int start, int end) throws SystemException {
5502                    return findByG_P_V(groupId, parentCategoryId, vocabularyId, start, end,
5503                            null);
5504            }
5505    
5506            /**
5507             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5508             *
5509             * <p>
5510             * 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.
5511             * </p>
5512             *
5513             * @param groupId the group ID
5514             * @param parentCategoryId the parent category ID
5515             * @param vocabularyId the vocabulary ID
5516             * @param start the lower bound of the range of asset categories
5517             * @param end the upper bound of the range of asset categories (not inclusive)
5518             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5519             * @return the ordered range of matching asset categories
5520             * @throws SystemException if a system exception occurred
5521             */
5522            public List<AssetCategory> findByG_P_V(long groupId, long parentCategoryId,
5523                    long vocabularyId, int start, int end,
5524                    OrderByComparator orderByComparator) throws SystemException {
5525                    FinderPath finderPath = null;
5526                    Object[] finderArgs = null;
5527    
5528                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
5529                                    (orderByComparator == null)) {
5530                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_V;
5531                            finderArgs = new Object[] { groupId, parentCategoryId, vocabularyId };
5532                    }
5533                    else {
5534                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_V;
5535                            finderArgs = new Object[] {
5536                                            groupId, parentCategoryId, vocabularyId,
5537                                            
5538                                            start, end, orderByComparator
5539                                    };
5540                    }
5541    
5542                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
5543                                    finderArgs, this);
5544    
5545                    if ((list != null) && !list.isEmpty()) {
5546                            for (AssetCategory assetCategory : list) {
5547                                    if ((groupId != assetCategory.getGroupId()) ||
5548                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
5549                                                    (vocabularyId != assetCategory.getVocabularyId())) {
5550                                            list = null;
5551    
5552                                            break;
5553                                    }
5554                            }
5555                    }
5556    
5557                    if (list == null) {
5558                            StringBundler query = null;
5559    
5560                            if (orderByComparator != null) {
5561                                    query = new StringBundler(5 +
5562                                                    (orderByComparator.getOrderByFields().length * 3));
5563                            }
5564                            else {
5565                                    query = new StringBundler(5);
5566                            }
5567    
5568                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5569    
5570                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5571    
5572                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5573    
5574                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5575    
5576                            if (orderByComparator != null) {
5577                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5578                                            orderByComparator);
5579                            }
5580    
5581                            else {
5582                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5583                            }
5584    
5585                            String sql = query.toString();
5586    
5587                            Session session = null;
5588    
5589                            try {
5590                                    session = openSession();
5591    
5592                                    Query q = session.createQuery(sql);
5593    
5594                                    QueryPos qPos = QueryPos.getInstance(q);
5595    
5596                                    qPos.add(groupId);
5597    
5598                                    qPos.add(parentCategoryId);
5599    
5600                                    qPos.add(vocabularyId);
5601    
5602                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
5603                                                    start, end);
5604                            }
5605                            catch (Exception e) {
5606                                    throw processException(e);
5607                            }
5608                            finally {
5609                                    if (list == null) {
5610                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
5611                                    }
5612                                    else {
5613                                            cacheResult(list);
5614    
5615                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
5616                                    }
5617    
5618                                    closeSession(session);
5619                            }
5620                    }
5621    
5622                    return list;
5623            }
5624    
5625            /**
5626             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5627             *
5628             * @param groupId the group ID
5629             * @param parentCategoryId the parent category ID
5630             * @param vocabularyId the vocabulary ID
5631             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5632             * @return the first matching asset category
5633             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5634             * @throws SystemException if a system exception occurred
5635             */
5636            public AssetCategory findByG_P_V_First(long groupId, long parentCategoryId,
5637                    long vocabularyId, OrderByComparator orderByComparator)
5638                    throws NoSuchCategoryException, SystemException {
5639                    AssetCategory assetCategory = fetchByG_P_V_First(groupId,
5640                                    parentCategoryId, vocabularyId, orderByComparator);
5641    
5642                    if (assetCategory != null) {
5643                            return assetCategory;
5644                    }
5645    
5646                    StringBundler msg = new StringBundler(8);
5647    
5648                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5649    
5650                    msg.append("groupId=");
5651                    msg.append(groupId);
5652    
5653                    msg.append(", parentCategoryId=");
5654                    msg.append(parentCategoryId);
5655    
5656                    msg.append(", vocabularyId=");
5657                    msg.append(vocabularyId);
5658    
5659                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5660    
5661                    throw new NoSuchCategoryException(msg.toString());
5662            }
5663    
5664            /**
5665             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5666             *
5667             * @param groupId the group ID
5668             * @param parentCategoryId the parent category ID
5669             * @param vocabularyId the vocabulary ID
5670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5671             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
5672             * @throws SystemException if a system exception occurred
5673             */
5674            public AssetCategory fetchByG_P_V_First(long groupId,
5675                    long parentCategoryId, long vocabularyId,
5676                    OrderByComparator orderByComparator) throws SystemException {
5677                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
5678                                    vocabularyId, 0, 1, orderByComparator);
5679    
5680                    if (!list.isEmpty()) {
5681                            return list.get(0);
5682                    }
5683    
5684                    return null;
5685            }
5686    
5687            /**
5688             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5689             *
5690             * @param groupId the group ID
5691             * @param parentCategoryId the parent category ID
5692             * @param vocabularyId the vocabulary ID
5693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5694             * @return the last matching asset category
5695             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
5696             * @throws SystemException if a system exception occurred
5697             */
5698            public AssetCategory findByG_P_V_Last(long groupId, long parentCategoryId,
5699                    long vocabularyId, OrderByComparator orderByComparator)
5700                    throws NoSuchCategoryException, SystemException {
5701                    AssetCategory assetCategory = fetchByG_P_V_Last(groupId,
5702                                    parentCategoryId, vocabularyId, orderByComparator);
5703    
5704                    if (assetCategory != null) {
5705                            return assetCategory;
5706                    }
5707    
5708                    StringBundler msg = new StringBundler(8);
5709    
5710                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
5711    
5712                    msg.append("groupId=");
5713                    msg.append(groupId);
5714    
5715                    msg.append(", parentCategoryId=");
5716                    msg.append(parentCategoryId);
5717    
5718                    msg.append(", vocabularyId=");
5719                    msg.append(vocabularyId);
5720    
5721                    msg.append(StringPool.CLOSE_CURLY_BRACE);
5722    
5723                    throw new NoSuchCategoryException(msg.toString());
5724            }
5725    
5726            /**
5727             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5728             *
5729             * @param groupId the group ID
5730             * @param parentCategoryId the parent category ID
5731             * @param vocabularyId the vocabulary ID
5732             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5733             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
5734             * @throws SystemException if a system exception occurred
5735             */
5736            public AssetCategory fetchByG_P_V_Last(long groupId, long parentCategoryId,
5737                    long vocabularyId, OrderByComparator orderByComparator)
5738                    throws SystemException {
5739                    int count = countByG_P_V(groupId, parentCategoryId, vocabularyId);
5740    
5741                    List<AssetCategory> list = findByG_P_V(groupId, parentCategoryId,
5742                                    vocabularyId, count - 1, count, orderByComparator);
5743    
5744                    if (!list.isEmpty()) {
5745                            return list.get(0);
5746                    }
5747    
5748                    return null;
5749            }
5750    
5751            /**
5752             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5753             *
5754             * @param categoryId the primary key of the current asset category
5755             * @param groupId the group ID
5756             * @param parentCategoryId the parent category ID
5757             * @param vocabularyId the vocabulary ID
5758             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
5759             * @return the previous, current, and next asset category
5760             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
5761             * @throws SystemException if a system exception occurred
5762             */
5763            public AssetCategory[] findByG_P_V_PrevAndNext(long categoryId,
5764                    long groupId, long parentCategoryId, long vocabularyId,
5765                    OrderByComparator orderByComparator)
5766                    throws NoSuchCategoryException, SystemException {
5767                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
5768    
5769                    Session session = null;
5770    
5771                    try {
5772                            session = openSession();
5773    
5774                            AssetCategory[] array = new AssetCategoryImpl[3];
5775    
5776                            array[0] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
5777                                            parentCategoryId, vocabularyId, orderByComparator, true);
5778    
5779                            array[1] = assetCategory;
5780    
5781                            array[2] = getByG_P_V_PrevAndNext(session, assetCategory, groupId,
5782                                            parentCategoryId, vocabularyId, orderByComparator, false);
5783    
5784                            return array;
5785                    }
5786                    catch (Exception e) {
5787                            throw processException(e);
5788                    }
5789                    finally {
5790                            closeSession(session);
5791                    }
5792            }
5793    
5794            protected AssetCategory getByG_P_V_PrevAndNext(Session session,
5795                    AssetCategory assetCategory, long groupId, long parentCategoryId,
5796                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
5797                    StringBundler query = null;
5798    
5799                    if (orderByComparator != null) {
5800                            query = new StringBundler(6 +
5801                                            (orderByComparator.getOrderByFields().length * 6));
5802                    }
5803                    else {
5804                            query = new StringBundler(3);
5805                    }
5806    
5807                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
5808    
5809                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5810    
5811                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5812    
5813                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5814    
5815                    if (orderByComparator != null) {
5816                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
5817    
5818                            if (orderByConditionFields.length > 0) {
5819                                    query.append(WHERE_AND);
5820                            }
5821    
5822                            for (int i = 0; i < orderByConditionFields.length; i++) {
5823                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5824                                    query.append(orderByConditionFields[i]);
5825    
5826                                    if ((i + 1) < orderByConditionFields.length) {
5827                                            if (orderByComparator.isAscending() ^ previous) {
5828                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
5829                                            }
5830                                            else {
5831                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
5832                                            }
5833                                    }
5834                                    else {
5835                                            if (orderByComparator.isAscending() ^ previous) {
5836                                                    query.append(WHERE_GREATER_THAN);
5837                                            }
5838                                            else {
5839                                                    query.append(WHERE_LESSER_THAN);
5840                                            }
5841                                    }
5842                            }
5843    
5844                            query.append(ORDER_BY_CLAUSE);
5845    
5846                            String[] orderByFields = orderByComparator.getOrderByFields();
5847    
5848                            for (int i = 0; i < orderByFields.length; i++) {
5849                                    query.append(_ORDER_BY_ENTITY_ALIAS);
5850                                    query.append(orderByFields[i]);
5851    
5852                                    if ((i + 1) < orderByFields.length) {
5853                                            if (orderByComparator.isAscending() ^ previous) {
5854                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
5855                                            }
5856                                            else {
5857                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
5858                                            }
5859                                    }
5860                                    else {
5861                                            if (orderByComparator.isAscending() ^ previous) {
5862                                                    query.append(ORDER_BY_ASC);
5863                                            }
5864                                            else {
5865                                                    query.append(ORDER_BY_DESC);
5866                                            }
5867                                    }
5868                            }
5869                    }
5870    
5871                    else {
5872                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
5873                    }
5874    
5875                    String sql = query.toString();
5876    
5877                    Query q = session.createQuery(sql);
5878    
5879                    q.setFirstResult(0);
5880                    q.setMaxResults(2);
5881    
5882                    QueryPos qPos = QueryPos.getInstance(q);
5883    
5884                    qPos.add(groupId);
5885    
5886                    qPos.add(parentCategoryId);
5887    
5888                    qPos.add(vocabularyId);
5889    
5890                    if (orderByComparator != null) {
5891                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
5892    
5893                            for (Object value : values) {
5894                                    qPos.add(value);
5895                            }
5896                    }
5897    
5898                    List<AssetCategory> list = q.list();
5899    
5900                    if (list.size() == 2) {
5901                            return list.get(1);
5902                    }
5903                    else {
5904                            return null;
5905                    }
5906            }
5907    
5908            /**
5909             * Returns all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5910             *
5911             * @param groupId the group ID
5912             * @param parentCategoryId the parent category ID
5913             * @param vocabularyId the vocabulary ID
5914             * @return the matching asset categories that the user has permission to view
5915             * @throws SystemException if a system exception occurred
5916             */
5917            public List<AssetCategory> filterFindByG_P_V(long groupId,
5918                    long parentCategoryId, long vocabularyId) throws SystemException {
5919                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
5920                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
5921            }
5922    
5923            /**
5924             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5925             *
5926             * <p>
5927             * 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.
5928             * </p>
5929             *
5930             * @param groupId the group ID
5931             * @param parentCategoryId the parent category ID
5932             * @param vocabularyId the vocabulary ID
5933             * @param start the lower bound of the range of asset categories
5934             * @param end the upper bound of the range of asset categories (not inclusive)
5935             * @return the range of matching asset categories that the user has permission to view
5936             * @throws SystemException if a system exception occurred
5937             */
5938            public List<AssetCategory> filterFindByG_P_V(long groupId,
5939                    long parentCategoryId, long vocabularyId, int start, int end)
5940                    throws SystemException {
5941                    return filterFindByG_P_V(groupId, parentCategoryId, vocabularyId,
5942                            start, end, null);
5943            }
5944    
5945            /**
5946             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
5947             *
5948             * <p>
5949             * 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.
5950             * </p>
5951             *
5952             * @param groupId the group ID
5953             * @param parentCategoryId the parent category ID
5954             * @param vocabularyId the vocabulary ID
5955             * @param start the lower bound of the range of asset categories
5956             * @param end the upper bound of the range of asset categories (not inclusive)
5957             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
5958             * @return the ordered range of matching asset categories that the user has permission to view
5959             * @throws SystemException if a system exception occurred
5960             */
5961            public List<AssetCategory> filterFindByG_P_V(long groupId,
5962                    long parentCategoryId, long vocabularyId, int start, int end,
5963                    OrderByComparator orderByComparator) throws SystemException {
5964                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
5965                            return findByG_P_V(groupId, parentCategoryId, vocabularyId, start,
5966                                    end, orderByComparator);
5967                    }
5968    
5969                    StringBundler query = null;
5970    
5971                    if (orderByComparator != null) {
5972                            query = new StringBundler(5 +
5973                                            (orderByComparator.getOrderByFields().length * 3));
5974                    }
5975                    else {
5976                            query = new StringBundler(5);
5977                    }
5978    
5979                    if (getDB().isSupportsInlineDistinct()) {
5980                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
5981                    }
5982                    else {
5983                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
5984                    }
5985    
5986                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
5987    
5988                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
5989    
5990                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
5991    
5992                    if (!getDB().isSupportsInlineDistinct()) {
5993                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
5994                    }
5995    
5996                    if (orderByComparator != null) {
5997                            if (getDB().isSupportsInlineDistinct()) {
5998                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
5999                                            orderByComparator);
6000                            }
6001                            else {
6002                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
6003                                            orderByComparator);
6004                            }
6005                    }
6006    
6007                    else {
6008                            if (getDB().isSupportsInlineDistinct()) {
6009                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6010                            }
6011                            else {
6012                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6013                            }
6014                    }
6015    
6016                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6017                                    AssetCategory.class.getName(),
6018                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6019    
6020                    Session session = null;
6021    
6022                    try {
6023                            session = openSession();
6024    
6025                            SQLQuery q = session.createSQLQuery(sql);
6026    
6027                            if (getDB().isSupportsInlineDistinct()) {
6028                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6029                            }
6030                            else {
6031                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6032                            }
6033    
6034                            QueryPos qPos = QueryPos.getInstance(q);
6035    
6036                            qPos.add(groupId);
6037    
6038                            qPos.add(parentCategoryId);
6039    
6040                            qPos.add(vocabularyId);
6041    
6042                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
6043                                    end);
6044                    }
6045                    catch (Exception e) {
6046                            throw processException(e);
6047                    }
6048                    finally {
6049                            closeSession(session);
6050                    }
6051            }
6052    
6053            /**
6054             * 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 parentCategoryId = &#63; and vocabularyId = &#63;.
6055             *
6056             * @param categoryId the primary key of the current asset category
6057             * @param groupId the group ID
6058             * @param parentCategoryId the parent category ID
6059             * @param vocabularyId the vocabulary ID
6060             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6061             * @return the previous, current, and next asset category
6062             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6063             * @throws SystemException if a system exception occurred
6064             */
6065            public AssetCategory[] filterFindByG_P_V_PrevAndNext(long categoryId,
6066                    long groupId, long parentCategoryId, long vocabularyId,
6067                    OrderByComparator orderByComparator)
6068                    throws NoSuchCategoryException, SystemException {
6069                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6070                            return findByG_P_V_PrevAndNext(categoryId, groupId,
6071                                    parentCategoryId, vocabularyId, orderByComparator);
6072                    }
6073    
6074                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6075    
6076                    Session session = null;
6077    
6078                    try {
6079                            session = openSession();
6080    
6081                            AssetCategory[] array = new AssetCategoryImpl[3];
6082    
6083                            array[0] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6084                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
6085                                            true);
6086    
6087                            array[1] = assetCategory;
6088    
6089                            array[2] = filterGetByG_P_V_PrevAndNext(session, assetCategory,
6090                                            groupId, parentCategoryId, vocabularyId, orderByComparator,
6091                                            false);
6092    
6093                            return array;
6094                    }
6095                    catch (Exception e) {
6096                            throw processException(e);
6097                    }
6098                    finally {
6099                            closeSession(session);
6100                    }
6101            }
6102    
6103            protected AssetCategory filterGetByG_P_V_PrevAndNext(Session session,
6104                    AssetCategory assetCategory, long groupId, long parentCategoryId,
6105                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6106                    StringBundler query = null;
6107    
6108                    if (orderByComparator != null) {
6109                            query = new StringBundler(6 +
6110                                            (orderByComparator.getOrderByFields().length * 6));
6111                    }
6112                    else {
6113                            query = new StringBundler(3);
6114                    }
6115    
6116                    if (getDB().isSupportsInlineDistinct()) {
6117                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6118                    }
6119                    else {
6120                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6121                    }
6122    
6123                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
6124    
6125                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
6126    
6127                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
6128    
6129                    if (!getDB().isSupportsInlineDistinct()) {
6130                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6131                    }
6132    
6133                    if (orderByComparator != null) {
6134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6135    
6136                            if (orderByConditionFields.length > 0) {
6137                                    query.append(WHERE_AND);
6138                            }
6139    
6140                            for (int i = 0; i < orderByConditionFields.length; i++) {
6141                                    if (getDB().isSupportsInlineDistinct()) {
6142                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6143                                    }
6144                                    else {
6145                                            query.append(_ORDER_BY_ENTITY_TABLE);
6146                                    }
6147    
6148                                    query.append(orderByConditionFields[i]);
6149    
6150                                    if ((i + 1) < orderByConditionFields.length) {
6151                                            if (orderByComparator.isAscending() ^ previous) {
6152                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6153                                            }
6154                                            else {
6155                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6156                                            }
6157                                    }
6158                                    else {
6159                                            if (orderByComparator.isAscending() ^ previous) {
6160                                                    query.append(WHERE_GREATER_THAN);
6161                                            }
6162                                            else {
6163                                                    query.append(WHERE_LESSER_THAN);
6164                                            }
6165                                    }
6166                            }
6167    
6168                            query.append(ORDER_BY_CLAUSE);
6169    
6170                            String[] orderByFields = orderByComparator.getOrderByFields();
6171    
6172                            for (int i = 0; i < orderByFields.length; i++) {
6173                                    if (getDB().isSupportsInlineDistinct()) {
6174                                            query.append(_ORDER_BY_ENTITY_ALIAS);
6175                                    }
6176                                    else {
6177                                            query.append(_ORDER_BY_ENTITY_TABLE);
6178                                    }
6179    
6180                                    query.append(orderByFields[i]);
6181    
6182                                    if ((i + 1) < orderByFields.length) {
6183                                            if (orderByComparator.isAscending() ^ previous) {
6184                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6185                                            }
6186                                            else {
6187                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6188                                            }
6189                                    }
6190                                    else {
6191                                            if (orderByComparator.isAscending() ^ previous) {
6192                                                    query.append(ORDER_BY_ASC);
6193                                            }
6194                                            else {
6195                                                    query.append(ORDER_BY_DESC);
6196                                            }
6197                                    }
6198                            }
6199                    }
6200    
6201                    else {
6202                            if (getDB().isSupportsInlineDistinct()) {
6203                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6204                            }
6205                            else {
6206                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
6207                            }
6208                    }
6209    
6210                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
6211                                    AssetCategory.class.getName(),
6212                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
6213    
6214                    SQLQuery q = session.createSQLQuery(sql);
6215    
6216                    q.setFirstResult(0);
6217                    q.setMaxResults(2);
6218    
6219                    if (getDB().isSupportsInlineDistinct()) {
6220                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
6221                    }
6222                    else {
6223                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
6224                    }
6225    
6226                    QueryPos qPos = QueryPos.getInstance(q);
6227    
6228                    qPos.add(groupId);
6229    
6230                    qPos.add(parentCategoryId);
6231    
6232                    qPos.add(vocabularyId);
6233    
6234                    if (orderByComparator != null) {
6235                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6236    
6237                            for (Object value : values) {
6238                                    qPos.add(value);
6239                            }
6240                    }
6241    
6242                    List<AssetCategory> list = q.list();
6243    
6244                    if (list.size() == 2) {
6245                            return list.get(1);
6246                    }
6247                    else {
6248                            return null;
6249                    }
6250            }
6251    
6252            /**
6253             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6254             *
6255             * @param groupId the group ID
6256             * @param name the name
6257             * @param vocabularyId the vocabulary ID
6258             * @return the matching asset categories
6259             * @throws SystemException if a system exception occurred
6260             */
6261            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6262                    long vocabularyId) throws SystemException {
6263                    return findByG_LikeN_V(groupId, name, vocabularyId, QueryUtil.ALL_POS,
6264                            QueryUtil.ALL_POS, null);
6265            }
6266    
6267            /**
6268             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6269             *
6270             * <p>
6271             * 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.
6272             * </p>
6273             *
6274             * @param groupId the group ID
6275             * @param name the name
6276             * @param vocabularyId the vocabulary ID
6277             * @param start the lower bound of the range of asset categories
6278             * @param end the upper bound of the range of asset categories (not inclusive)
6279             * @return the range of matching asset categories
6280             * @throws SystemException if a system exception occurred
6281             */
6282            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6283                    long vocabularyId, int start, int end) throws SystemException {
6284                    return findByG_LikeN_V(groupId, name, vocabularyId, start, end, null);
6285            }
6286    
6287            /**
6288             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6289             *
6290             * <p>
6291             * 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.
6292             * </p>
6293             *
6294             * @param groupId the group ID
6295             * @param name the name
6296             * @param vocabularyId the vocabulary ID
6297             * @param start the lower bound of the range of asset categories
6298             * @param end the upper bound of the range of asset categories (not inclusive)
6299             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6300             * @return the ordered range of matching asset categories
6301             * @throws SystemException if a system exception occurred
6302             */
6303            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6304                    long vocabularyId, int start, int end,
6305                    OrderByComparator orderByComparator) throws SystemException {
6306                    FinderPath finderPath = null;
6307                    Object[] finderArgs = null;
6308    
6309                    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
6310                    finderArgs = new Object[] {
6311                                    groupId, name, vocabularyId,
6312                                    
6313                                    start, end, orderByComparator
6314                            };
6315    
6316                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6317                                    finderArgs, this);
6318    
6319                    if ((list != null) && !list.isEmpty()) {
6320                            for (AssetCategory assetCategory : list) {
6321                                    if ((groupId != assetCategory.getGroupId()) ||
6322                                                    !Validator.equals(name, assetCategory.getName()) ||
6323                                                    (vocabularyId != assetCategory.getVocabularyId())) {
6324                                            list = null;
6325    
6326                                            break;
6327                                    }
6328                            }
6329                    }
6330    
6331                    if (list == null) {
6332                            StringBundler query = null;
6333    
6334                            if (orderByComparator != null) {
6335                                    query = new StringBundler(5 +
6336                                                    (orderByComparator.getOrderByFields().length * 3));
6337                            }
6338                            else {
6339                                    query = new StringBundler(5);
6340                            }
6341    
6342                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6343    
6344                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6345    
6346                            if (name == null) {
6347                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6348                            }
6349                            else {
6350                                    if (name.equals(StringPool.BLANK)) {
6351                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6352                                    }
6353                                    else {
6354                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6355                                    }
6356                            }
6357    
6358                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6359    
6360                            if (orderByComparator != null) {
6361                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6362                                            orderByComparator);
6363                            }
6364    
6365                            else {
6366                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6367                            }
6368    
6369                            String sql = query.toString();
6370    
6371                            Session session = null;
6372    
6373                            try {
6374                                    session = openSession();
6375    
6376                                    Query q = session.createQuery(sql);
6377    
6378                                    QueryPos qPos = QueryPos.getInstance(q);
6379    
6380                                    qPos.add(groupId);
6381    
6382                                    if (name != null) {
6383                                            qPos.add(name);
6384                                    }
6385    
6386                                    qPos.add(vocabularyId);
6387    
6388                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6389                                                    start, end);
6390                            }
6391                            catch (Exception e) {
6392                                    throw processException(e);
6393                            }
6394                            finally {
6395                                    if (list == null) {
6396                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6397                                    }
6398                                    else {
6399                                            cacheResult(list);
6400    
6401                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6402                                    }
6403    
6404                                    closeSession(session);
6405                            }
6406                    }
6407    
6408                    return list;
6409            }
6410    
6411            /**
6412             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6413             *
6414             * @param groupId the group ID
6415             * @param name the name
6416             * @param vocabularyId the vocabulary ID
6417             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6418             * @return the first matching asset category
6419             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6420             * @throws SystemException if a system exception occurred
6421             */
6422            public AssetCategory findByG_LikeN_V_First(long groupId, String name,
6423                    long vocabularyId, OrderByComparator orderByComparator)
6424                    throws NoSuchCategoryException, SystemException {
6425                    AssetCategory assetCategory = fetchByG_LikeN_V_First(groupId, name,
6426                                    vocabularyId, orderByComparator);
6427    
6428                    if (assetCategory != null) {
6429                            return assetCategory;
6430                    }
6431    
6432                    StringBundler msg = new StringBundler(8);
6433    
6434                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6435    
6436                    msg.append("groupId=");
6437                    msg.append(groupId);
6438    
6439                    msg.append(", name=");
6440                    msg.append(name);
6441    
6442                    msg.append(", vocabularyId=");
6443                    msg.append(vocabularyId);
6444    
6445                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6446    
6447                    throw new NoSuchCategoryException(msg.toString());
6448            }
6449    
6450            /**
6451             * Returns the first asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6452             *
6453             * @param groupId the group ID
6454             * @param name the name
6455             * @param vocabularyId the vocabulary ID
6456             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6457             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
6458             * @throws SystemException if a system exception occurred
6459             */
6460            public AssetCategory fetchByG_LikeN_V_First(long groupId, String name,
6461                    long vocabularyId, OrderByComparator orderByComparator)
6462                    throws SystemException {
6463                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
6464                                    0, 1, orderByComparator);
6465    
6466                    if (!list.isEmpty()) {
6467                            return list.get(0);
6468                    }
6469    
6470                    return null;
6471            }
6472    
6473            /**
6474             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6475             *
6476             * @param groupId the group ID
6477             * @param name the name
6478             * @param vocabularyId the vocabulary ID
6479             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6480             * @return the last matching asset category
6481             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
6482             * @throws SystemException if a system exception occurred
6483             */
6484            public AssetCategory findByG_LikeN_V_Last(long groupId, String name,
6485                    long vocabularyId, OrderByComparator orderByComparator)
6486                    throws NoSuchCategoryException, SystemException {
6487                    AssetCategory assetCategory = fetchByG_LikeN_V_Last(groupId, name,
6488                                    vocabularyId, orderByComparator);
6489    
6490                    if (assetCategory != null) {
6491                            return assetCategory;
6492                    }
6493    
6494                    StringBundler msg = new StringBundler(8);
6495    
6496                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
6497    
6498                    msg.append("groupId=");
6499                    msg.append(groupId);
6500    
6501                    msg.append(", name=");
6502                    msg.append(name);
6503    
6504                    msg.append(", vocabularyId=");
6505                    msg.append(vocabularyId);
6506    
6507                    msg.append(StringPool.CLOSE_CURLY_BRACE);
6508    
6509                    throw new NoSuchCategoryException(msg.toString());
6510            }
6511    
6512            /**
6513             * Returns the last asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6514             *
6515             * @param groupId the group ID
6516             * @param name the name
6517             * @param vocabularyId the vocabulary ID
6518             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6519             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
6520             * @throws SystemException if a system exception occurred
6521             */
6522            public AssetCategory fetchByG_LikeN_V_Last(long groupId, String name,
6523                    long vocabularyId, OrderByComparator orderByComparator)
6524                    throws SystemException {
6525                    int count = countByG_LikeN_V(groupId, name, vocabularyId);
6526    
6527                    List<AssetCategory> list = findByG_LikeN_V(groupId, name, vocabularyId,
6528                                    count - 1, count, orderByComparator);
6529    
6530                    if (!list.isEmpty()) {
6531                            return list.get(0);
6532                    }
6533    
6534                    return null;
6535            }
6536    
6537            /**
6538             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6539             *
6540             * @param categoryId the primary key of the current asset category
6541             * @param groupId the group ID
6542             * @param name the name
6543             * @param vocabularyId the vocabulary ID
6544             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
6545             * @return the previous, current, and next asset category
6546             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
6547             * @throws SystemException if a system exception occurred
6548             */
6549            public AssetCategory[] findByG_LikeN_V_PrevAndNext(long categoryId,
6550                    long groupId, String name, long vocabularyId,
6551                    OrderByComparator orderByComparator)
6552                    throws NoSuchCategoryException, SystemException {
6553                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
6554    
6555                    Session session = null;
6556    
6557                    try {
6558                            session = openSession();
6559    
6560                            AssetCategory[] array = new AssetCategoryImpl[3];
6561    
6562                            array[0] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
6563                                            groupId, name, vocabularyId, orderByComparator, true);
6564    
6565                            array[1] = assetCategory;
6566    
6567                            array[2] = getByG_LikeN_V_PrevAndNext(session, assetCategory,
6568                                            groupId, name, vocabularyId, orderByComparator, false);
6569    
6570                            return array;
6571                    }
6572                    catch (Exception e) {
6573                            throw processException(e);
6574                    }
6575                    finally {
6576                            closeSession(session);
6577                    }
6578            }
6579    
6580            protected AssetCategory getByG_LikeN_V_PrevAndNext(Session session,
6581                    AssetCategory assetCategory, long groupId, String name,
6582                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
6583                    StringBundler query = null;
6584    
6585                    if (orderByComparator != null) {
6586                            query = new StringBundler(6 +
6587                                            (orderByComparator.getOrderByFields().length * 6));
6588                    }
6589                    else {
6590                            query = new StringBundler(3);
6591                    }
6592    
6593                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6594    
6595                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6596    
6597                    if (name == null) {
6598                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6599                    }
6600                    else {
6601                            if (name.equals(StringPool.BLANK)) {
6602                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6603                            }
6604                            else {
6605                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6606                            }
6607                    }
6608    
6609                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6610    
6611                    if (orderByComparator != null) {
6612                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
6613    
6614                            if (orderByConditionFields.length > 0) {
6615                                    query.append(WHERE_AND);
6616                            }
6617    
6618                            for (int i = 0; i < orderByConditionFields.length; i++) {
6619                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6620                                    query.append(orderByConditionFields[i]);
6621    
6622                                    if ((i + 1) < orderByConditionFields.length) {
6623                                            if (orderByComparator.isAscending() ^ previous) {
6624                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
6625                                            }
6626                                            else {
6627                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
6628                                            }
6629                                    }
6630                                    else {
6631                                            if (orderByComparator.isAscending() ^ previous) {
6632                                                    query.append(WHERE_GREATER_THAN);
6633                                            }
6634                                            else {
6635                                                    query.append(WHERE_LESSER_THAN);
6636                                            }
6637                                    }
6638                            }
6639    
6640                            query.append(ORDER_BY_CLAUSE);
6641    
6642                            String[] orderByFields = orderByComparator.getOrderByFields();
6643    
6644                            for (int i = 0; i < orderByFields.length; i++) {
6645                                    query.append(_ORDER_BY_ENTITY_ALIAS);
6646                                    query.append(orderByFields[i]);
6647    
6648                                    if ((i + 1) < orderByFields.length) {
6649                                            if (orderByComparator.isAscending() ^ previous) {
6650                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
6651                                            }
6652                                            else {
6653                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
6654                                            }
6655                                    }
6656                                    else {
6657                                            if (orderByComparator.isAscending() ^ previous) {
6658                                                    query.append(ORDER_BY_ASC);
6659                                            }
6660                                            else {
6661                                                    query.append(ORDER_BY_DESC);
6662                                            }
6663                                    }
6664                            }
6665                    }
6666    
6667                    else {
6668                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6669                    }
6670    
6671                    String sql = query.toString();
6672    
6673                    Query q = session.createQuery(sql);
6674    
6675                    q.setFirstResult(0);
6676                    q.setMaxResults(2);
6677    
6678                    QueryPos qPos = QueryPos.getInstance(q);
6679    
6680                    qPos.add(groupId);
6681    
6682                    if (name != null) {
6683                            qPos.add(name);
6684                    }
6685    
6686                    qPos.add(vocabularyId);
6687    
6688                    if (orderByComparator != null) {
6689                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
6690    
6691                            for (Object value : values) {
6692                                    qPos.add(value);
6693                            }
6694                    }
6695    
6696                    List<AssetCategory> list = q.list();
6697    
6698                    if (list.size() == 2) {
6699                            return list.get(1);
6700                    }
6701                    else {
6702                            return null;
6703                    }
6704            }
6705    
6706            /**
6707             * Returns all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
6708             *
6709             * <p>
6710             * 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.
6711             * </p>
6712             *
6713             * @param groupId the group ID
6714             * @param name the name
6715             * @param vocabularyIds the vocabulary IDs
6716             * @return the matching asset categories
6717             * @throws SystemException if a system exception occurred
6718             */
6719            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6720                    long[] vocabularyIds) throws SystemException {
6721                    return findByG_LikeN_V(groupId, name, vocabularyIds, QueryUtil.ALL_POS,
6722                            QueryUtil.ALL_POS, null);
6723            }
6724    
6725            /**
6726             * Returns a range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
6727             *
6728             * <p>
6729             * 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.
6730             * </p>
6731             *
6732             * @param groupId the group ID
6733             * @param name the name
6734             * @param vocabularyIds the vocabulary IDs
6735             * @param start the lower bound of the range of asset categories
6736             * @param end the upper bound of the range of asset categories (not inclusive)
6737             * @return the range of matching asset categories
6738             * @throws SystemException if a system exception occurred
6739             */
6740            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6741                    long[] vocabularyIds, int start, int end) throws SystemException {
6742                    return findByG_LikeN_V(groupId, name, vocabularyIds, start, end, null);
6743            }
6744    
6745            /**
6746             * Returns an ordered range of all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
6747             *
6748             * <p>
6749             * 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.
6750             * </p>
6751             *
6752             * @param groupId the group ID
6753             * @param name the name
6754             * @param vocabularyIds the vocabulary IDs
6755             * @param start the lower bound of the range of asset categories
6756             * @param end the upper bound of the range of asset categories (not inclusive)
6757             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6758             * @return the ordered range of matching asset categories
6759             * @throws SystemException if a system exception occurred
6760             */
6761            public List<AssetCategory> findByG_LikeN_V(long groupId, String name,
6762                    long[] vocabularyIds, int start, int end,
6763                    OrderByComparator orderByComparator) throws SystemException {
6764                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_V;
6765                    Object[] finderArgs = null;
6766    
6767                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
6768                                    (orderByComparator == null)) {
6769                            finderArgs = new Object[] {
6770                                            groupId, name, StringUtil.merge(vocabularyIds)
6771                                    };
6772                    }
6773                    else {
6774                            finderArgs = new Object[] {
6775                                            groupId, name, StringUtil.merge(vocabularyIds),
6776                                            
6777                                            start, end, orderByComparator
6778                                    };
6779                    }
6780    
6781                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
6782                                    finderArgs, this);
6783    
6784                    if ((list != null) && !list.isEmpty()) {
6785                            for (AssetCategory assetCategory : list) {
6786                                    if ((groupId != assetCategory.getGroupId()) ||
6787                                                    !Validator.equals(name, assetCategory.getName()) ||
6788                                                    !ArrayUtil.contains(vocabularyIds,
6789                                                            assetCategory.getVocabularyId())) {
6790                                            list = null;
6791    
6792                                            break;
6793                                    }
6794                            }
6795                    }
6796    
6797                    if (list == null) {
6798                            StringBundler query = new StringBundler();
6799    
6800                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
6801    
6802                            boolean conjunctionable = false;
6803    
6804                            if (conjunctionable) {
6805                                    query.append(WHERE_AND);
6806                            }
6807    
6808                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
6809    
6810                            conjunctionable = true;
6811    
6812                            if (conjunctionable) {
6813                                    query.append(WHERE_AND);
6814                            }
6815    
6816                            if (name == null) {
6817                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
6818                            }
6819                            else {
6820                                    if (name.equals(StringPool.BLANK)) {
6821                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
6822                                    }
6823                                    else {
6824                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
6825                                    }
6826                            }
6827    
6828                            conjunctionable = true;
6829    
6830                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
6831                                    if (conjunctionable) {
6832                                            query.append(WHERE_AND);
6833                                    }
6834    
6835                                    query.append(StringPool.OPEN_PARENTHESIS);
6836    
6837                                    for (int i = 0; i < vocabularyIds.length; i++) {
6838                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
6839    
6840                                            if ((i + 1) < vocabularyIds.length) {
6841                                                    query.append(WHERE_OR);
6842                                            }
6843                                    }
6844    
6845                                    query.append(StringPool.CLOSE_PARENTHESIS);
6846    
6847                                    conjunctionable = true;
6848                            }
6849    
6850                            if (orderByComparator != null) {
6851                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
6852                                            orderByComparator);
6853                            }
6854    
6855                            else {
6856                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
6857                            }
6858    
6859                            String sql = query.toString();
6860    
6861                            Session session = null;
6862    
6863                            try {
6864                                    session = openSession();
6865    
6866                                    Query q = session.createQuery(sql);
6867    
6868                                    QueryPos qPos = QueryPos.getInstance(q);
6869    
6870                                    qPos.add(groupId);
6871    
6872                                    if (name != null) {
6873                                            qPos.add(name);
6874                                    }
6875    
6876                                    if (vocabularyIds != null) {
6877                                            qPos.add(vocabularyIds);
6878                                    }
6879    
6880                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
6881                                                    start, end);
6882                            }
6883                            catch (Exception e) {
6884                                    throw processException(e);
6885                            }
6886                            finally {
6887                                    if (list == null) {
6888                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
6889                                    }
6890                                    else {
6891                                            cacheResult(list);
6892    
6893                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
6894                                    }
6895    
6896                                    closeSession(session);
6897                            }
6898                    }
6899    
6900                    return list;
6901            }
6902    
6903            /**
6904             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6905             *
6906             * @param groupId the group ID
6907             * @param name the name
6908             * @param vocabularyId the vocabulary ID
6909             * @return the matching asset categories that the user has permission to view
6910             * @throws SystemException if a system exception occurred
6911             */
6912            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6913                    long vocabularyId) throws SystemException {
6914                    return filterFindByG_LikeN_V(groupId, name, vocabularyId,
6915                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
6916            }
6917    
6918            /**
6919             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6920             *
6921             * <p>
6922             * 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.
6923             * </p>
6924             *
6925             * @param groupId the group ID
6926             * @param name the name
6927             * @param vocabularyId the vocabulary ID
6928             * @param start the lower bound of the range of asset categories
6929             * @param end the upper bound of the range of asset categories (not inclusive)
6930             * @return the range of matching asset categories that the user has permission to view
6931             * @throws SystemException if a system exception occurred
6932             */
6933            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6934                    long vocabularyId, int start, int end) throws SystemException {
6935                    return filterFindByG_LikeN_V(groupId, name, vocabularyId, start, end,
6936                            null);
6937            }
6938    
6939            /**
6940             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
6941             *
6942             * <p>
6943             * 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.
6944             * </p>
6945             *
6946             * @param groupId the group ID
6947             * @param name the name
6948             * @param vocabularyId the vocabulary ID
6949             * @param start the lower bound of the range of asset categories
6950             * @param end the upper bound of the range of asset categories (not inclusive)
6951             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
6952             * @return the ordered range of matching asset categories that the user has permission to view
6953             * @throws SystemException if a system exception occurred
6954             */
6955            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
6956                    long vocabularyId, int start, int end,
6957                    OrderByComparator orderByComparator) throws SystemException {
6958                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
6959                            return findByG_LikeN_V(groupId, name, vocabularyId, start, end,
6960                                    orderByComparator);
6961                    }
6962    
6963                    StringBundler query = null;
6964    
6965                    if (orderByComparator != null) {
6966                            query = new StringBundler(5 +
6967                                            (orderByComparator.getOrderByFields().length * 3));
6968                    }
6969                    else {
6970                            query = new StringBundler(5);
6971                    }
6972    
6973                    if (getDB().isSupportsInlineDistinct()) {
6974                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
6975                    }
6976                    else {
6977                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
6978                    }
6979    
6980                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
6981    
6982                    if (name == null) {
6983                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
6984                    }
6985                    else {
6986                            if (name.equals(StringPool.BLANK)) {
6987                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
6988                            }
6989                            else {
6990                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
6991                            }
6992                    }
6993    
6994                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
6995    
6996                    if (!getDB().isSupportsInlineDistinct()) {
6997                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
6998                    }
6999    
7000                    if (orderByComparator != null) {
7001                            if (getDB().isSupportsInlineDistinct()) {
7002                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7003                                            orderByComparator);
7004                            }
7005                            else {
7006                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7007                                            orderByComparator);
7008                            }
7009                    }
7010    
7011                    else {
7012                            if (getDB().isSupportsInlineDistinct()) {
7013                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7014                            }
7015                            else {
7016                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7017                            }
7018                    }
7019    
7020                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7021                                    AssetCategory.class.getName(),
7022                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7023    
7024                    Session session = null;
7025    
7026                    try {
7027                            session = openSession();
7028    
7029                            SQLQuery q = session.createSQLQuery(sql);
7030    
7031                            if (getDB().isSupportsInlineDistinct()) {
7032                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7033                            }
7034                            else {
7035                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7036                            }
7037    
7038                            QueryPos qPos = QueryPos.getInstance(q);
7039    
7040                            qPos.add(groupId);
7041    
7042                            if (name != null) {
7043                                    qPos.add(name);
7044                            }
7045    
7046                            qPos.add(vocabularyId);
7047    
7048                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7049                                    end);
7050                    }
7051                    catch (Exception e) {
7052                            throw processException(e);
7053                    }
7054                    finally {
7055                            closeSession(session);
7056                    }
7057            }
7058    
7059            /**
7060             * 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 name LIKE &#63; and vocabularyId = &#63;.
7061             *
7062             * @param categoryId the primary key of the current asset category
7063             * @param groupId the group ID
7064             * @param name the name
7065             * @param vocabularyId the vocabulary ID
7066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7067             * @return the previous, current, and next asset category
7068             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7069             * @throws SystemException if a system exception occurred
7070             */
7071            public AssetCategory[] filterFindByG_LikeN_V_PrevAndNext(long categoryId,
7072                    long groupId, String name, long vocabularyId,
7073                    OrderByComparator orderByComparator)
7074                    throws NoSuchCategoryException, SystemException {
7075                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7076                            return findByG_LikeN_V_PrevAndNext(categoryId, groupId, name,
7077                                    vocabularyId, orderByComparator);
7078                    }
7079    
7080                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7081    
7082                    Session session = null;
7083    
7084                    try {
7085                            session = openSession();
7086    
7087                            AssetCategory[] array = new AssetCategoryImpl[3];
7088    
7089                            array[0] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7090                                            groupId, name, vocabularyId, orderByComparator, true);
7091    
7092                            array[1] = assetCategory;
7093    
7094                            array[2] = filterGetByG_LikeN_V_PrevAndNext(session, assetCategory,
7095                                            groupId, name, vocabularyId, orderByComparator, false);
7096    
7097                            return array;
7098                    }
7099                    catch (Exception e) {
7100                            throw processException(e);
7101                    }
7102                    finally {
7103                            closeSession(session);
7104                    }
7105            }
7106    
7107            protected AssetCategory filterGetByG_LikeN_V_PrevAndNext(Session session,
7108                    AssetCategory assetCategory, long groupId, String name,
7109                    long vocabularyId, OrderByComparator orderByComparator, boolean previous) {
7110                    StringBundler query = null;
7111    
7112                    if (orderByComparator != null) {
7113                            query = new StringBundler(6 +
7114                                            (orderByComparator.getOrderByFields().length * 6));
7115                    }
7116                    else {
7117                            query = new StringBundler(3);
7118                    }
7119    
7120                    if (getDB().isSupportsInlineDistinct()) {
7121                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7122                    }
7123                    else {
7124                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7125                    }
7126    
7127                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
7128    
7129                    if (name == null) {
7130                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
7131                    }
7132                    else {
7133                            if (name.equals(StringPool.BLANK)) {
7134                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
7135                            }
7136                            else {
7137                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
7138                            }
7139                    }
7140    
7141                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
7142    
7143                    if (!getDB().isSupportsInlineDistinct()) {
7144                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7145                    }
7146    
7147                    if (orderByComparator != null) {
7148                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
7149    
7150                            if (orderByConditionFields.length > 0) {
7151                                    query.append(WHERE_AND);
7152                            }
7153    
7154                            for (int i = 0; i < orderByConditionFields.length; i++) {
7155                                    if (getDB().isSupportsInlineDistinct()) {
7156                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7157                                    }
7158                                    else {
7159                                            query.append(_ORDER_BY_ENTITY_TABLE);
7160                                    }
7161    
7162                                    query.append(orderByConditionFields[i]);
7163    
7164                                    if ((i + 1) < orderByConditionFields.length) {
7165                                            if (orderByComparator.isAscending() ^ previous) {
7166                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
7167                                            }
7168                                            else {
7169                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
7170                                            }
7171                                    }
7172                                    else {
7173                                            if (orderByComparator.isAscending() ^ previous) {
7174                                                    query.append(WHERE_GREATER_THAN);
7175                                            }
7176                                            else {
7177                                                    query.append(WHERE_LESSER_THAN);
7178                                            }
7179                                    }
7180                            }
7181    
7182                            query.append(ORDER_BY_CLAUSE);
7183    
7184                            String[] orderByFields = orderByComparator.getOrderByFields();
7185    
7186                            for (int i = 0; i < orderByFields.length; i++) {
7187                                    if (getDB().isSupportsInlineDistinct()) {
7188                                            query.append(_ORDER_BY_ENTITY_ALIAS);
7189                                    }
7190                                    else {
7191                                            query.append(_ORDER_BY_ENTITY_TABLE);
7192                                    }
7193    
7194                                    query.append(orderByFields[i]);
7195    
7196                                    if ((i + 1) < orderByFields.length) {
7197                                            if (orderByComparator.isAscending() ^ previous) {
7198                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
7199                                            }
7200                                            else {
7201                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
7202                                            }
7203                                    }
7204                                    else {
7205                                            if (orderByComparator.isAscending() ^ previous) {
7206                                                    query.append(ORDER_BY_ASC);
7207                                            }
7208                                            else {
7209                                                    query.append(ORDER_BY_DESC);
7210                                            }
7211                                    }
7212                            }
7213                    }
7214    
7215                    else {
7216                            if (getDB().isSupportsInlineDistinct()) {
7217                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7218                            }
7219                            else {
7220                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7221                            }
7222                    }
7223    
7224                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7225                                    AssetCategory.class.getName(),
7226                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7227    
7228                    SQLQuery q = session.createSQLQuery(sql);
7229    
7230                    q.setFirstResult(0);
7231                    q.setMaxResults(2);
7232    
7233                    if (getDB().isSupportsInlineDistinct()) {
7234                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7235                    }
7236                    else {
7237                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7238                    }
7239    
7240                    QueryPos qPos = QueryPos.getInstance(q);
7241    
7242                    qPos.add(groupId);
7243    
7244                    if (name != null) {
7245                            qPos.add(name);
7246                    }
7247    
7248                    qPos.add(vocabularyId);
7249    
7250                    if (orderByComparator != null) {
7251                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
7252    
7253                            for (Object value : values) {
7254                                    qPos.add(value);
7255                            }
7256                    }
7257    
7258                    List<AssetCategory> list = q.list();
7259    
7260                    if (list.size() == 2) {
7261                            return list.get(1);
7262                    }
7263                    else {
7264                            return null;
7265                    }
7266            }
7267    
7268            /**
7269             * Returns all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
7270             *
7271             * @param groupId the group ID
7272             * @param name the name
7273             * @param vocabularyIds the vocabulary IDs
7274             * @return the matching asset categories that the user has permission to view
7275             * @throws SystemException if a system exception occurred
7276             */
7277            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7278                    long[] vocabularyIds) throws SystemException {
7279                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds,
7280                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7281            }
7282    
7283            /**
7284             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
7285             *
7286             * <p>
7287             * 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.
7288             * </p>
7289             *
7290             * @param groupId the group ID
7291             * @param name the name
7292             * @param vocabularyIds the vocabulary IDs
7293             * @param start the lower bound of the range of asset categories
7294             * @param end the upper bound of the range of asset categories (not inclusive)
7295             * @return the range of matching asset categories that the user has permission to view
7296             * @throws SystemException if a system exception occurred
7297             */
7298            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7299                    long[] vocabularyIds, int start, int end) throws SystemException {
7300                    return filterFindByG_LikeN_V(groupId, name, vocabularyIds, start, end,
7301                            null);
7302            }
7303    
7304            /**
7305             * Returns an ordered range of all the asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
7306             *
7307             * <p>
7308             * 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.
7309             * </p>
7310             *
7311             * @param groupId the group ID
7312             * @param name the name
7313             * @param vocabularyIds the vocabulary IDs
7314             * @param start the lower bound of the range of asset categories
7315             * @param end the upper bound of the range of asset categories (not inclusive)
7316             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7317             * @return the ordered range of matching asset categories that the user has permission to view
7318             * @throws SystemException if a system exception occurred
7319             */
7320            public List<AssetCategory> filterFindByG_LikeN_V(long groupId, String name,
7321                    long[] vocabularyIds, int start, int end,
7322                    OrderByComparator orderByComparator) throws SystemException {
7323                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
7324                            return findByG_LikeN_V(groupId, name, vocabularyIds, start, end,
7325                                    orderByComparator);
7326                    }
7327    
7328                    StringBundler query = new StringBundler();
7329    
7330                    if (getDB().isSupportsInlineDistinct()) {
7331                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
7332                    }
7333                    else {
7334                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
7335                    }
7336    
7337                    boolean conjunctionable = false;
7338    
7339                    if (conjunctionable) {
7340                            query.append(WHERE_AND);
7341                    }
7342    
7343                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
7344    
7345                    conjunctionable = true;
7346    
7347                    if (conjunctionable) {
7348                            query.append(WHERE_AND);
7349                    }
7350    
7351                    if (name == null) {
7352                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
7353                    }
7354                    else {
7355                            if (name.equals(StringPool.BLANK)) {
7356                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
7357                            }
7358                            else {
7359                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
7360                            }
7361                    }
7362    
7363                    conjunctionable = true;
7364    
7365                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
7366                            if (conjunctionable) {
7367                                    query.append(WHERE_AND);
7368                            }
7369    
7370                            query.append(StringPool.OPEN_PARENTHESIS);
7371    
7372                            for (int i = 0; i < vocabularyIds.length; i++) {
7373                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
7374    
7375                                    if ((i + 1) < vocabularyIds.length) {
7376                                            query.append(WHERE_OR);
7377                                    }
7378                            }
7379    
7380                            query.append(StringPool.CLOSE_PARENTHESIS);
7381    
7382                            conjunctionable = true;
7383                    }
7384    
7385                    if (!getDB().isSupportsInlineDistinct()) {
7386                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
7387                    }
7388    
7389                    if (orderByComparator != null) {
7390                            if (getDB().isSupportsInlineDistinct()) {
7391                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7392                                            orderByComparator);
7393                            }
7394                            else {
7395                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
7396                                            orderByComparator);
7397                            }
7398                    }
7399    
7400                    else {
7401                            if (getDB().isSupportsInlineDistinct()) {
7402                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7403                            }
7404                            else {
7405                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
7406                            }
7407                    }
7408    
7409                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
7410                                    AssetCategory.class.getName(),
7411                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
7412    
7413                    Session session = null;
7414    
7415                    try {
7416                            session = openSession();
7417    
7418                            SQLQuery q = session.createSQLQuery(sql);
7419    
7420                            if (getDB().isSupportsInlineDistinct()) {
7421                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
7422                            }
7423                            else {
7424                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
7425                            }
7426    
7427                            QueryPos qPos = QueryPos.getInstance(q);
7428    
7429                            qPos.add(groupId);
7430    
7431                            if (name != null) {
7432                                    qPos.add(name);
7433                            }
7434    
7435                            if (vocabularyIds != null) {
7436                                    qPos.add(vocabularyIds);
7437                            }
7438    
7439                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
7440                                    end);
7441                    }
7442                    catch (Exception e) {
7443                            throw processException(e);
7444                    }
7445                    finally {
7446                            closeSession(session);
7447                    }
7448            }
7449    
7450            /**
7451             * 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.
7452             *
7453             * @param parentCategoryId the parent category ID
7454             * @param name the name
7455             * @param vocabularyId the vocabulary ID
7456             * @return the matching asset category
7457             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7458             * @throws SystemException if a system exception occurred
7459             */
7460            public AssetCategory findByP_N_V(long parentCategoryId, String name,
7461                    long vocabularyId) throws NoSuchCategoryException, SystemException {
7462                    AssetCategory assetCategory = fetchByP_N_V(parentCategoryId, name,
7463                                    vocabularyId);
7464    
7465                    if (assetCategory == null) {
7466                            StringBundler msg = new StringBundler(8);
7467    
7468                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7469    
7470                            msg.append("parentCategoryId=");
7471                            msg.append(parentCategoryId);
7472    
7473                            msg.append(", name=");
7474                            msg.append(name);
7475    
7476                            msg.append(", vocabularyId=");
7477                            msg.append(vocabularyId);
7478    
7479                            msg.append(StringPool.CLOSE_CURLY_BRACE);
7480    
7481                            if (_log.isWarnEnabled()) {
7482                                    _log.warn(msg.toString());
7483                            }
7484    
7485                            throw new NoSuchCategoryException(msg.toString());
7486                    }
7487    
7488                    return assetCategory;
7489            }
7490    
7491            /**
7492             * 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.
7493             *
7494             * @param parentCategoryId the parent category ID
7495             * @param name the name
7496             * @param vocabularyId the vocabulary ID
7497             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
7498             * @throws SystemException if a system exception occurred
7499             */
7500            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
7501                    long vocabularyId) throws SystemException {
7502                    return fetchByP_N_V(parentCategoryId, name, vocabularyId, true);
7503            }
7504    
7505            /**
7506             * 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.
7507             *
7508             * @param parentCategoryId the parent category ID
7509             * @param name the name
7510             * @param vocabularyId the vocabulary ID
7511             * @param retrieveFromCache whether to use the finder cache
7512             * @return the matching asset category, or <code>null</code> if a matching asset category could not be found
7513             * @throws SystemException if a system exception occurred
7514             */
7515            public AssetCategory fetchByP_N_V(long parentCategoryId, String name,
7516                    long vocabularyId, boolean retrieveFromCache) throws SystemException {
7517                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
7518    
7519                    Object result = null;
7520    
7521                    if (retrieveFromCache) {
7522                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_P_N_V,
7523                                            finderArgs, this);
7524                    }
7525    
7526                    if (result instanceof AssetCategory) {
7527                            AssetCategory assetCategory = (AssetCategory)result;
7528    
7529                            if ((parentCategoryId != assetCategory.getParentCategoryId()) ||
7530                                            !Validator.equals(name, assetCategory.getName()) ||
7531                                            (vocabularyId != assetCategory.getVocabularyId())) {
7532                                    result = null;
7533                            }
7534                    }
7535    
7536                    if (result == null) {
7537                            StringBundler query = new StringBundler(5);
7538    
7539                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7540    
7541                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
7542    
7543                            if (name == null) {
7544                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
7545                            }
7546                            else {
7547                                    if (name.equals(StringPool.BLANK)) {
7548                                            query.append(_FINDER_COLUMN_P_N_V_NAME_3);
7549                                    }
7550                                    else {
7551                                            query.append(_FINDER_COLUMN_P_N_V_NAME_2);
7552                                    }
7553                            }
7554    
7555                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
7556    
7557                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7558    
7559                            String sql = query.toString();
7560    
7561                            Session session = null;
7562    
7563                            try {
7564                                    session = openSession();
7565    
7566                                    Query q = session.createQuery(sql);
7567    
7568                                    QueryPos qPos = QueryPos.getInstance(q);
7569    
7570                                    qPos.add(parentCategoryId);
7571    
7572                                    if (name != null) {
7573                                            qPos.add(name);
7574                                    }
7575    
7576                                    qPos.add(vocabularyId);
7577    
7578                                    List<AssetCategory> list = q.list();
7579    
7580                                    result = list;
7581    
7582                                    AssetCategory assetCategory = null;
7583    
7584                                    if (list.isEmpty()) {
7585                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
7586                                                    finderArgs, list);
7587                                    }
7588                                    else {
7589                                            assetCategory = list.get(0);
7590    
7591                                            cacheResult(assetCategory);
7592    
7593                                            if ((assetCategory.getParentCategoryId() != parentCategoryId) ||
7594                                                            (assetCategory.getName() == null) ||
7595                                                            !assetCategory.getName().equals(name) ||
7596                                                            (assetCategory.getVocabularyId() != vocabularyId)) {
7597                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_P_N_V,
7598                                                            finderArgs, assetCategory);
7599                                            }
7600                                    }
7601    
7602                                    return assetCategory;
7603                            }
7604                            catch (Exception e) {
7605                                    throw processException(e);
7606                            }
7607                            finally {
7608                                    if (result == null) {
7609                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_P_N_V,
7610                                                    finderArgs);
7611                                    }
7612    
7613                                    closeSession(session);
7614                            }
7615                    }
7616                    else {
7617                            if (result instanceof List<?>) {
7618                                    return null;
7619                            }
7620                            else {
7621                                    return (AssetCategory)result;
7622                            }
7623                    }
7624            }
7625    
7626            /**
7627             * Returns all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7628             *
7629             * @param groupId the group ID
7630             * @param parentCategoryId the parent category ID
7631             * @param name the name
7632             * @param vocabularyId the vocabulary ID
7633             * @return the matching asset categories
7634             * @throws SystemException if a system exception occurred
7635             */
7636            public List<AssetCategory> findByG_P_N_V(long groupId,
7637                    long parentCategoryId, String name, long vocabularyId)
7638                    throws SystemException {
7639                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
7640                            QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
7641            }
7642    
7643            /**
7644             * Returns a range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7645             *
7646             * <p>
7647             * 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.
7648             * </p>
7649             *
7650             * @param groupId the group ID
7651             * @param parentCategoryId the parent category ID
7652             * @param name the name
7653             * @param vocabularyId the vocabulary ID
7654             * @param start the lower bound of the range of asset categories
7655             * @param end the upper bound of the range of asset categories (not inclusive)
7656             * @return the range of matching asset categories
7657             * @throws SystemException if a system exception occurred
7658             */
7659            public List<AssetCategory> findByG_P_N_V(long groupId,
7660                    long parentCategoryId, String name, long vocabularyId, int start,
7661                    int end) throws SystemException {
7662                    return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
7663                            start, end, null);
7664            }
7665    
7666            /**
7667             * Returns an ordered range of all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7668             *
7669             * <p>
7670             * 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.
7671             * </p>
7672             *
7673             * @param groupId the group ID
7674             * @param parentCategoryId the parent category ID
7675             * @param name the name
7676             * @param vocabularyId the vocabulary ID
7677             * @param start the lower bound of the range of asset categories
7678             * @param end the upper bound of the range of asset categories (not inclusive)
7679             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
7680             * @return the ordered range of matching asset categories
7681             * @throws SystemException if a system exception occurred
7682             */
7683            public List<AssetCategory> findByG_P_N_V(long groupId,
7684                    long parentCategoryId, String name, long vocabularyId, int start,
7685                    int end, OrderByComparator orderByComparator) throws SystemException {
7686                    FinderPath finderPath = null;
7687                    Object[] finderArgs = null;
7688    
7689                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
7690                                    (orderByComparator == null)) {
7691                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_P_N_V;
7692                            finderArgs = new Object[] {
7693                                            groupId, parentCategoryId, name, vocabularyId
7694                                    };
7695                    }
7696                    else {
7697                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_P_N_V;
7698                            finderArgs = new Object[] {
7699                                            groupId, parentCategoryId, name, vocabularyId,
7700                                            
7701                                            start, end, orderByComparator
7702                                    };
7703                    }
7704    
7705                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
7706                                    finderArgs, this);
7707    
7708                    if ((list != null) && !list.isEmpty()) {
7709                            for (AssetCategory assetCategory : list) {
7710                                    if ((groupId != assetCategory.getGroupId()) ||
7711                                                    (parentCategoryId != assetCategory.getParentCategoryId()) ||
7712                                                    !Validator.equals(name, assetCategory.getName()) ||
7713                                                    (vocabularyId != assetCategory.getVocabularyId())) {
7714                                            list = null;
7715    
7716                                            break;
7717                                    }
7718                            }
7719                    }
7720    
7721                    if (list == null) {
7722                            StringBundler query = null;
7723    
7724                            if (orderByComparator != null) {
7725                                    query = new StringBundler(6 +
7726                                                    (orderByComparator.getOrderByFields().length * 3));
7727                            }
7728                            else {
7729                                    query = new StringBundler(6);
7730                            }
7731    
7732                            query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
7733    
7734                            query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
7735    
7736                            query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
7737    
7738                            if (name == null) {
7739                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
7740                            }
7741                            else {
7742                                    if (name.equals(StringPool.BLANK)) {
7743                                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
7744                                    }
7745                                    else {
7746                                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
7747                                    }
7748                            }
7749    
7750                            query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
7751    
7752                            if (orderByComparator != null) {
7753                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
7754                                            orderByComparator);
7755                            }
7756    
7757                            else {
7758                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
7759                            }
7760    
7761                            String sql = query.toString();
7762    
7763                            Session session = null;
7764    
7765                            try {
7766                                    session = openSession();
7767    
7768                                    Query q = session.createQuery(sql);
7769    
7770                                    QueryPos qPos = QueryPos.getInstance(q);
7771    
7772                                    qPos.add(groupId);
7773    
7774                                    qPos.add(parentCategoryId);
7775    
7776                                    if (name != null) {
7777                                            qPos.add(name);
7778                                    }
7779    
7780                                    qPos.add(vocabularyId);
7781    
7782                                    list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
7783                                                    start, end);
7784                            }
7785                            catch (Exception e) {
7786                                    throw processException(e);
7787                            }
7788                            finally {
7789                                    if (list == null) {
7790                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
7791                                    }
7792                                    else {
7793                                            cacheResult(list);
7794    
7795                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
7796                                    }
7797    
7798                                    closeSession(session);
7799                            }
7800                    }
7801    
7802                    return list;
7803            }
7804    
7805            /**
7806             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7807             *
7808             * @param groupId the group ID
7809             * @param parentCategoryId the parent category ID
7810             * @param name the name
7811             * @param vocabularyId the vocabulary ID
7812             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7813             * @return the first matching asset category
7814             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7815             * @throws SystemException if a system exception occurred
7816             */
7817            public AssetCategory findByG_P_N_V_First(long groupId,
7818                    long parentCategoryId, String name, long vocabularyId,
7819                    OrderByComparator orderByComparator)
7820                    throws NoSuchCategoryException, SystemException {
7821                    AssetCategory assetCategory = fetchByG_P_N_V_First(groupId,
7822                                    parentCategoryId, name, vocabularyId, orderByComparator);
7823    
7824                    if (assetCategory != null) {
7825                            return assetCategory;
7826                    }
7827    
7828                    StringBundler msg = new StringBundler(10);
7829    
7830                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7831    
7832                    msg.append("groupId=");
7833                    msg.append(groupId);
7834    
7835                    msg.append(", parentCategoryId=");
7836                    msg.append(parentCategoryId);
7837    
7838                    msg.append(", name=");
7839                    msg.append(name);
7840    
7841                    msg.append(", vocabularyId=");
7842                    msg.append(vocabularyId);
7843    
7844                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7845    
7846                    throw new NoSuchCategoryException(msg.toString());
7847            }
7848    
7849            /**
7850             * Returns the first asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7851             *
7852             * @param groupId the group ID
7853             * @param parentCategoryId the parent category ID
7854             * @param name the name
7855             * @param vocabularyId the vocabulary ID
7856             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7857             * @return the first matching asset category, or <code>null</code> if a matching asset category could not be found
7858             * @throws SystemException if a system exception occurred
7859             */
7860            public AssetCategory fetchByG_P_N_V_First(long groupId,
7861                    long parentCategoryId, String name, long vocabularyId,
7862                    OrderByComparator orderByComparator) throws SystemException {
7863                    List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
7864                                    name, vocabularyId, 0, 1, orderByComparator);
7865    
7866                    if (!list.isEmpty()) {
7867                            return list.get(0);
7868                    }
7869    
7870                    return null;
7871            }
7872    
7873            /**
7874             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7875             *
7876             * @param groupId the group ID
7877             * @param parentCategoryId the parent category ID
7878             * @param name the name
7879             * @param vocabularyId the vocabulary ID
7880             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7881             * @return the last matching asset category
7882             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a matching asset category could not be found
7883             * @throws SystemException if a system exception occurred
7884             */
7885            public AssetCategory findByG_P_N_V_Last(long groupId,
7886                    long parentCategoryId, String name, long vocabularyId,
7887                    OrderByComparator orderByComparator)
7888                    throws NoSuchCategoryException, SystemException {
7889                    AssetCategory assetCategory = fetchByG_P_N_V_Last(groupId,
7890                                    parentCategoryId, name, vocabularyId, orderByComparator);
7891    
7892                    if (assetCategory != null) {
7893                            return assetCategory;
7894                    }
7895    
7896                    StringBundler msg = new StringBundler(10);
7897    
7898                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
7899    
7900                    msg.append("groupId=");
7901                    msg.append(groupId);
7902    
7903                    msg.append(", parentCategoryId=");
7904                    msg.append(parentCategoryId);
7905    
7906                    msg.append(", name=");
7907                    msg.append(name);
7908    
7909                    msg.append(", vocabularyId=");
7910                    msg.append(vocabularyId);
7911    
7912                    msg.append(StringPool.CLOSE_CURLY_BRACE);
7913    
7914                    throw new NoSuchCategoryException(msg.toString());
7915            }
7916    
7917            /**
7918             * Returns the last asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7919             *
7920             * @param groupId the group ID
7921             * @param parentCategoryId the parent category ID
7922             * @param name the name
7923             * @param vocabularyId the vocabulary ID
7924             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7925             * @return the last matching asset category, or <code>null</code> if a matching asset category could not be found
7926             * @throws SystemException if a system exception occurred
7927             */
7928            public AssetCategory fetchByG_P_N_V_Last(long groupId,
7929                    long parentCategoryId, String name, long vocabularyId,
7930                    OrderByComparator orderByComparator) throws SystemException {
7931                    int count = countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
7932    
7933                    List<AssetCategory> list = findByG_P_N_V(groupId, parentCategoryId,
7934                                    name, vocabularyId, count - 1, count, orderByComparator);
7935    
7936                    if (!list.isEmpty()) {
7937                            return list.get(0);
7938                    }
7939    
7940                    return null;
7941            }
7942    
7943            /**
7944             * Returns the asset categories before and after the current asset category in the ordered set where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
7945             *
7946             * @param categoryId the primary key of the current asset category
7947             * @param groupId the group ID
7948             * @param parentCategoryId the parent category ID
7949             * @param name the name
7950             * @param vocabularyId the vocabulary ID
7951             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
7952             * @return the previous, current, and next asset category
7953             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
7954             * @throws SystemException if a system exception occurred
7955             */
7956            public AssetCategory[] findByG_P_N_V_PrevAndNext(long categoryId,
7957                    long groupId, long parentCategoryId, String name, long vocabularyId,
7958                    OrderByComparator orderByComparator)
7959                    throws NoSuchCategoryException, SystemException {
7960                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
7961    
7962                    Session session = null;
7963    
7964                    try {
7965                            session = openSession();
7966    
7967                            AssetCategory[] array = new AssetCategoryImpl[3];
7968    
7969                            array[0] = getByG_P_N_V_PrevAndNext(session, assetCategory,
7970                                            groupId, parentCategoryId, name, vocabularyId,
7971                                            orderByComparator, true);
7972    
7973                            array[1] = assetCategory;
7974    
7975                            array[2] = getByG_P_N_V_PrevAndNext(session, assetCategory,
7976                                            groupId, parentCategoryId, name, vocabularyId,
7977                                            orderByComparator, false);
7978    
7979                            return array;
7980                    }
7981                    catch (Exception e) {
7982                            throw processException(e);
7983                    }
7984                    finally {
7985                            closeSession(session);
7986                    }
7987            }
7988    
7989            protected AssetCategory getByG_P_N_V_PrevAndNext(Session session,
7990                    AssetCategory assetCategory, long groupId, long parentCategoryId,
7991                    String name, long vocabularyId, OrderByComparator orderByComparator,
7992                    boolean previous) {
7993                    StringBundler query = null;
7994    
7995                    if (orderByComparator != null) {
7996                            query = new StringBundler(6 +
7997                                            (orderByComparator.getOrderByFields().length * 6));
7998                    }
7999                    else {
8000                            query = new StringBundler(3);
8001                    }
8002    
8003                    query.append(_SQL_SELECT_ASSETCATEGORY_WHERE);
8004    
8005                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8006    
8007                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8008    
8009                    if (name == null) {
8010                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8011                    }
8012                    else {
8013                            if (name.equals(StringPool.BLANK)) {
8014                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8015                            }
8016                            else {
8017                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8018                            }
8019                    }
8020    
8021                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8022    
8023                    if (orderByComparator != null) {
8024                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8025    
8026                            if (orderByConditionFields.length > 0) {
8027                                    query.append(WHERE_AND);
8028                            }
8029    
8030                            for (int i = 0; i < orderByConditionFields.length; i++) {
8031                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8032                                    query.append(orderByConditionFields[i]);
8033    
8034                                    if ((i + 1) < orderByConditionFields.length) {
8035                                            if (orderByComparator.isAscending() ^ previous) {
8036                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8037                                            }
8038                                            else {
8039                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8040                                            }
8041                                    }
8042                                    else {
8043                                            if (orderByComparator.isAscending() ^ previous) {
8044                                                    query.append(WHERE_GREATER_THAN);
8045                                            }
8046                                            else {
8047                                                    query.append(WHERE_LESSER_THAN);
8048                                            }
8049                                    }
8050                            }
8051    
8052                            query.append(ORDER_BY_CLAUSE);
8053    
8054                            String[] orderByFields = orderByComparator.getOrderByFields();
8055    
8056                            for (int i = 0; i < orderByFields.length; i++) {
8057                                    query.append(_ORDER_BY_ENTITY_ALIAS);
8058                                    query.append(orderByFields[i]);
8059    
8060                                    if ((i + 1) < orderByFields.length) {
8061                                            if (orderByComparator.isAscending() ^ previous) {
8062                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8063                                            }
8064                                            else {
8065                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8066                                            }
8067                                    }
8068                                    else {
8069                                            if (orderByComparator.isAscending() ^ previous) {
8070                                                    query.append(ORDER_BY_ASC);
8071                                            }
8072                                            else {
8073                                                    query.append(ORDER_BY_DESC);
8074                                            }
8075                                    }
8076                            }
8077                    }
8078    
8079                    else {
8080                            query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8081                    }
8082    
8083                    String sql = query.toString();
8084    
8085                    Query q = session.createQuery(sql);
8086    
8087                    q.setFirstResult(0);
8088                    q.setMaxResults(2);
8089    
8090                    QueryPos qPos = QueryPos.getInstance(q);
8091    
8092                    qPos.add(groupId);
8093    
8094                    qPos.add(parentCategoryId);
8095    
8096                    if (name != null) {
8097                            qPos.add(name);
8098                    }
8099    
8100                    qPos.add(vocabularyId);
8101    
8102                    if (orderByComparator != null) {
8103                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8104    
8105                            for (Object value : values) {
8106                                    qPos.add(value);
8107                            }
8108                    }
8109    
8110                    List<AssetCategory> list = q.list();
8111    
8112                    if (list.size() == 2) {
8113                            return list.get(1);
8114                    }
8115                    else {
8116                            return null;
8117                    }
8118            }
8119    
8120            /**
8121             * Returns all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
8122             *
8123             * @param groupId the group ID
8124             * @param parentCategoryId the parent category ID
8125             * @param name the name
8126             * @param vocabularyId the vocabulary ID
8127             * @return the matching asset categories that the user has permission to view
8128             * @throws SystemException if a system exception occurred
8129             */
8130            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8131                    long parentCategoryId, String name, long vocabularyId)
8132                    throws SystemException {
8133                    return filterFindByG_P_N_V(groupId, parentCategoryId, name,
8134                            vocabularyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8135            }
8136    
8137            /**
8138             * Returns a range of all the asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
8139             *
8140             * <p>
8141             * 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.
8142             * </p>
8143             *
8144             * @param groupId the group ID
8145             * @param parentCategoryId the parent category ID
8146             * @param name the name
8147             * @param vocabularyId the vocabulary ID
8148             * @param start the lower bound of the range of asset categories
8149             * @param end the upper bound of the range of asset categories (not inclusive)
8150             * @return the range of matching asset categories that the user has permission to view
8151             * @throws SystemException if a system exception occurred
8152             */
8153            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8154                    long parentCategoryId, String name, long vocabularyId, int start,
8155                    int end) throws SystemException {
8156                    return filterFindByG_P_N_V(groupId, parentCategoryId, name,
8157                            vocabularyId, start, end, null);
8158            }
8159    
8160            /**
8161             * Returns an ordered range of all the asset categories that the user has permissions to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
8162             *
8163             * <p>
8164             * 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.
8165             * </p>
8166             *
8167             * @param groupId the group ID
8168             * @param parentCategoryId the parent category ID
8169             * @param name the name
8170             * @param vocabularyId the vocabulary ID
8171             * @param start the lower bound of the range of asset categories
8172             * @param end the upper bound of the range of asset categories (not inclusive)
8173             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8174             * @return the ordered range of matching asset categories that the user has permission to view
8175             * @throws SystemException if a system exception occurred
8176             */
8177            public List<AssetCategory> filterFindByG_P_N_V(long groupId,
8178                    long parentCategoryId, String name, long vocabularyId, int start,
8179                    int end, OrderByComparator orderByComparator) throws SystemException {
8180                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8181                            return findByG_P_N_V(groupId, parentCategoryId, name, vocabularyId,
8182                                    start, end, orderByComparator);
8183                    }
8184    
8185                    StringBundler query = null;
8186    
8187                    if (orderByComparator != null) {
8188                            query = new StringBundler(6 +
8189                                            (orderByComparator.getOrderByFields().length * 3));
8190                    }
8191                    else {
8192                            query = new StringBundler(6);
8193                    }
8194    
8195                    if (getDB().isSupportsInlineDistinct()) {
8196                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8197                    }
8198                    else {
8199                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8200                    }
8201    
8202                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8203    
8204                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8205    
8206                    if (name == null) {
8207                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8208                    }
8209                    else {
8210                            if (name.equals(StringPool.BLANK)) {
8211                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8212                            }
8213                            else {
8214                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8215                            }
8216                    }
8217    
8218                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8219    
8220                    if (!getDB().isSupportsInlineDistinct()) {
8221                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8222                    }
8223    
8224                    if (orderByComparator != null) {
8225                            if (getDB().isSupportsInlineDistinct()) {
8226                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8227                                            orderByComparator);
8228                            }
8229                            else {
8230                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
8231                                            orderByComparator);
8232                            }
8233                    }
8234    
8235                    else {
8236                            if (getDB().isSupportsInlineDistinct()) {
8237                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8238                            }
8239                            else {
8240                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8241                            }
8242                    }
8243    
8244                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8245                                    AssetCategory.class.getName(),
8246                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8247    
8248                    Session session = null;
8249    
8250                    try {
8251                            session = openSession();
8252    
8253                            SQLQuery q = session.createSQLQuery(sql);
8254    
8255                            if (getDB().isSupportsInlineDistinct()) {
8256                                    q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8257                            }
8258                            else {
8259                                    q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8260                            }
8261    
8262                            QueryPos qPos = QueryPos.getInstance(q);
8263    
8264                            qPos.add(groupId);
8265    
8266                            qPos.add(parentCategoryId);
8267    
8268                            if (name != null) {
8269                                    qPos.add(name);
8270                            }
8271    
8272                            qPos.add(vocabularyId);
8273    
8274                            return (List<AssetCategory>)QueryUtil.list(q, getDialect(), start,
8275                                    end);
8276                    }
8277                    catch (Exception e) {
8278                            throw processException(e);
8279                    }
8280                    finally {
8281                            closeSession(session);
8282                    }
8283            }
8284    
8285            /**
8286             * 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 parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
8287             *
8288             * @param categoryId the primary key of the current asset category
8289             * @param groupId the group ID
8290             * @param parentCategoryId the parent category ID
8291             * @param name the name
8292             * @param vocabularyId the vocabulary ID
8293             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
8294             * @return the previous, current, and next asset category
8295             * @throws com.liferay.portlet.asset.NoSuchCategoryException if a asset category with the primary key could not be found
8296             * @throws SystemException if a system exception occurred
8297             */
8298            public AssetCategory[] filterFindByG_P_N_V_PrevAndNext(long categoryId,
8299                    long groupId, long parentCategoryId, String name, long vocabularyId,
8300                    OrderByComparator orderByComparator)
8301                    throws NoSuchCategoryException, SystemException {
8302                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
8303                            return findByG_P_N_V_PrevAndNext(categoryId, groupId,
8304                                    parentCategoryId, name, vocabularyId, orderByComparator);
8305                    }
8306    
8307                    AssetCategory assetCategory = findByPrimaryKey(categoryId);
8308    
8309                    Session session = null;
8310    
8311                    try {
8312                            session = openSession();
8313    
8314                            AssetCategory[] array = new AssetCategoryImpl[3];
8315    
8316                            array[0] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
8317                                            groupId, parentCategoryId, name, vocabularyId,
8318                                            orderByComparator, true);
8319    
8320                            array[1] = assetCategory;
8321    
8322                            array[2] = filterGetByG_P_N_V_PrevAndNext(session, assetCategory,
8323                                            groupId, parentCategoryId, name, vocabularyId,
8324                                            orderByComparator, false);
8325    
8326                            return array;
8327                    }
8328                    catch (Exception e) {
8329                            throw processException(e);
8330                    }
8331                    finally {
8332                            closeSession(session);
8333                    }
8334            }
8335    
8336            protected AssetCategory filterGetByG_P_N_V_PrevAndNext(Session session,
8337                    AssetCategory assetCategory, long groupId, long parentCategoryId,
8338                    String name, long vocabularyId, OrderByComparator orderByComparator,
8339                    boolean previous) {
8340                    StringBundler query = null;
8341    
8342                    if (orderByComparator != null) {
8343                            query = new StringBundler(6 +
8344                                            (orderByComparator.getOrderByFields().length * 6));
8345                    }
8346                    else {
8347                            query = new StringBundler(3);
8348                    }
8349    
8350                    if (getDB().isSupportsInlineDistinct()) {
8351                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_WHERE);
8352                    }
8353                    else {
8354                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1);
8355                    }
8356    
8357                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
8358    
8359                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
8360    
8361                    if (name == null) {
8362                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
8363                    }
8364                    else {
8365                            if (name.equals(StringPool.BLANK)) {
8366                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
8367                            }
8368                            else {
8369                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
8370                            }
8371                    }
8372    
8373                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
8374    
8375                    if (!getDB().isSupportsInlineDistinct()) {
8376                            query.append(_FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2);
8377                    }
8378    
8379                    if (orderByComparator != null) {
8380                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
8381    
8382                            if (orderByConditionFields.length > 0) {
8383                                    query.append(WHERE_AND);
8384                            }
8385    
8386                            for (int i = 0; i < orderByConditionFields.length; i++) {
8387                                    if (getDB().isSupportsInlineDistinct()) {
8388                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8389                                    }
8390                                    else {
8391                                            query.append(_ORDER_BY_ENTITY_TABLE);
8392                                    }
8393    
8394                                    query.append(orderByConditionFields[i]);
8395    
8396                                    if ((i + 1) < orderByConditionFields.length) {
8397                                            if (orderByComparator.isAscending() ^ previous) {
8398                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
8399                                            }
8400                                            else {
8401                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
8402                                            }
8403                                    }
8404                                    else {
8405                                            if (orderByComparator.isAscending() ^ previous) {
8406                                                    query.append(WHERE_GREATER_THAN);
8407                                            }
8408                                            else {
8409                                                    query.append(WHERE_LESSER_THAN);
8410                                            }
8411                                    }
8412                            }
8413    
8414                            query.append(ORDER_BY_CLAUSE);
8415    
8416                            String[] orderByFields = orderByComparator.getOrderByFields();
8417    
8418                            for (int i = 0; i < orderByFields.length; i++) {
8419                                    if (getDB().isSupportsInlineDistinct()) {
8420                                            query.append(_ORDER_BY_ENTITY_ALIAS);
8421                                    }
8422                                    else {
8423                                            query.append(_ORDER_BY_ENTITY_TABLE);
8424                                    }
8425    
8426                                    query.append(orderByFields[i]);
8427    
8428                                    if ((i + 1) < orderByFields.length) {
8429                                            if (orderByComparator.isAscending() ^ previous) {
8430                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
8431                                            }
8432                                            else {
8433                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
8434                                            }
8435                                    }
8436                                    else {
8437                                            if (orderByComparator.isAscending() ^ previous) {
8438                                                    query.append(ORDER_BY_ASC);
8439                                            }
8440                                            else {
8441                                                    query.append(ORDER_BY_DESC);
8442                                            }
8443                                    }
8444                            }
8445                    }
8446    
8447                    else {
8448                            if (getDB().isSupportsInlineDistinct()) {
8449                                    query.append(AssetCategoryModelImpl.ORDER_BY_JPQL);
8450                            }
8451                            else {
8452                                    query.append(AssetCategoryModelImpl.ORDER_BY_SQL);
8453                            }
8454                    }
8455    
8456                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
8457                                    AssetCategory.class.getName(),
8458                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
8459    
8460                    SQLQuery q = session.createSQLQuery(sql);
8461    
8462                    q.setFirstResult(0);
8463                    q.setMaxResults(2);
8464    
8465                    if (getDB().isSupportsInlineDistinct()) {
8466                            q.addEntity(_FILTER_ENTITY_ALIAS, AssetCategoryImpl.class);
8467                    }
8468                    else {
8469                            q.addEntity(_FILTER_ENTITY_TABLE, AssetCategoryImpl.class);
8470                    }
8471    
8472                    QueryPos qPos = QueryPos.getInstance(q);
8473    
8474                    qPos.add(groupId);
8475    
8476                    qPos.add(parentCategoryId);
8477    
8478                    if (name != null) {
8479                            qPos.add(name);
8480                    }
8481    
8482                    qPos.add(vocabularyId);
8483    
8484                    if (orderByComparator != null) {
8485                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategory);
8486    
8487                            for (Object value : values) {
8488                                    qPos.add(value);
8489                            }
8490                    }
8491    
8492                    List<AssetCategory> list = q.list();
8493    
8494                    if (list.size() == 2) {
8495                            return list.get(1);
8496                    }
8497                    else {
8498                            return null;
8499                    }
8500            }
8501    
8502            /**
8503             * Returns all the asset categories.
8504             *
8505             * @return the asset categories
8506             * @throws SystemException if a system exception occurred
8507             */
8508            public List<AssetCategory> findAll() throws SystemException {
8509                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
8510            }
8511    
8512            /**
8513             * Returns a range of all the asset categories.
8514             *
8515             * <p>
8516             * 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.
8517             * </p>
8518             *
8519             * @param start the lower bound of the range of asset categories
8520             * @param end the upper bound of the range of asset categories (not inclusive)
8521             * @return the range of asset categories
8522             * @throws SystemException if a system exception occurred
8523             */
8524            public List<AssetCategory> findAll(int start, int end)
8525                    throws SystemException {
8526                    return findAll(start, end, null);
8527            }
8528    
8529            /**
8530             * Returns an ordered range of all the asset categories.
8531             *
8532             * <p>
8533             * 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.
8534             * </p>
8535             *
8536             * @param start the lower bound of the range of asset categories
8537             * @param end the upper bound of the range of asset categories (not inclusive)
8538             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
8539             * @return the ordered range of asset categories
8540             * @throws SystemException if a system exception occurred
8541             */
8542            public List<AssetCategory> findAll(int start, int end,
8543                    OrderByComparator orderByComparator) throws SystemException {
8544                    FinderPath finderPath = null;
8545                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
8546    
8547                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
8548                                    (orderByComparator == null)) {
8549                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
8550                            finderArgs = FINDER_ARGS_EMPTY;
8551                    }
8552                    else {
8553                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
8554                            finderArgs = new Object[] { start, end, orderByComparator };
8555                    }
8556    
8557                    List<AssetCategory> list = (List<AssetCategory>)FinderCacheUtil.getResult(finderPath,
8558                                    finderArgs, this);
8559    
8560                    if (list == null) {
8561                            StringBundler query = null;
8562                            String sql = null;
8563    
8564                            if (orderByComparator != null) {
8565                                    query = new StringBundler(2 +
8566                                                    (orderByComparator.getOrderByFields().length * 3));
8567    
8568                                    query.append(_SQL_SELECT_ASSETCATEGORY);
8569    
8570                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
8571                                            orderByComparator);
8572    
8573                                    sql = query.toString();
8574                            }
8575                            else {
8576                                    sql = _SQL_SELECT_ASSETCATEGORY.concat(AssetCategoryModelImpl.ORDER_BY_JPQL);
8577                            }
8578    
8579                            Session session = null;
8580    
8581                            try {
8582                                    session = openSession();
8583    
8584                                    Query q = session.createQuery(sql);
8585    
8586                                    if (orderByComparator == null) {
8587                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8588                                                            start, end, false);
8589    
8590                                            Collections.sort(list);
8591                                    }
8592                                    else {
8593                                            list = (List<AssetCategory>)QueryUtil.list(q, getDialect(),
8594                                                            start, end);
8595                                    }
8596                            }
8597                            catch (Exception e) {
8598                                    throw processException(e);
8599                            }
8600                            finally {
8601                                    if (list == null) {
8602                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
8603                                    }
8604                                    else {
8605                                            cacheResult(list);
8606    
8607                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
8608                                    }
8609    
8610                                    closeSession(session);
8611                            }
8612                    }
8613    
8614                    return list;
8615            }
8616    
8617            /**
8618             * Removes all the asset categories where uuid = &#63; from the database.
8619             *
8620             * @param uuid the uuid
8621             * @throws SystemException if a system exception occurred
8622             */
8623            public void removeByUuid(String uuid) throws SystemException {
8624                    for (AssetCategory assetCategory : findByUuid(uuid)) {
8625                            remove(assetCategory);
8626                    }
8627            }
8628    
8629            /**
8630             * Removes the asset category where uuid = &#63; and groupId = &#63; from the database.
8631             *
8632             * @param uuid the uuid
8633             * @param groupId the group ID
8634             * @return the asset category that was removed
8635             * @throws SystemException if a system exception occurred
8636             */
8637            public AssetCategory removeByUUID_G(String uuid, long groupId)
8638                    throws NoSuchCategoryException, SystemException {
8639                    AssetCategory assetCategory = findByUUID_G(uuid, groupId);
8640    
8641                    return remove(assetCategory);
8642            }
8643    
8644            /**
8645             * Removes all the asset categories where groupId = &#63; from the database.
8646             *
8647             * @param groupId the group ID
8648             * @throws SystemException if a system exception occurred
8649             */
8650            public void removeByGroupId(long groupId) throws SystemException {
8651                    for (AssetCategory assetCategory : findByGroupId(groupId)) {
8652                            remove(assetCategory);
8653                    }
8654            }
8655    
8656            /**
8657             * Removes all the asset categories where parentCategoryId = &#63; from the database.
8658             *
8659             * @param parentCategoryId the parent category ID
8660             * @throws SystemException if a system exception occurred
8661             */
8662            public void removeByParentCategoryId(long parentCategoryId)
8663                    throws SystemException {
8664                    for (AssetCategory assetCategory : findByParentCategoryId(
8665                                    parentCategoryId)) {
8666                            remove(assetCategory);
8667                    }
8668            }
8669    
8670            /**
8671             * Removes all the asset categories where vocabularyId = &#63; from the database.
8672             *
8673             * @param vocabularyId the vocabulary ID
8674             * @throws SystemException if a system exception occurred
8675             */
8676            public void removeByVocabularyId(long vocabularyId)
8677                    throws SystemException {
8678                    for (AssetCategory assetCategory : findByVocabularyId(vocabularyId)) {
8679                            remove(assetCategory);
8680                    }
8681            }
8682    
8683            /**
8684             * Removes all the asset categories where groupId = &#63; and vocabularyId = &#63; from the database.
8685             *
8686             * @param groupId the group ID
8687             * @param vocabularyId the vocabulary ID
8688             * @throws SystemException if a system exception occurred
8689             */
8690            public void removeByG_V(long groupId, long vocabularyId)
8691                    throws SystemException {
8692                    for (AssetCategory assetCategory : findByG_V(groupId, vocabularyId)) {
8693                            remove(assetCategory);
8694                    }
8695            }
8696    
8697            /**
8698             * Removes all the asset categories where parentCategoryId = &#63; and name = &#63; from the database.
8699             *
8700             * @param parentCategoryId the parent category ID
8701             * @param name the name
8702             * @throws SystemException if a system exception occurred
8703             */
8704            public void removeByP_N(long parentCategoryId, String name)
8705                    throws SystemException {
8706                    for (AssetCategory assetCategory : findByP_N(parentCategoryId, name)) {
8707                            remove(assetCategory);
8708                    }
8709            }
8710    
8711            /**
8712             * Removes all the asset categories where parentCategoryId = &#63; and vocabularyId = &#63; from the database.
8713             *
8714             * @param parentCategoryId the parent category ID
8715             * @param vocabularyId the vocabulary ID
8716             * @throws SystemException if a system exception occurred
8717             */
8718            public void removeByP_V(long parentCategoryId, long vocabularyId)
8719                    throws SystemException {
8720                    for (AssetCategory assetCategory : findByP_V(parentCategoryId,
8721                                    vocabularyId)) {
8722                            remove(assetCategory);
8723                    }
8724            }
8725    
8726            /**
8727             * Removes all the asset categories where name = &#63; and vocabularyId = &#63; from the database.
8728             *
8729             * @param name the name
8730             * @param vocabularyId the vocabulary ID
8731             * @throws SystemException if a system exception occurred
8732             */
8733            public void removeByN_V(String name, long vocabularyId)
8734                    throws SystemException {
8735                    for (AssetCategory assetCategory : findByN_V(name, vocabularyId)) {
8736                            remove(assetCategory);
8737                    }
8738            }
8739    
8740            /**
8741             * Removes all the asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63; from the database.
8742             *
8743             * @param groupId the group ID
8744             * @param parentCategoryId the parent category ID
8745             * @param vocabularyId the vocabulary ID
8746             * @throws SystemException if a system exception occurred
8747             */
8748            public void removeByG_P_V(long groupId, long parentCategoryId,
8749                    long vocabularyId) throws SystemException {
8750                    for (AssetCategory assetCategory : findByG_P_V(groupId,
8751                                    parentCategoryId, vocabularyId)) {
8752                            remove(assetCategory);
8753                    }
8754            }
8755    
8756            /**
8757             * Removes all the asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63; from the database.
8758             *
8759             * @param groupId the group ID
8760             * @param name the name
8761             * @param vocabularyId the vocabulary ID
8762             * @throws SystemException if a system exception occurred
8763             */
8764            public void removeByG_LikeN_V(long groupId, String name, long vocabularyId)
8765                    throws SystemException {
8766                    for (AssetCategory assetCategory : findByG_LikeN_V(groupId, name,
8767                                    vocabularyId)) {
8768                            remove(assetCategory);
8769                    }
8770            }
8771    
8772            /**
8773             * Removes the asset category where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
8774             *
8775             * @param parentCategoryId the parent category ID
8776             * @param name the name
8777             * @param vocabularyId the vocabulary ID
8778             * @return the asset category that was removed
8779             * @throws SystemException if a system exception occurred
8780             */
8781            public AssetCategory removeByP_N_V(long parentCategoryId, String name,
8782                    long vocabularyId) throws NoSuchCategoryException, SystemException {
8783                    AssetCategory assetCategory = findByP_N_V(parentCategoryId, name,
8784                                    vocabularyId);
8785    
8786                    return remove(assetCategory);
8787            }
8788    
8789            /**
8790             * Removes all the asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63; from the database.
8791             *
8792             * @param groupId the group ID
8793             * @param parentCategoryId the parent category ID
8794             * @param name the name
8795             * @param vocabularyId the vocabulary ID
8796             * @throws SystemException if a system exception occurred
8797             */
8798            public void removeByG_P_N_V(long groupId, long parentCategoryId,
8799                    String name, long vocabularyId) throws SystemException {
8800                    for (AssetCategory assetCategory : findByG_P_N_V(groupId,
8801                                    parentCategoryId, name, vocabularyId)) {
8802                            remove(assetCategory);
8803                    }
8804            }
8805    
8806            /**
8807             * Removes all the asset categories from the database.
8808             *
8809             * @throws SystemException if a system exception occurred
8810             */
8811            public void removeAll() throws SystemException {
8812                    for (AssetCategory assetCategory : findAll()) {
8813                            remove(assetCategory);
8814                    }
8815            }
8816    
8817            /**
8818             * Returns the number of asset categories where uuid = &#63;.
8819             *
8820             * @param uuid the uuid
8821             * @return the number of matching asset categories
8822             * @throws SystemException if a system exception occurred
8823             */
8824            public int countByUuid(String uuid) throws SystemException {
8825                    Object[] finderArgs = new Object[] { uuid };
8826    
8827                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
8828                                    finderArgs, this);
8829    
8830                    if (count == null) {
8831                            StringBundler query = new StringBundler(2);
8832    
8833                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8834    
8835                            if (uuid == null) {
8836                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
8837                            }
8838                            else {
8839                                    if (uuid.equals(StringPool.BLANK)) {
8840                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
8841                                    }
8842                                    else {
8843                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
8844                                    }
8845                            }
8846    
8847                            String sql = query.toString();
8848    
8849                            Session session = null;
8850    
8851                            try {
8852                                    session = openSession();
8853    
8854                                    Query q = session.createQuery(sql);
8855    
8856                                    QueryPos qPos = QueryPos.getInstance(q);
8857    
8858                                    if (uuid != null) {
8859                                            qPos.add(uuid);
8860                                    }
8861    
8862                                    count = (Long)q.uniqueResult();
8863                            }
8864                            catch (Exception e) {
8865                                    throw processException(e);
8866                            }
8867                            finally {
8868                                    if (count == null) {
8869                                            count = Long.valueOf(0);
8870                                    }
8871    
8872                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
8873                                            finderArgs, count);
8874    
8875                                    closeSession(session);
8876                            }
8877                    }
8878    
8879                    return count.intValue();
8880            }
8881    
8882            /**
8883             * Returns the number of asset categories where uuid = &#63; and groupId = &#63;.
8884             *
8885             * @param uuid the uuid
8886             * @param groupId the group ID
8887             * @return the number of matching asset categories
8888             * @throws SystemException if a system exception occurred
8889             */
8890            public int countByUUID_G(String uuid, long groupId)
8891                    throws SystemException {
8892                    Object[] finderArgs = new Object[] { uuid, groupId };
8893    
8894                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
8895                                    finderArgs, this);
8896    
8897                    if (count == null) {
8898                            StringBundler query = new StringBundler(3);
8899    
8900                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8901    
8902                            if (uuid == null) {
8903                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
8904                            }
8905                            else {
8906                                    if (uuid.equals(StringPool.BLANK)) {
8907                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
8908                                    }
8909                                    else {
8910                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
8911                                    }
8912                            }
8913    
8914                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
8915    
8916                            String sql = query.toString();
8917    
8918                            Session session = null;
8919    
8920                            try {
8921                                    session = openSession();
8922    
8923                                    Query q = session.createQuery(sql);
8924    
8925                                    QueryPos qPos = QueryPos.getInstance(q);
8926    
8927                                    if (uuid != null) {
8928                                            qPos.add(uuid);
8929                                    }
8930    
8931                                    qPos.add(groupId);
8932    
8933                                    count = (Long)q.uniqueResult();
8934                            }
8935                            catch (Exception e) {
8936                                    throw processException(e);
8937                            }
8938                            finally {
8939                                    if (count == null) {
8940                                            count = Long.valueOf(0);
8941                                    }
8942    
8943                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
8944                                            finderArgs, count);
8945    
8946                                    closeSession(session);
8947                            }
8948                    }
8949    
8950                    return count.intValue();
8951            }
8952    
8953            /**
8954             * Returns the number of asset categories where groupId = &#63;.
8955             *
8956             * @param groupId the group ID
8957             * @return the number of matching asset categories
8958             * @throws SystemException if a system exception occurred
8959             */
8960            public int countByGroupId(long groupId) throws SystemException {
8961                    Object[] finderArgs = new Object[] { groupId };
8962    
8963                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
8964                                    finderArgs, this);
8965    
8966                    if (count == null) {
8967                            StringBundler query = new StringBundler(2);
8968    
8969                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
8970    
8971                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
8972    
8973                            String sql = query.toString();
8974    
8975                            Session session = null;
8976    
8977                            try {
8978                                    session = openSession();
8979    
8980                                    Query q = session.createQuery(sql);
8981    
8982                                    QueryPos qPos = QueryPos.getInstance(q);
8983    
8984                                    qPos.add(groupId);
8985    
8986                                    count = (Long)q.uniqueResult();
8987                            }
8988                            catch (Exception e) {
8989                                    throw processException(e);
8990                            }
8991                            finally {
8992                                    if (count == null) {
8993                                            count = Long.valueOf(0);
8994                                    }
8995    
8996                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
8997                                            finderArgs, count);
8998    
8999                                    closeSession(session);
9000                            }
9001                    }
9002    
9003                    return count.intValue();
9004            }
9005    
9006            /**
9007             * Returns the number of asset categories that the user has permission to view where groupId = &#63;.
9008             *
9009             * @param groupId the group ID
9010             * @return the number of matching asset categories that the user has permission to view
9011             * @throws SystemException if a system exception occurred
9012             */
9013            public int filterCountByGroupId(long groupId) throws SystemException {
9014                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9015                            return countByGroupId(groupId);
9016                    }
9017    
9018                    StringBundler query = new StringBundler(2);
9019    
9020                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9021    
9022                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
9023    
9024                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9025                                    AssetCategory.class.getName(),
9026                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9027    
9028                    Session session = null;
9029    
9030                    try {
9031                            session = openSession();
9032    
9033                            SQLQuery q = session.createSQLQuery(sql);
9034    
9035                            q.addScalar(COUNT_COLUMN_NAME,
9036                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9037    
9038                            QueryPos qPos = QueryPos.getInstance(q);
9039    
9040                            qPos.add(groupId);
9041    
9042                            Long count = (Long)q.uniqueResult();
9043    
9044                            return count.intValue();
9045                    }
9046                    catch (Exception e) {
9047                            throw processException(e);
9048                    }
9049                    finally {
9050                            closeSession(session);
9051                    }
9052            }
9053    
9054            /**
9055             * Returns the number of asset categories where parentCategoryId = &#63;.
9056             *
9057             * @param parentCategoryId the parent category ID
9058             * @return the number of matching asset categories
9059             * @throws SystemException if a system exception occurred
9060             */
9061            public int countByParentCategoryId(long parentCategoryId)
9062                    throws SystemException {
9063                    Object[] finderArgs = new Object[] { parentCategoryId };
9064    
9065                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
9066                                    finderArgs, this);
9067    
9068                    if (count == null) {
9069                            StringBundler query = new StringBundler(2);
9070    
9071                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9072    
9073                            query.append(_FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2);
9074    
9075                            String sql = query.toString();
9076    
9077                            Session session = null;
9078    
9079                            try {
9080                                    session = openSession();
9081    
9082                                    Query q = session.createQuery(sql);
9083    
9084                                    QueryPos qPos = QueryPos.getInstance(q);
9085    
9086                                    qPos.add(parentCategoryId);
9087    
9088                                    count = (Long)q.uniqueResult();
9089                            }
9090                            catch (Exception e) {
9091                                    throw processException(e);
9092                            }
9093                            finally {
9094                                    if (count == null) {
9095                                            count = Long.valueOf(0);
9096                                    }
9097    
9098                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PARENTCATEGORYID,
9099                                            finderArgs, count);
9100    
9101                                    closeSession(session);
9102                            }
9103                    }
9104    
9105                    return count.intValue();
9106            }
9107    
9108            /**
9109             * Returns the number of asset categories where vocabularyId = &#63;.
9110             *
9111             * @param vocabularyId the vocabulary ID
9112             * @return the number of matching asset categories
9113             * @throws SystemException if a system exception occurred
9114             */
9115            public int countByVocabularyId(long vocabularyId) throws SystemException {
9116                    Object[] finderArgs = new Object[] { vocabularyId };
9117    
9118                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
9119                                    finderArgs, this);
9120    
9121                    if (count == null) {
9122                            StringBundler query = new StringBundler(2);
9123    
9124                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9125    
9126                            query.append(_FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2);
9127    
9128                            String sql = query.toString();
9129    
9130                            Session session = null;
9131    
9132                            try {
9133                                    session = openSession();
9134    
9135                                    Query q = session.createQuery(sql);
9136    
9137                                    QueryPos qPos = QueryPos.getInstance(q);
9138    
9139                                    qPos.add(vocabularyId);
9140    
9141                                    count = (Long)q.uniqueResult();
9142                            }
9143                            catch (Exception e) {
9144                                    throw processException(e);
9145                            }
9146                            finally {
9147                                    if (count == null) {
9148                                            count = Long.valueOf(0);
9149                                    }
9150    
9151                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_VOCABULARYID,
9152                                            finderArgs, count);
9153    
9154                                    closeSession(session);
9155                            }
9156                    }
9157    
9158                    return count.intValue();
9159            }
9160    
9161            /**
9162             * Returns the number of asset categories where groupId = &#63; and vocabularyId = &#63;.
9163             *
9164             * @param groupId the group ID
9165             * @param vocabularyId the vocabulary ID
9166             * @return the number of matching asset categories
9167             * @throws SystemException if a system exception occurred
9168             */
9169            public int countByG_V(long groupId, long vocabularyId)
9170                    throws SystemException {
9171                    Object[] finderArgs = new Object[] { groupId, vocabularyId };
9172    
9173                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_V,
9174                                    finderArgs, this);
9175    
9176                    if (count == null) {
9177                            StringBundler query = new StringBundler(3);
9178    
9179                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9180    
9181                            query.append(_FINDER_COLUMN_G_V_GROUPID_2);
9182    
9183                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
9184    
9185                            String sql = query.toString();
9186    
9187                            Session session = null;
9188    
9189                            try {
9190                                    session = openSession();
9191    
9192                                    Query q = session.createQuery(sql);
9193    
9194                                    QueryPos qPos = QueryPos.getInstance(q);
9195    
9196                                    qPos.add(groupId);
9197    
9198                                    qPos.add(vocabularyId);
9199    
9200                                    count = (Long)q.uniqueResult();
9201                            }
9202                            catch (Exception e) {
9203                                    throw processException(e);
9204                            }
9205                            finally {
9206                                    if (count == null) {
9207                                            count = Long.valueOf(0);
9208                                    }
9209    
9210                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_V, finderArgs,
9211                                            count);
9212    
9213                                    closeSession(session);
9214                            }
9215                    }
9216    
9217                    return count.intValue();
9218            }
9219    
9220            /**
9221             * Returns the number of asset categories where groupId = &#63; and vocabularyId = any &#63;.
9222             *
9223             * @param groupId the group ID
9224             * @param vocabularyIds the vocabulary IDs
9225             * @return the number of matching asset categories
9226             * @throws SystemException if a system exception occurred
9227             */
9228            public int countByG_V(long groupId, long[] vocabularyIds)
9229                    throws SystemException {
9230                    Object[] finderArgs = new Object[] {
9231                                    groupId, StringUtil.merge(vocabularyIds)
9232                            };
9233    
9234                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
9235                                    finderArgs, this);
9236    
9237                    if (count == null) {
9238                            StringBundler query = new StringBundler();
9239    
9240                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9241    
9242                            boolean conjunctionable = false;
9243    
9244                            if (conjunctionable) {
9245                                    query.append(WHERE_AND);
9246                            }
9247    
9248                            query.append(_FINDER_COLUMN_G_V_GROUPID_5);
9249    
9250                            conjunctionable = true;
9251    
9252                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9253                                    if (conjunctionable) {
9254                                            query.append(WHERE_AND);
9255                                    }
9256    
9257                                    query.append(StringPool.OPEN_PARENTHESIS);
9258    
9259                                    for (int i = 0; i < vocabularyIds.length; i++) {
9260                                            query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
9261    
9262                                            if ((i + 1) < vocabularyIds.length) {
9263                                                    query.append(WHERE_OR);
9264                                            }
9265                                    }
9266    
9267                                    query.append(StringPool.CLOSE_PARENTHESIS);
9268    
9269                                    conjunctionable = true;
9270                            }
9271    
9272                            String sql = query.toString();
9273    
9274                            Session session = null;
9275    
9276                            try {
9277                                    session = openSession();
9278    
9279                                    Query q = session.createQuery(sql);
9280    
9281                                    QueryPos qPos = QueryPos.getInstance(q);
9282    
9283                                    qPos.add(groupId);
9284    
9285                                    if (vocabularyIds != null) {
9286                                            qPos.add(vocabularyIds);
9287                                    }
9288    
9289                                    count = (Long)q.uniqueResult();
9290                            }
9291                            catch (Exception e) {
9292                                    throw processException(e);
9293                            }
9294                            finally {
9295                                    if (count == null) {
9296                                            count = Long.valueOf(0);
9297                                    }
9298    
9299                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_V,
9300                                            finderArgs, count);
9301    
9302                                    closeSession(session);
9303                            }
9304                    }
9305    
9306                    return count.intValue();
9307            }
9308    
9309            /**
9310             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = &#63;.
9311             *
9312             * @param groupId the group ID
9313             * @param vocabularyId the vocabulary ID
9314             * @return the number of matching asset categories that the user has permission to view
9315             * @throws SystemException if a system exception occurred
9316             */
9317            public int filterCountByG_V(long groupId, long vocabularyId)
9318                    throws SystemException {
9319                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9320                            return countByG_V(groupId, vocabularyId);
9321                    }
9322    
9323                    StringBundler query = new StringBundler(3);
9324    
9325                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9326    
9327                    query.append(_FINDER_COLUMN_G_V_GROUPID_2);
9328    
9329                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_2);
9330    
9331                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9332                                    AssetCategory.class.getName(),
9333                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9334    
9335                    Session session = null;
9336    
9337                    try {
9338                            session = openSession();
9339    
9340                            SQLQuery q = session.createSQLQuery(sql);
9341    
9342                            q.addScalar(COUNT_COLUMN_NAME,
9343                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9344    
9345                            QueryPos qPos = QueryPos.getInstance(q);
9346    
9347                            qPos.add(groupId);
9348    
9349                            qPos.add(vocabularyId);
9350    
9351                            Long count = (Long)q.uniqueResult();
9352    
9353                            return count.intValue();
9354                    }
9355                    catch (Exception e) {
9356                            throw processException(e);
9357                    }
9358                    finally {
9359                            closeSession(session);
9360                    }
9361            }
9362    
9363            /**
9364             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and vocabularyId = any &#63;.
9365             *
9366             * @param groupId the group ID
9367             * @param vocabularyIds the vocabulary IDs
9368             * @return the number of matching asset categories that the user has permission to view
9369             * @throws SystemException if a system exception occurred
9370             */
9371            public int filterCountByG_V(long groupId, long[] vocabularyIds)
9372                    throws SystemException {
9373                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9374                            return countByG_V(groupId, vocabularyIds);
9375                    }
9376    
9377                    StringBundler query = new StringBundler();
9378    
9379                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9380    
9381                    boolean conjunctionable = false;
9382    
9383                    if (conjunctionable) {
9384                            query.append(WHERE_AND);
9385                    }
9386    
9387                    query.append(_FINDER_COLUMN_G_V_GROUPID_5);
9388    
9389                    conjunctionable = true;
9390    
9391                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9392                            if (conjunctionable) {
9393                                    query.append(WHERE_AND);
9394                            }
9395    
9396                            query.append(StringPool.OPEN_PARENTHESIS);
9397    
9398                            for (int i = 0; i < vocabularyIds.length; i++) {
9399                                    query.append(_FINDER_COLUMN_G_V_VOCABULARYID_5);
9400    
9401                                    if ((i + 1) < vocabularyIds.length) {
9402                                            query.append(WHERE_OR);
9403                                    }
9404                            }
9405    
9406                            query.append(StringPool.CLOSE_PARENTHESIS);
9407    
9408                            conjunctionable = true;
9409                    }
9410    
9411                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9412                                    AssetCategory.class.getName(),
9413                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9414    
9415                    Session session = null;
9416    
9417                    try {
9418                            session = openSession();
9419    
9420                            SQLQuery q = session.createSQLQuery(sql);
9421    
9422                            q.addScalar(COUNT_COLUMN_NAME,
9423                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9424    
9425                            QueryPos qPos = QueryPos.getInstance(q);
9426    
9427                            qPos.add(groupId);
9428    
9429                            if (vocabularyIds != null) {
9430                                    qPos.add(vocabularyIds);
9431                            }
9432    
9433                            Long count = (Long)q.uniqueResult();
9434    
9435                            return count.intValue();
9436                    }
9437                    catch (Exception e) {
9438                            throw processException(e);
9439                    }
9440                    finally {
9441                            closeSession(session);
9442                    }
9443            }
9444    
9445            /**
9446             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63;.
9447             *
9448             * @param parentCategoryId the parent category ID
9449             * @param name the name
9450             * @return the number of matching asset categories
9451             * @throws SystemException if a system exception occurred
9452             */
9453            public int countByP_N(long parentCategoryId, String name)
9454                    throws SystemException {
9455                    Object[] finderArgs = new Object[] { parentCategoryId, name };
9456    
9457                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N,
9458                                    finderArgs, this);
9459    
9460                    if (count == null) {
9461                            StringBundler query = new StringBundler(3);
9462    
9463                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9464    
9465                            query.append(_FINDER_COLUMN_P_N_PARENTCATEGORYID_2);
9466    
9467                            if (name == null) {
9468                                    query.append(_FINDER_COLUMN_P_N_NAME_1);
9469                            }
9470                            else {
9471                                    if (name.equals(StringPool.BLANK)) {
9472                                            query.append(_FINDER_COLUMN_P_N_NAME_3);
9473                                    }
9474                                    else {
9475                                            query.append(_FINDER_COLUMN_P_N_NAME_2);
9476                                    }
9477                            }
9478    
9479                            String sql = query.toString();
9480    
9481                            Session session = null;
9482    
9483                            try {
9484                                    session = openSession();
9485    
9486                                    Query q = session.createQuery(sql);
9487    
9488                                    QueryPos qPos = QueryPos.getInstance(q);
9489    
9490                                    qPos.add(parentCategoryId);
9491    
9492                                    if (name != null) {
9493                                            qPos.add(name);
9494                                    }
9495    
9496                                    count = (Long)q.uniqueResult();
9497                            }
9498                            catch (Exception e) {
9499                                    throw processException(e);
9500                            }
9501                            finally {
9502                                    if (count == null) {
9503                                            count = Long.valueOf(0);
9504                                    }
9505    
9506                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N, finderArgs,
9507                                            count);
9508    
9509                                    closeSession(session);
9510                            }
9511                    }
9512    
9513                    return count.intValue();
9514            }
9515    
9516            /**
9517             * Returns the number of asset categories where parentCategoryId = &#63; and vocabularyId = &#63;.
9518             *
9519             * @param parentCategoryId the parent category ID
9520             * @param vocabularyId the vocabulary ID
9521             * @return the number of matching asset categories
9522             * @throws SystemException if a system exception occurred
9523             */
9524            public int countByP_V(long parentCategoryId, long vocabularyId)
9525                    throws SystemException {
9526                    Object[] finderArgs = new Object[] { parentCategoryId, vocabularyId };
9527    
9528                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_V,
9529                                    finderArgs, this);
9530    
9531                    if (count == null) {
9532                            StringBundler query = new StringBundler(3);
9533    
9534                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9535    
9536                            query.append(_FINDER_COLUMN_P_V_PARENTCATEGORYID_2);
9537    
9538                            query.append(_FINDER_COLUMN_P_V_VOCABULARYID_2);
9539    
9540                            String sql = query.toString();
9541    
9542                            Session session = null;
9543    
9544                            try {
9545                                    session = openSession();
9546    
9547                                    Query q = session.createQuery(sql);
9548    
9549                                    QueryPos qPos = QueryPos.getInstance(q);
9550    
9551                                    qPos.add(parentCategoryId);
9552    
9553                                    qPos.add(vocabularyId);
9554    
9555                                    count = (Long)q.uniqueResult();
9556                            }
9557                            catch (Exception e) {
9558                                    throw processException(e);
9559                            }
9560                            finally {
9561                                    if (count == null) {
9562                                            count = Long.valueOf(0);
9563                                    }
9564    
9565                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_V, finderArgs,
9566                                            count);
9567    
9568                                    closeSession(session);
9569                            }
9570                    }
9571    
9572                    return count.intValue();
9573            }
9574    
9575            /**
9576             * Returns the number of asset categories where name = &#63; and vocabularyId = &#63;.
9577             *
9578             * @param name the name
9579             * @param vocabularyId the vocabulary ID
9580             * @return the number of matching asset categories
9581             * @throws SystemException if a system exception occurred
9582             */
9583            public int countByN_V(String name, long vocabularyId)
9584                    throws SystemException {
9585                    Object[] finderArgs = new Object[] { name, vocabularyId };
9586    
9587                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_V,
9588                                    finderArgs, this);
9589    
9590                    if (count == null) {
9591                            StringBundler query = new StringBundler(3);
9592    
9593                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9594    
9595                            if (name == null) {
9596                                    query.append(_FINDER_COLUMN_N_V_NAME_1);
9597                            }
9598                            else {
9599                                    if (name.equals(StringPool.BLANK)) {
9600                                            query.append(_FINDER_COLUMN_N_V_NAME_3);
9601                                    }
9602                                    else {
9603                                            query.append(_FINDER_COLUMN_N_V_NAME_2);
9604                                    }
9605                            }
9606    
9607                            query.append(_FINDER_COLUMN_N_V_VOCABULARYID_2);
9608    
9609                            String sql = query.toString();
9610    
9611                            Session session = null;
9612    
9613                            try {
9614                                    session = openSession();
9615    
9616                                    Query q = session.createQuery(sql);
9617    
9618                                    QueryPos qPos = QueryPos.getInstance(q);
9619    
9620                                    if (name != null) {
9621                                            qPos.add(name);
9622                                    }
9623    
9624                                    qPos.add(vocabularyId);
9625    
9626                                    count = (Long)q.uniqueResult();
9627                            }
9628                            catch (Exception e) {
9629                                    throw processException(e);
9630                            }
9631                            finally {
9632                                    if (count == null) {
9633                                            count = Long.valueOf(0);
9634                                    }
9635    
9636                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_V, finderArgs,
9637                                            count);
9638    
9639                                    closeSession(session);
9640                            }
9641                    }
9642    
9643                    return count.intValue();
9644            }
9645    
9646            /**
9647             * Returns the number of asset categories where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
9648             *
9649             * @param groupId the group ID
9650             * @param parentCategoryId the parent category ID
9651             * @param vocabularyId the vocabulary ID
9652             * @return the number of matching asset categories
9653             * @throws SystemException if a system exception occurred
9654             */
9655            public int countByG_P_V(long groupId, long parentCategoryId,
9656                    long vocabularyId) throws SystemException {
9657                    Object[] finderArgs = new Object[] {
9658                                    groupId, parentCategoryId, vocabularyId
9659                            };
9660    
9661                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_V,
9662                                    finderArgs, this);
9663    
9664                    if (count == null) {
9665                            StringBundler query = new StringBundler(4);
9666    
9667                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9668    
9669                            query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
9670    
9671                            query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
9672    
9673                            query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
9674    
9675                            String sql = query.toString();
9676    
9677                            Session session = null;
9678    
9679                            try {
9680                                    session = openSession();
9681    
9682                                    Query q = session.createQuery(sql);
9683    
9684                                    QueryPos qPos = QueryPos.getInstance(q);
9685    
9686                                    qPos.add(groupId);
9687    
9688                                    qPos.add(parentCategoryId);
9689    
9690                                    qPos.add(vocabularyId);
9691    
9692                                    count = (Long)q.uniqueResult();
9693                            }
9694                            catch (Exception e) {
9695                                    throw processException(e);
9696                            }
9697                            finally {
9698                                    if (count == null) {
9699                                            count = Long.valueOf(0);
9700                                    }
9701    
9702                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_V,
9703                                            finderArgs, count);
9704    
9705                                    closeSession(session);
9706                            }
9707                    }
9708    
9709                    return count.intValue();
9710            }
9711    
9712            /**
9713             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and vocabularyId = &#63;.
9714             *
9715             * @param groupId the group ID
9716             * @param parentCategoryId the parent category ID
9717             * @param vocabularyId the vocabulary ID
9718             * @return the number of matching asset categories that the user has permission to view
9719             * @throws SystemException if a system exception occurred
9720             */
9721            public int filterCountByG_P_V(long groupId, long parentCategoryId,
9722                    long vocabularyId) throws SystemException {
9723                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9724                            return countByG_P_V(groupId, parentCategoryId, vocabularyId);
9725                    }
9726    
9727                    StringBundler query = new StringBundler(4);
9728    
9729                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9730    
9731                    query.append(_FINDER_COLUMN_G_P_V_GROUPID_2);
9732    
9733                    query.append(_FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2);
9734    
9735                    query.append(_FINDER_COLUMN_G_P_V_VOCABULARYID_2);
9736    
9737                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9738                                    AssetCategory.class.getName(),
9739                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9740    
9741                    Session session = null;
9742    
9743                    try {
9744                            session = openSession();
9745    
9746                            SQLQuery q = session.createSQLQuery(sql);
9747    
9748                            q.addScalar(COUNT_COLUMN_NAME,
9749                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
9750    
9751                            QueryPos qPos = QueryPos.getInstance(q);
9752    
9753                            qPos.add(groupId);
9754    
9755                            qPos.add(parentCategoryId);
9756    
9757                            qPos.add(vocabularyId);
9758    
9759                            Long count = (Long)q.uniqueResult();
9760    
9761                            return count.intValue();
9762                    }
9763                    catch (Exception e) {
9764                            throw processException(e);
9765                    }
9766                    finally {
9767                            closeSession(session);
9768                    }
9769            }
9770    
9771            /**
9772             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
9773             *
9774             * @param groupId the group ID
9775             * @param name the name
9776             * @param vocabularyId the vocabulary ID
9777             * @return the number of matching asset categories
9778             * @throws SystemException if a system exception occurred
9779             */
9780            public int countByG_LikeN_V(long groupId, String name, long vocabularyId)
9781                    throws SystemException {
9782                    Object[] finderArgs = new Object[] { groupId, name, vocabularyId };
9783    
9784                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9785                                    finderArgs, this);
9786    
9787                    if (count == null) {
9788                            StringBundler query = new StringBundler(4);
9789    
9790                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9791    
9792                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
9793    
9794                            if (name == null) {
9795                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
9796                            }
9797                            else {
9798                                    if (name.equals(StringPool.BLANK)) {
9799                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
9800                                    }
9801                                    else {
9802                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
9803                                    }
9804                            }
9805    
9806                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
9807    
9808                            String sql = query.toString();
9809    
9810                            Session session = null;
9811    
9812                            try {
9813                                    session = openSession();
9814    
9815                                    Query q = session.createQuery(sql);
9816    
9817                                    QueryPos qPos = QueryPos.getInstance(q);
9818    
9819                                    qPos.add(groupId);
9820    
9821                                    if (name != null) {
9822                                            qPos.add(name);
9823                                    }
9824    
9825                                    qPos.add(vocabularyId);
9826    
9827                                    count = (Long)q.uniqueResult();
9828                            }
9829                            catch (Exception e) {
9830                                    throw processException(e);
9831                            }
9832                            finally {
9833                                    if (count == null) {
9834                                            count = Long.valueOf(0);
9835                                    }
9836    
9837                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9838                                            finderArgs, count);
9839    
9840                                    closeSession(session);
9841                            }
9842                    }
9843    
9844                    return count.intValue();
9845            }
9846    
9847            /**
9848             * Returns the number of asset categories where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
9849             *
9850             * @param groupId the group ID
9851             * @param name the name
9852             * @param vocabularyIds the vocabulary IDs
9853             * @return the number of matching asset categories
9854             * @throws SystemException if a system exception occurred
9855             */
9856            public int countByG_LikeN_V(long groupId, String name, long[] vocabularyIds)
9857                    throws SystemException {
9858                    Object[] finderArgs = new Object[] {
9859                                    groupId, name, StringUtil.merge(vocabularyIds)
9860                            };
9861    
9862                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9863                                    finderArgs, this);
9864    
9865                    if (count == null) {
9866                            StringBundler query = new StringBundler();
9867    
9868                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
9869    
9870                            boolean conjunctionable = false;
9871    
9872                            if (conjunctionable) {
9873                                    query.append(WHERE_AND);
9874                            }
9875    
9876                            query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
9877    
9878                            conjunctionable = true;
9879    
9880                            if (conjunctionable) {
9881                                    query.append(WHERE_AND);
9882                            }
9883    
9884                            if (name == null) {
9885                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
9886                            }
9887                            else {
9888                                    if (name.equals(StringPool.BLANK)) {
9889                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
9890                                    }
9891                                    else {
9892                                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
9893                                    }
9894                            }
9895    
9896                            conjunctionable = true;
9897    
9898                            if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
9899                                    if (conjunctionable) {
9900                                            query.append(WHERE_AND);
9901                                    }
9902    
9903                                    query.append(StringPool.OPEN_PARENTHESIS);
9904    
9905                                    for (int i = 0; i < vocabularyIds.length; i++) {
9906                                            query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
9907    
9908                                            if ((i + 1) < vocabularyIds.length) {
9909                                                    query.append(WHERE_OR);
9910                                            }
9911                                    }
9912    
9913                                    query.append(StringPool.CLOSE_PARENTHESIS);
9914    
9915                                    conjunctionable = true;
9916                            }
9917    
9918                            String sql = query.toString();
9919    
9920                            Session session = null;
9921    
9922                            try {
9923                                    session = openSession();
9924    
9925                                    Query q = session.createQuery(sql);
9926    
9927                                    QueryPos qPos = QueryPos.getInstance(q);
9928    
9929                                    qPos.add(groupId);
9930    
9931                                    if (name != null) {
9932                                            qPos.add(name);
9933                                    }
9934    
9935                                    if (vocabularyIds != null) {
9936                                            qPos.add(vocabularyIds);
9937                                    }
9938    
9939                                    count = (Long)q.uniqueResult();
9940                            }
9941                            catch (Exception e) {
9942                                    throw processException(e);
9943                            }
9944                            finally {
9945                                    if (count == null) {
9946                                            count = Long.valueOf(0);
9947                                    }
9948    
9949                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_G_LIKEN_V,
9950                                            finderArgs, count);
9951    
9952                                    closeSession(session);
9953                            }
9954                    }
9955    
9956                    return count.intValue();
9957            }
9958    
9959            /**
9960             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = &#63;.
9961             *
9962             * @param groupId the group ID
9963             * @param name the name
9964             * @param vocabularyId the vocabulary ID
9965             * @return the number of matching asset categories that the user has permission to view
9966             * @throws SystemException if a system exception occurred
9967             */
9968            public int filterCountByG_LikeN_V(long groupId, String name,
9969                    long vocabularyId) throws SystemException {
9970                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
9971                            return countByG_LikeN_V(groupId, name, vocabularyId);
9972                    }
9973    
9974                    StringBundler query = new StringBundler(4);
9975    
9976                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
9977    
9978                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2);
9979    
9980                    if (name == null) {
9981                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_1);
9982                    }
9983                    else {
9984                            if (name.equals(StringPool.BLANK)) {
9985                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_3);
9986                            }
9987                            else {
9988                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_2);
9989                            }
9990                    }
9991    
9992                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2);
9993    
9994                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
9995                                    AssetCategory.class.getName(),
9996                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
9997    
9998                    Session session = null;
9999    
10000                    try {
10001                            session = openSession();
10002    
10003                            SQLQuery q = session.createSQLQuery(sql);
10004    
10005                            q.addScalar(COUNT_COLUMN_NAME,
10006                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10007    
10008                            QueryPos qPos = QueryPos.getInstance(q);
10009    
10010                            qPos.add(groupId);
10011    
10012                            if (name != null) {
10013                                    qPos.add(name);
10014                            }
10015    
10016                            qPos.add(vocabularyId);
10017    
10018                            Long count = (Long)q.uniqueResult();
10019    
10020                            return count.intValue();
10021                    }
10022                    catch (Exception e) {
10023                            throw processException(e);
10024                    }
10025                    finally {
10026                            closeSession(session);
10027                    }
10028            }
10029    
10030            /**
10031             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and name LIKE &#63; and vocabularyId = any &#63;.
10032             *
10033             * @param groupId the group ID
10034             * @param name the name
10035             * @param vocabularyIds the vocabulary IDs
10036             * @return the number of matching asset categories that the user has permission to view
10037             * @throws SystemException if a system exception occurred
10038             */
10039            public int filterCountByG_LikeN_V(long groupId, String name,
10040                    long[] vocabularyIds) throws SystemException {
10041                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10042                            return countByG_LikeN_V(groupId, name, vocabularyIds);
10043                    }
10044    
10045                    StringBundler query = new StringBundler();
10046    
10047                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10048    
10049                    boolean conjunctionable = false;
10050    
10051                    if (conjunctionable) {
10052                            query.append(WHERE_AND);
10053                    }
10054    
10055                    query.append(_FINDER_COLUMN_G_LIKEN_V_GROUPID_5);
10056    
10057                    conjunctionable = true;
10058    
10059                    if (conjunctionable) {
10060                            query.append(WHERE_AND);
10061                    }
10062    
10063                    if (name == null) {
10064                            query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_4);
10065                    }
10066                    else {
10067                            if (name.equals(StringPool.BLANK)) {
10068                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_6);
10069                            }
10070                            else {
10071                                    query.append(_FINDER_COLUMN_G_LIKEN_V_NAME_5);
10072                            }
10073                    }
10074    
10075                    conjunctionable = true;
10076    
10077                    if ((vocabularyIds == null) || (vocabularyIds.length > 0)) {
10078                            if (conjunctionable) {
10079                                    query.append(WHERE_AND);
10080                            }
10081    
10082                            query.append(StringPool.OPEN_PARENTHESIS);
10083    
10084                            for (int i = 0; i < vocabularyIds.length; i++) {
10085                                    query.append(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5);
10086    
10087                                    if ((i + 1) < vocabularyIds.length) {
10088                                            query.append(WHERE_OR);
10089                                    }
10090                            }
10091    
10092                            query.append(StringPool.CLOSE_PARENTHESIS);
10093    
10094                            conjunctionable = true;
10095                    }
10096    
10097                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10098                                    AssetCategory.class.getName(),
10099                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10100    
10101                    Session session = null;
10102    
10103                    try {
10104                            session = openSession();
10105    
10106                            SQLQuery q = session.createSQLQuery(sql);
10107    
10108                            q.addScalar(COUNT_COLUMN_NAME,
10109                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10110    
10111                            QueryPos qPos = QueryPos.getInstance(q);
10112    
10113                            qPos.add(groupId);
10114    
10115                            if (name != null) {
10116                                    qPos.add(name);
10117                            }
10118    
10119                            if (vocabularyIds != null) {
10120                                    qPos.add(vocabularyIds);
10121                            }
10122    
10123                            Long count = (Long)q.uniqueResult();
10124    
10125                            return count.intValue();
10126                    }
10127                    catch (Exception e) {
10128                            throw processException(e);
10129                    }
10130                    finally {
10131                            closeSession(session);
10132                    }
10133            }
10134    
10135            /**
10136             * Returns the number of asset categories where parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10137             *
10138             * @param parentCategoryId the parent category ID
10139             * @param name the name
10140             * @param vocabularyId the vocabulary ID
10141             * @return the number of matching asset categories
10142             * @throws SystemException if a system exception occurred
10143             */
10144            public int countByP_N_V(long parentCategoryId, String name,
10145                    long vocabularyId) throws SystemException {
10146                    Object[] finderArgs = new Object[] { parentCategoryId, name, vocabularyId };
10147    
10148                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_P_N_V,
10149                                    finderArgs, this);
10150    
10151                    if (count == null) {
10152                            StringBundler query = new StringBundler(4);
10153    
10154                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10155    
10156                            query.append(_FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2);
10157    
10158                            if (name == null) {
10159                                    query.append(_FINDER_COLUMN_P_N_V_NAME_1);
10160                            }
10161                            else {
10162                                    if (name.equals(StringPool.BLANK)) {
10163                                            query.append(_FINDER_COLUMN_P_N_V_NAME_3);
10164                                    }
10165                                    else {
10166                                            query.append(_FINDER_COLUMN_P_N_V_NAME_2);
10167                                    }
10168                            }
10169    
10170                            query.append(_FINDER_COLUMN_P_N_V_VOCABULARYID_2);
10171    
10172                            String sql = query.toString();
10173    
10174                            Session session = null;
10175    
10176                            try {
10177                                    session = openSession();
10178    
10179                                    Query q = session.createQuery(sql);
10180    
10181                                    QueryPos qPos = QueryPos.getInstance(q);
10182    
10183                                    qPos.add(parentCategoryId);
10184    
10185                                    if (name != null) {
10186                                            qPos.add(name);
10187                                    }
10188    
10189                                    qPos.add(vocabularyId);
10190    
10191                                    count = (Long)q.uniqueResult();
10192                            }
10193                            catch (Exception e) {
10194                                    throw processException(e);
10195                            }
10196                            finally {
10197                                    if (count == null) {
10198                                            count = Long.valueOf(0);
10199                                    }
10200    
10201                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_P_N_V,
10202                                            finderArgs, count);
10203    
10204                                    closeSession(session);
10205                            }
10206                    }
10207    
10208                    return count.intValue();
10209            }
10210    
10211            /**
10212             * Returns the number of asset categories where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10213             *
10214             * @param groupId the group ID
10215             * @param parentCategoryId the parent category ID
10216             * @param name the name
10217             * @param vocabularyId the vocabulary ID
10218             * @return the number of matching asset categories
10219             * @throws SystemException if a system exception occurred
10220             */
10221            public int countByG_P_N_V(long groupId, long parentCategoryId, String name,
10222                    long vocabularyId) throws SystemException {
10223                    Object[] finderArgs = new Object[] {
10224                                    groupId, parentCategoryId, name, vocabularyId
10225                            };
10226    
10227                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N_V,
10228                                    finderArgs, this);
10229    
10230                    if (count == null) {
10231                            StringBundler query = new StringBundler(5);
10232    
10233                            query.append(_SQL_COUNT_ASSETCATEGORY_WHERE);
10234    
10235                            query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10236    
10237                            query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10238    
10239                            if (name == null) {
10240                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10241                            }
10242                            else {
10243                                    if (name.equals(StringPool.BLANK)) {
10244                                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10245                                    }
10246                                    else {
10247                                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10248                                    }
10249                            }
10250    
10251                            query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10252    
10253                            String sql = query.toString();
10254    
10255                            Session session = null;
10256    
10257                            try {
10258                                    session = openSession();
10259    
10260                                    Query q = session.createQuery(sql);
10261    
10262                                    QueryPos qPos = QueryPos.getInstance(q);
10263    
10264                                    qPos.add(groupId);
10265    
10266                                    qPos.add(parentCategoryId);
10267    
10268                                    if (name != null) {
10269                                            qPos.add(name);
10270                                    }
10271    
10272                                    qPos.add(vocabularyId);
10273    
10274                                    count = (Long)q.uniqueResult();
10275                            }
10276                            catch (Exception e) {
10277                                    throw processException(e);
10278                            }
10279                            finally {
10280                                    if (count == null) {
10281                                            count = Long.valueOf(0);
10282                                    }
10283    
10284                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N_V,
10285                                            finderArgs, count);
10286    
10287                                    closeSession(session);
10288                            }
10289                    }
10290    
10291                    return count.intValue();
10292            }
10293    
10294            /**
10295             * Returns the number of asset categories that the user has permission to view where groupId = &#63; and parentCategoryId = &#63; and name = &#63; and vocabularyId = &#63;.
10296             *
10297             * @param groupId the group ID
10298             * @param parentCategoryId the parent category ID
10299             * @param name the name
10300             * @param vocabularyId the vocabulary ID
10301             * @return the number of matching asset categories that the user has permission to view
10302             * @throws SystemException if a system exception occurred
10303             */
10304            public int filterCountByG_P_N_V(long groupId, long parentCategoryId,
10305                    String name, long vocabularyId) throws SystemException {
10306                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
10307                            return countByG_P_N_V(groupId, parentCategoryId, name, vocabularyId);
10308                    }
10309    
10310                    StringBundler query = new StringBundler(5);
10311    
10312                    query.append(_FILTER_SQL_COUNT_ASSETCATEGORY_WHERE);
10313    
10314                    query.append(_FINDER_COLUMN_G_P_N_V_GROUPID_2);
10315    
10316                    query.append(_FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2);
10317    
10318                    if (name == null) {
10319                            query.append(_FINDER_COLUMN_G_P_N_V_NAME_1);
10320                    }
10321                    else {
10322                            if (name.equals(StringPool.BLANK)) {
10323                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_3);
10324                            }
10325                            else {
10326                                    query.append(_FINDER_COLUMN_G_P_N_V_NAME_2);
10327                            }
10328                    }
10329    
10330                    query.append(_FINDER_COLUMN_G_P_N_V_VOCABULARYID_2);
10331    
10332                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
10333                                    AssetCategory.class.getName(),
10334                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
10335    
10336                    Session session = null;
10337    
10338                    try {
10339                            session = openSession();
10340    
10341                            SQLQuery q = session.createSQLQuery(sql);
10342    
10343                            q.addScalar(COUNT_COLUMN_NAME,
10344                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10345    
10346                            QueryPos qPos = QueryPos.getInstance(q);
10347    
10348                            qPos.add(groupId);
10349    
10350                            qPos.add(parentCategoryId);
10351    
10352                            if (name != null) {
10353                                    qPos.add(name);
10354                            }
10355    
10356                            qPos.add(vocabularyId);
10357    
10358                            Long count = (Long)q.uniqueResult();
10359    
10360                            return count.intValue();
10361                    }
10362                    catch (Exception e) {
10363                            throw processException(e);
10364                    }
10365                    finally {
10366                            closeSession(session);
10367                    }
10368            }
10369    
10370            /**
10371             * Returns the number of asset categories.
10372             *
10373             * @return the number of asset categories
10374             * @throws SystemException if a system exception occurred
10375             */
10376            public int countAll() throws SystemException {
10377                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
10378                                    FINDER_ARGS_EMPTY, this);
10379    
10380                    if (count == null) {
10381                            Session session = null;
10382    
10383                            try {
10384                                    session = openSession();
10385    
10386                                    Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORY);
10387    
10388                                    count = (Long)q.uniqueResult();
10389                            }
10390                            catch (Exception e) {
10391                                    throw processException(e);
10392                            }
10393                            finally {
10394                                    if (count == null) {
10395                                            count = Long.valueOf(0);
10396                                    }
10397    
10398                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
10399                                            FINDER_ARGS_EMPTY, count);
10400    
10401                                    closeSession(session);
10402                            }
10403                    }
10404    
10405                    return count.intValue();
10406            }
10407    
10408            /**
10409             * Returns all the asset entries associated with the asset category.
10410             *
10411             * @param pk the primary key of the asset category
10412             * @return the asset entries associated with the asset category
10413             * @throws SystemException if a system exception occurred
10414             */
10415            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
10416                    long pk) throws SystemException {
10417                    return getAssetEntries(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
10418            }
10419    
10420            /**
10421             * Returns a range of all the asset entries associated with the asset category.
10422             *
10423             * <p>
10424             * 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.
10425             * </p>
10426             *
10427             * @param pk the primary key of the asset category
10428             * @param start the lower bound of the range of asset categories
10429             * @param end the upper bound of the range of asset categories (not inclusive)
10430             * @return the range of asset entries associated with the asset category
10431             * @throws SystemException if a system exception occurred
10432             */
10433            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
10434                    long pk, int start, int end) throws SystemException {
10435                    return getAssetEntries(pk, start, end, null);
10436            }
10437    
10438            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
10439                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
10440                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class,
10441                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
10442                            "getAssetEntries",
10443                            new String[] {
10444                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
10445                                    "com.liferay.portal.kernel.util.OrderByComparator"
10446                            });
10447    
10448            static {
10449                    FINDER_PATH_GET_ASSETENTRIES.setCacheKeyGeneratorCacheName(null);
10450            }
10451    
10452            /**
10453             * Returns an ordered range of all the asset entries associated with the asset category.
10454             *
10455             * <p>
10456             * 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.
10457             * </p>
10458             *
10459             * @param pk the primary key of the asset category
10460             * @param start the lower bound of the range of asset categories
10461             * @param end the upper bound of the range of asset categories (not inclusive)
10462             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
10463             * @return the ordered range of asset entries associated with the asset category
10464             * @throws SystemException if a system exception occurred
10465             */
10466            public List<com.liferay.portlet.asset.model.AssetEntry> getAssetEntries(
10467                    long pk, int start, int end, OrderByComparator orderByComparator)
10468                    throws SystemException {
10469                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
10470    
10471                    List<com.liferay.portlet.asset.model.AssetEntry> list = (List<com.liferay.portlet.asset.model.AssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES,
10472                                    finderArgs, this);
10473    
10474                    if (list == null) {
10475                            Session session = null;
10476    
10477                            try {
10478                                    session = openSession();
10479    
10480                                    String sql = null;
10481    
10482                                    if (orderByComparator != null) {
10483                                            sql = _SQL_GETASSETENTRIES.concat(ORDER_BY_CLAUSE)
10484                                                                                              .concat(orderByComparator.getOrderBy());
10485                                    }
10486                                    else {
10487                                            sql = _SQL_GETASSETENTRIES;
10488                                    }
10489    
10490                                    SQLQuery q = session.createSQLQuery(sql);
10491    
10492                                    q.addEntity("AssetEntry",
10493                                            com.liferay.portlet.asset.model.impl.AssetEntryImpl.class);
10494    
10495                                    QueryPos qPos = QueryPos.getInstance(q);
10496    
10497                                    qPos.add(pk);
10498    
10499                                    list = (List<com.liferay.portlet.asset.model.AssetEntry>)QueryUtil.list(q,
10500                                                    getDialect(), start, end);
10501                            }
10502                            catch (Exception e) {
10503                                    throw processException(e);
10504                            }
10505                            finally {
10506                                    if (list == null) {
10507                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_ASSETENTRIES,
10508                                                    finderArgs);
10509                                    }
10510                                    else {
10511                                            assetEntryPersistence.cacheResult(list);
10512    
10513                                            FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES,
10514                                                    finderArgs, list);
10515                                    }
10516    
10517                                    closeSession(session);
10518                            }
10519                    }
10520    
10521                    return list;
10522            }
10523    
10524            public static final FinderPath FINDER_PATH_GET_ASSETENTRIES_SIZE = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
10525                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
10526                            Long.class,
10527                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
10528                            "getAssetEntriesSize", new String[] { Long.class.getName() });
10529    
10530            static {
10531                    FINDER_PATH_GET_ASSETENTRIES_SIZE.setCacheKeyGeneratorCacheName(null);
10532            }
10533    
10534            /**
10535             * Returns the number of asset entries associated with the asset category.
10536             *
10537             * @param pk the primary key of the asset category
10538             * @return the number of asset entries associated with the asset category
10539             * @throws SystemException if a system exception occurred
10540             */
10541            public int getAssetEntriesSize(long pk) throws SystemException {
10542                    Object[] finderArgs = new Object[] { pk };
10543    
10544                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
10545                                    finderArgs, this);
10546    
10547                    if (count == null) {
10548                            Session session = null;
10549    
10550                            try {
10551                                    session = openSession();
10552    
10553                                    SQLQuery q = session.createSQLQuery(_SQL_GETASSETENTRIESSIZE);
10554    
10555                                    q.addScalar(COUNT_COLUMN_NAME,
10556                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
10557    
10558                                    QueryPos qPos = QueryPos.getInstance(q);
10559    
10560                                    qPos.add(pk);
10561    
10562                                    count = (Long)q.uniqueResult();
10563                            }
10564                            catch (Exception e) {
10565                                    throw processException(e);
10566                            }
10567                            finally {
10568                                    if (count == null) {
10569                                            count = Long.valueOf(0);
10570                                    }
10571    
10572                                    FinderCacheUtil.putResult(FINDER_PATH_GET_ASSETENTRIES_SIZE,
10573                                            finderArgs, count);
10574    
10575                                    closeSession(session);
10576                            }
10577                    }
10578    
10579                    return count.intValue();
10580            }
10581    
10582            public static final FinderPath FINDER_PATH_CONTAINS_ASSETENTRY = new FinderPath(com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.ENTITY_CACHE_ENABLED,
10583                            AssetCategoryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES,
10584                            Boolean.class,
10585                            AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME,
10586                            "containsAssetEntry",
10587                            new String[] { Long.class.getName(), Long.class.getName() });
10588    
10589            /**
10590             * Returns <code>true</code> if the asset entry is associated with the asset category.
10591             *
10592             * @param pk the primary key of the asset category
10593             * @param assetEntryPK the primary key of the asset entry
10594             * @return <code>true</code> if the asset entry is associated with the asset category; <code>false</code> otherwise
10595             * @throws SystemException if a system exception occurred
10596             */
10597            public boolean containsAssetEntry(long pk, long assetEntryPK)
10598                    throws SystemException {
10599                    Object[] finderArgs = new Object[] { pk, assetEntryPK };
10600    
10601                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ASSETENTRY,
10602                                    finderArgs, this);
10603    
10604                    if (value == null) {
10605                            try {
10606                                    value = Boolean.valueOf(containsAssetEntry.contains(pk,
10607                                                            assetEntryPK));
10608                            }
10609                            catch (Exception e) {
10610                                    throw processException(e);
10611                            }
10612                            finally {
10613                                    if (value == null) {
10614                                            value = Boolean.FALSE;
10615                                    }
10616    
10617                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ASSETENTRY,
10618                                            finderArgs, value);
10619                            }
10620                    }
10621    
10622                    return value.booleanValue();
10623            }
10624    
10625            /**
10626             * Returns <code>true</code> if the asset category has any asset entries associated with it.
10627             *
10628             * @param pk the primary key of the asset category to check for associations with asset entries
10629             * @return <code>true</code> if the asset category has any asset entries associated with it; <code>false</code> otherwise
10630             * @throws SystemException if a system exception occurred
10631             */
10632            public boolean containsAssetEntries(long pk) throws SystemException {
10633                    if (getAssetEntriesSize(pk) > 0) {
10634                            return true;
10635                    }
10636                    else {
10637                            return false;
10638                    }
10639            }
10640    
10641            /**
10642             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10643             *
10644             * @param pk the primary key of the asset category
10645             * @param assetEntryPK the primary key of the asset entry
10646             * @throws SystemException if a system exception occurred
10647             */
10648            public void addAssetEntry(long pk, long assetEntryPK)
10649                    throws SystemException {
10650                    try {
10651                            addAssetEntry.add(pk, assetEntryPK);
10652                    }
10653                    catch (Exception e) {
10654                            throw processException(e);
10655                    }
10656                    finally {
10657                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10658                    }
10659            }
10660    
10661            /**
10662             * Adds an association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10663             *
10664             * @param pk the primary key of the asset category
10665             * @param assetEntry the asset entry
10666             * @throws SystemException if a system exception occurred
10667             */
10668            public void addAssetEntry(long pk,
10669                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
10670                    throws SystemException {
10671                    try {
10672                            addAssetEntry.add(pk, assetEntry.getPrimaryKey());
10673                    }
10674                    catch (Exception e) {
10675                            throw processException(e);
10676                    }
10677                    finally {
10678                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10679                    }
10680            }
10681    
10682            /**
10683             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10684             *
10685             * @param pk the primary key of the asset category
10686             * @param assetEntryPKs the primary keys of the asset entries
10687             * @throws SystemException if a system exception occurred
10688             */
10689            public void addAssetEntries(long pk, long[] assetEntryPKs)
10690                    throws SystemException {
10691                    try {
10692                            for (long assetEntryPK : assetEntryPKs) {
10693                                    addAssetEntry.add(pk, assetEntryPK);
10694                            }
10695                    }
10696                    catch (Exception e) {
10697                            throw processException(e);
10698                    }
10699                    finally {
10700                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10701                    }
10702            }
10703    
10704            /**
10705             * Adds an association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10706             *
10707             * @param pk the primary key of the asset category
10708             * @param assetEntries the asset entries
10709             * @throws SystemException if a system exception occurred
10710             */
10711            public void addAssetEntries(long pk,
10712                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
10713                    throws SystemException {
10714                    try {
10715                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
10716                                    addAssetEntry.add(pk, assetEntry.getPrimaryKey());
10717                            }
10718                    }
10719                    catch (Exception e) {
10720                            throw processException(e);
10721                    }
10722                    finally {
10723                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10724                    }
10725            }
10726    
10727            /**
10728             * Clears all associations between the asset category and its asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10729             *
10730             * @param pk the primary key of the asset category to clear the associated asset entries from
10731             * @throws SystemException if a system exception occurred
10732             */
10733            public void clearAssetEntries(long pk) throws SystemException {
10734                    try {
10735                            clearAssetEntries.clear(pk);
10736                    }
10737                    catch (Exception e) {
10738                            throw processException(e);
10739                    }
10740                    finally {
10741                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10742                    }
10743            }
10744    
10745            /**
10746             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10747             *
10748             * @param pk the primary key of the asset category
10749             * @param assetEntryPK the primary key of the asset entry
10750             * @throws SystemException if a system exception occurred
10751             */
10752            public void removeAssetEntry(long pk, long assetEntryPK)
10753                    throws SystemException {
10754                    try {
10755                            removeAssetEntry.remove(pk, assetEntryPK);
10756                    }
10757                    catch (Exception e) {
10758                            throw processException(e);
10759                    }
10760                    finally {
10761                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10762                    }
10763            }
10764    
10765            /**
10766             * Removes the association between the asset category and the asset entry. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10767             *
10768             * @param pk the primary key of the asset category
10769             * @param assetEntry the asset entry
10770             * @throws SystemException if a system exception occurred
10771             */
10772            public void removeAssetEntry(long pk,
10773                    com.liferay.portlet.asset.model.AssetEntry assetEntry)
10774                    throws SystemException {
10775                    try {
10776                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
10777                    }
10778                    catch (Exception e) {
10779                            throw processException(e);
10780                    }
10781                    finally {
10782                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10783                    }
10784            }
10785    
10786            /**
10787             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10788             *
10789             * @param pk the primary key of the asset category
10790             * @param assetEntryPKs the primary keys of the asset entries
10791             * @throws SystemException if a system exception occurred
10792             */
10793            public void removeAssetEntries(long pk, long[] assetEntryPKs)
10794                    throws SystemException {
10795                    try {
10796                            for (long assetEntryPK : assetEntryPKs) {
10797                                    removeAssetEntry.remove(pk, assetEntryPK);
10798                            }
10799                    }
10800                    catch (Exception e) {
10801                            throw processException(e);
10802                    }
10803                    finally {
10804                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10805                    }
10806            }
10807    
10808            /**
10809             * Removes the association between the asset category and the asset entries. Also notifies the appropriate model listeners and clears the mapping table finder cache.
10810             *
10811             * @param pk the primary key of the asset category
10812             * @param assetEntries the asset entries
10813             * @throws SystemException if a system exception occurred
10814             */
10815            public void removeAssetEntries(long pk,
10816                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
10817                    throws SystemException {
10818                    try {
10819                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
10820                                    removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
10821                            }
10822                    }
10823                    catch (Exception e) {
10824                            throw processException(e);
10825                    }
10826                    finally {
10827                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10828                    }
10829            }
10830    
10831            /**
10832             * 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.
10833             *
10834             * @param pk the primary key of the asset category
10835             * @param assetEntryPKs the primary keys of the asset entries to be associated with the asset category
10836             * @throws SystemException if a system exception occurred
10837             */
10838            public void setAssetEntries(long pk, long[] assetEntryPKs)
10839                    throws SystemException {
10840                    try {
10841                            Set<Long> assetEntryPKSet = SetUtil.fromArray(assetEntryPKs);
10842    
10843                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = getAssetEntries(pk);
10844    
10845                            for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
10846                                    if (!assetEntryPKSet.remove(assetEntry.getPrimaryKey())) {
10847                                            removeAssetEntry.remove(pk, assetEntry.getPrimaryKey());
10848                                    }
10849                            }
10850    
10851                            for (Long assetEntryPK : assetEntryPKSet) {
10852                                    addAssetEntry.add(pk, assetEntryPK);
10853                            }
10854                    }
10855                    catch (Exception e) {
10856                            throw processException(e);
10857                    }
10858                    finally {
10859                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10860                    }
10861            }
10862    
10863            /**
10864             * 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.
10865             *
10866             * @param pk the primary key of the asset category
10867             * @param assetEntries the asset entries to be associated with the asset category
10868             * @throws SystemException if a system exception occurred
10869             */
10870            public void setAssetEntries(long pk,
10871                    List<com.liferay.portlet.asset.model.AssetEntry> assetEntries)
10872                    throws SystemException {
10873                    try {
10874                            long[] assetEntryPKs = new long[assetEntries.size()];
10875    
10876                            for (int i = 0; i < assetEntries.size(); i++) {
10877                                    com.liferay.portlet.asset.model.AssetEntry assetEntry = assetEntries.get(i);
10878    
10879                                    assetEntryPKs[i] = assetEntry.getPrimaryKey();
10880                            }
10881    
10882                            setAssetEntries(pk, assetEntryPKs);
10883                    }
10884                    catch (Exception e) {
10885                            throw processException(e);
10886                    }
10887                    finally {
10888                            FinderCacheUtil.clearCache(AssetCategoryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME);
10889                    }
10890            }
10891    
10892            /**
10893             * Rebuilds the asset categories tree for the scope using the modified pre-order tree traversal algorithm.
10894             *
10895             * <p>
10896             * 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.
10897             * </p>
10898             *
10899             * @param groupId the ID of the scope
10900             * @param force whether to force the rebuild even if the tree is not stale
10901             */
10902            public void rebuildTree(long groupId, boolean force)
10903                    throws SystemException {
10904                    if (!rebuildTreeEnabled) {
10905                            return;
10906                    }
10907    
10908                    if (force || (countOrphanTreeNodes(groupId) > 0)) {
10909                            rebuildTree(groupId, 0, 1);
10910    
10911                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
10912                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
10913                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
10914                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
10915                    }
10916            }
10917    
10918            public void setRebuildTreeEnabled(boolean rebuildTreeEnabled) {
10919                    this.rebuildTreeEnabled = rebuildTreeEnabled;
10920            }
10921    
10922            protected long countOrphanTreeNodes(long groupId) throws SystemException {
10923                    Session session = null;
10924    
10925                    try {
10926                            session = openSession();
10927    
10928                            SQLQuery q = session.createSQLQuery(
10929                                            "SELECT COUNT(*) AS COUNT_VALUE FROM AssetCategory WHERE groupId = ? AND (leftCategoryId = 0 OR leftCategoryId IS NULL OR rightCategoryId = 0 OR rightCategoryId IS NULL)");
10930    
10931                            q.addScalar(COUNT_COLUMN_NAME,
10932                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
10933    
10934                            QueryPos qPos = QueryPos.getInstance(q);
10935    
10936                            qPos.add(groupId);
10937    
10938                            return (Long)q.uniqueResult();
10939                    }
10940                    catch (Exception e) {
10941                            throw processException(e);
10942                    }
10943                    finally {
10944                            closeSession(session);
10945                    }
10946            }
10947    
10948            protected void expandNoChildrenLeftCategoryId(long groupId,
10949                    long leftCategoryId, List<Long> childrenCategoryIds, long delta) {
10950                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?) WHERE (groupId = ?) AND (leftcategoryId > ?) AND (categoryId NOT IN (" +
10951                            StringUtil.merge(childrenCategoryIds) + "))";
10952    
10953                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10954                                    sql,
10955                                    new int[] {
10956                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
10957                                            java.sql.Types.BIGINT
10958                                    });
10959    
10960                    _sqlUpdate.update(new Object[] { delta, groupId, leftCategoryId });
10961            }
10962    
10963            protected void expandNoChildrenRightCategoryId(long groupId,
10964                    long rightCategoryId, List<Long> childrenCategoryIds, long delta) {
10965                    String sql = "UPDATE AssetCategory SET rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (rightcategoryId > ?) AND (categoryId NOT IN (" +
10966                            StringUtil.merge(childrenCategoryIds) + "))";
10967    
10968                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
10969                                    sql,
10970                                    new int[] {
10971                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
10972                                            java.sql.Types.BIGINT
10973                                    });
10974    
10975                    _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
10976            }
10977    
10978            protected void expandTree(AssetCategory assetCategory,
10979                    List<Long> childrenCategoryIds) throws SystemException {
10980                    if (!rebuildTreeEnabled) {
10981                            return;
10982                    }
10983    
10984                    long groupId = assetCategory.getGroupId();
10985    
10986                    long lastRightCategoryId = getLastRightCategoryId(groupId,
10987                                    assetCategory.getParentCategoryId());
10988    
10989                    long leftCategoryId = 2;
10990                    long rightCategoryId = 3;
10991    
10992                    if (lastRightCategoryId > 0) {
10993                            leftCategoryId = lastRightCategoryId + 1;
10994    
10995                            long childrenDistance = assetCategory.getRightCategoryId() -
10996                                    assetCategory.getLeftCategoryId();
10997    
10998                            if (childrenDistance > 1) {
10999                                    rightCategoryId = leftCategoryId + childrenDistance;
11000    
11001                                    updateChildrenTree(groupId, childrenCategoryIds,
11002                                            leftCategoryId - assetCategory.getLeftCategoryId());
11003    
11004                                    expandNoChildrenLeftCategoryId(groupId, lastRightCategoryId,
11005                                            childrenCategoryIds, childrenDistance + 1);
11006                                    expandNoChildrenRightCategoryId(groupId, lastRightCategoryId,
11007                                            childrenCategoryIds, childrenDistance + 1);
11008                            }
11009                            else {
11010                                    rightCategoryId = lastRightCategoryId + 2;
11011    
11012                                    expandTreeLeftCategoryId.expand(groupId, lastRightCategoryId);
11013                                    expandTreeRightCategoryId.expand(groupId, lastRightCategoryId);
11014                            }
11015    
11016                            CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11017                            EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11018                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11019                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11020                    }
11021    
11022                    assetCategory.setLeftCategoryId(leftCategoryId);
11023                    assetCategory.setRightCategoryId(rightCategoryId);
11024            }
11025    
11026            protected List<Long> getChildrenTreeCategoryIds(
11027                    AssetCategory parentAssetCategory) throws SystemException {
11028                    Session session = null;
11029    
11030                    try {
11031                            session = openSession();
11032    
11033                            SQLQuery q = session.createSQLQuery(
11034                                            "SELECT categoryId FROM AssetCategory WHERE (groupId = ?) AND (leftcategoryId BETWEEN ? AND ?)");
11035    
11036                            q.addScalar("CategoryId",
11037                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11038    
11039                            QueryPos qPos = QueryPos.getInstance(q);
11040    
11041                            qPos.add(parentAssetCategory.getGroupId());
11042                            qPos.add(parentAssetCategory.getLeftCategoryId() + 1);
11043                            qPos.add(parentAssetCategory.getRightCategoryId());
11044    
11045                            return q.list();
11046                    }
11047                    catch (Exception e) {
11048                            throw processException(e);
11049                    }
11050                    finally {
11051                            closeSession(session);
11052                    }
11053            }
11054    
11055            protected long getLastRightCategoryId(long groupId, long parentCategoryId)
11056                    throws SystemException {
11057                    Session session = null;
11058    
11059                    try {
11060                            session = openSession();
11061    
11062                            SQLQuery q = session.createSQLQuery(
11063                                            "SELECT rightCategoryId FROM AssetCategory WHERE (groupId = ?) AND (parentCategoryId = ?) ORDER BY rightCategoryId DESC");
11064    
11065                            q.addScalar("rightCategoryId",
11066                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11067    
11068                            QueryPos qPos = QueryPos.getInstance(q);
11069    
11070                            qPos.add(groupId);
11071                            qPos.add(parentCategoryId);
11072    
11073                            List<Long> list = (List<Long>)QueryUtil.list(q, getDialect(), 0, 1);
11074    
11075                            if (list.isEmpty()) {
11076                                    if (parentCategoryId > 0) {
11077                                            session.clear();
11078    
11079                                            AssetCategory parentAssetCategory = findByPrimaryKey(parentCategoryId);
11080    
11081                                            return parentAssetCategory.getLeftCategoryId();
11082                                    }
11083    
11084                                    return 0;
11085                            }
11086                            else {
11087                                    return list.get(0);
11088                            }
11089                    }
11090                    catch (Exception e) {
11091                            throw processException(e);
11092                    }
11093                    finally {
11094                            closeSession(session);
11095                    }
11096            }
11097    
11098            protected long rebuildTree(long groupId, long parentCategoryId,
11099                    long leftCategoryId) throws SystemException {
11100                    if (!rebuildTreeEnabled) {
11101                            return 0;
11102                    }
11103    
11104                    List<Long> categoryIds = null;
11105    
11106                    Session session = null;
11107    
11108                    try {
11109                            session = openSession();
11110    
11111                            SQLQuery q = session.createSQLQuery(
11112                                            "SELECT categoryId FROM AssetCategory WHERE groupId = ? AND parentCategoryId = ? ORDER BY categoryId ASC");
11113    
11114                            q.addScalar("categoryId",
11115                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
11116    
11117                            QueryPos qPos = QueryPos.getInstance(q);
11118    
11119                            qPos.add(groupId);
11120                            qPos.add(parentCategoryId);
11121    
11122                            categoryIds = q.list();
11123                    }
11124                    catch (Exception e) {
11125                            throw processException(e);
11126                    }
11127                    finally {
11128                            closeSession(session);
11129                    }
11130    
11131                    long rightCategoryId = leftCategoryId + 1;
11132    
11133                    for (long categoryId : categoryIds) {
11134                            rightCategoryId = rebuildTree(groupId, categoryId, rightCategoryId);
11135                    }
11136    
11137                    if (parentCategoryId > 0) {
11138                            updateTree.update(parentCategoryId, leftCategoryId, rightCategoryId);
11139                    }
11140    
11141                    return rightCategoryId + 1;
11142            }
11143    
11144            protected void shrinkTree(AssetCategory assetCategory) {
11145                    if (!rebuildTreeEnabled) {
11146                            return;
11147                    }
11148    
11149                    long groupId = assetCategory.getGroupId();
11150    
11151                    long leftCategoryId = assetCategory.getLeftCategoryId();
11152                    long rightCategoryId = assetCategory.getRightCategoryId();
11153    
11154                    long delta = (rightCategoryId - leftCategoryId) + 1;
11155    
11156                    shrinkTreeLeftCategoryId.shrink(groupId, rightCategoryId, delta);
11157                    shrinkTreeRightCategoryId.shrink(groupId, rightCategoryId, delta);
11158    
11159                    CacheRegistryUtil.clear(AssetCategoryImpl.class.getName());
11160                    EntityCacheUtil.clearCache(AssetCategoryImpl.class.getName());
11161                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
11162                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11163            }
11164    
11165            protected void updateChildrenTree(long groupId,
11166                    List<Long> childrenCategoryIds, long delta) {
11167                    String sql = "UPDATE AssetCategory SET leftcategoryId = (leftcategoryId + ?), rightcategoryId = (rightcategoryId + ?) WHERE (groupId = ?) AND (categoryId IN (" +
11168                            StringUtil.merge(childrenCategoryIds) + "))";
11169    
11170                    SqlUpdate _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11171                                    sql,
11172                                    new int[] {
11173                                            java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11174                                            java.sql.Types.BIGINT
11175                                    });
11176    
11177                    _sqlUpdate.update(new Object[] { delta, delta, groupId });
11178            }
11179    
11180            /**
11181             * Initializes the asset category persistence.
11182             */
11183            public void afterPropertiesSet() {
11184                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
11185                                            com.liferay.portal.util.PropsUtil.get(
11186                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetCategory")));
11187    
11188                    if (listenerClassNames.length > 0) {
11189                            try {
11190                                    List<ModelListener<AssetCategory>> listenersList = new ArrayList<ModelListener<AssetCategory>>();
11191    
11192                                    for (String listenerClassName : listenerClassNames) {
11193                                            Class<?> clazz = getClass();
11194    
11195                                            listenersList.add((ModelListener<AssetCategory>)InstanceFactory.newInstance(
11196                                                            clazz.getClassLoader(), listenerClassName));
11197                                    }
11198    
11199                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
11200                            }
11201                            catch (Exception e) {
11202                                    _log.error(e);
11203                            }
11204                    }
11205    
11206                    containsAssetEntry = new ContainsAssetEntry();
11207    
11208                    addAssetEntry = new AddAssetEntry();
11209                    clearAssetEntries = new ClearAssetEntries();
11210                    removeAssetEntry = new RemoveAssetEntry();
11211    
11212                    expandTreeLeftCategoryId = new ExpandTreeLeftCategoryId();
11213                    expandTreeRightCategoryId = new ExpandTreeRightCategoryId();
11214                    shrinkTreeLeftCategoryId = new ShrinkTreeLeftCategoryId();
11215                    shrinkTreeRightCategoryId = new ShrinkTreeRightCategoryId();
11216                    updateTree = new UpdateTree();
11217            }
11218    
11219            public void destroy() {
11220                    EntityCacheUtil.removeCache(AssetCategoryImpl.class.getName());
11221                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
11222                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
11223            }
11224    
11225            @BeanReference(type = AssetCategoryPersistence.class)
11226            protected AssetCategoryPersistence assetCategoryPersistence;
11227            @BeanReference(type = AssetCategoryPropertyPersistence.class)
11228            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
11229            @BeanReference(type = AssetEntryPersistence.class)
11230            protected AssetEntryPersistence assetEntryPersistence;
11231            @BeanReference(type = AssetLinkPersistence.class)
11232            protected AssetLinkPersistence assetLinkPersistence;
11233            @BeanReference(type = AssetTagPersistence.class)
11234            protected AssetTagPersistence assetTagPersistence;
11235            @BeanReference(type = AssetTagPropertyPersistence.class)
11236            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
11237            @BeanReference(type = AssetTagStatsPersistence.class)
11238            protected AssetTagStatsPersistence assetTagStatsPersistence;
11239            @BeanReference(type = AssetVocabularyPersistence.class)
11240            protected AssetVocabularyPersistence assetVocabularyPersistence;
11241            @BeanReference(type = ResourcePersistence.class)
11242            protected ResourcePersistence resourcePersistence;
11243            @BeanReference(type = UserPersistence.class)
11244            protected UserPersistence userPersistence;
11245            protected ContainsAssetEntry containsAssetEntry;
11246            protected AddAssetEntry addAssetEntry;
11247            protected ClearAssetEntries clearAssetEntries;
11248            protected RemoveAssetEntry removeAssetEntry;
11249    
11250            protected class ContainsAssetEntry {
11251                    protected ContainsAssetEntry() {
11252                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
11253                                            _SQL_CONTAINSASSETENTRY,
11254                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
11255                                            RowMapper.COUNT);
11256                    }
11257    
11258                    protected boolean contains(long categoryId, long entryId) {
11259                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
11260                                                    new Long(categoryId), new Long(entryId)
11261                                            });
11262    
11263                            if (results.size() > 0) {
11264                                    Integer count = results.get(0);
11265    
11266                                    if (count.intValue() > 0) {
11267                                            return true;
11268                                    }
11269                            }
11270    
11271                            return false;
11272                    }
11273    
11274                    private MappingSqlQuery<Integer> _mappingSqlQuery;
11275            }
11276    
11277            protected class AddAssetEntry {
11278                    protected AddAssetEntry() {
11279                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11280                                            "INSERT INTO AssetEntries_AssetCategories (categoryId, entryId) VALUES (?, ?)",
11281                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
11282                    }
11283    
11284                    protected void add(long categoryId, long entryId)
11285                            throws SystemException {
11286                            if (!containsAssetEntry.contains(categoryId, entryId)) {
11287                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
11288                                            assetEntryPersistence.getListeners();
11289    
11290                                    for (ModelListener<AssetCategory> listener : listeners) {
11291                                            listener.onBeforeAddAssociation(categoryId,
11292                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11293                                                    entryId);
11294                                    }
11295    
11296                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11297                                            listener.onBeforeAddAssociation(entryId,
11298                                                    AssetCategory.class.getName(), categoryId);
11299                                    }
11300    
11301                                    _sqlUpdate.update(new Object[] {
11302                                                    new Long(categoryId), new Long(entryId)
11303                                            });
11304    
11305                                    for (ModelListener<AssetCategory> listener : listeners) {
11306                                            listener.onAfterAddAssociation(categoryId,
11307                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11308                                                    entryId);
11309                                    }
11310    
11311                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11312                                            listener.onAfterAddAssociation(entryId,
11313                                                    AssetCategory.class.getName(), categoryId);
11314                                    }
11315                            }
11316                    }
11317    
11318                    private SqlUpdate _sqlUpdate;
11319            }
11320    
11321            protected class ClearAssetEntries {
11322                    protected ClearAssetEntries() {
11323                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11324                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ?",
11325                                            new int[] { java.sql.Types.BIGINT });
11326                    }
11327    
11328                    protected void clear(long categoryId) throws SystemException {
11329                            ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
11330                                    assetEntryPersistence.getListeners();
11331    
11332                            List<com.liferay.portlet.asset.model.AssetEntry> assetEntries = null;
11333    
11334                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
11335                                    assetEntries = getAssetEntries(categoryId);
11336    
11337                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11338                                            for (ModelListener<AssetCategory> listener : listeners) {
11339                                                    listener.onBeforeRemoveAssociation(categoryId,
11340                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11341                                                            assetEntry.getPrimaryKey());
11342                                            }
11343    
11344                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11345                                                    listener.onBeforeRemoveAssociation(assetEntry.getPrimaryKey(),
11346                                                            AssetCategory.class.getName(), categoryId);
11347                                            }
11348                                    }
11349                            }
11350    
11351                            _sqlUpdate.update(new Object[] { new Long(categoryId) });
11352    
11353                            if ((listeners.length > 0) || (assetEntryListeners.length > 0)) {
11354                                    for (com.liferay.portlet.asset.model.AssetEntry assetEntry : assetEntries) {
11355                                            for (ModelListener<AssetCategory> listener : listeners) {
11356                                                    listener.onAfterRemoveAssociation(categoryId,
11357                                                            com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11358                                                            assetEntry.getPrimaryKey());
11359                                            }
11360    
11361                                            for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11362                                                    listener.onAfterRemoveAssociation(assetEntry.getPrimaryKey(),
11363                                                            AssetCategory.class.getName(), categoryId);
11364                                            }
11365                                    }
11366                            }
11367                    }
11368    
11369                    private SqlUpdate _sqlUpdate;
11370            }
11371    
11372            protected class RemoveAssetEntry {
11373                    protected RemoveAssetEntry() {
11374                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11375                                            "DELETE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?",
11376                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
11377                    }
11378    
11379                    protected void remove(long categoryId, long entryId)
11380                            throws SystemException {
11381                            if (containsAssetEntry.contains(categoryId, entryId)) {
11382                                    ModelListener<com.liferay.portlet.asset.model.AssetEntry>[] assetEntryListeners =
11383                                            assetEntryPersistence.getListeners();
11384    
11385                                    for (ModelListener<AssetCategory> listener : listeners) {
11386                                            listener.onBeforeRemoveAssociation(categoryId,
11387                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11388                                                    entryId);
11389                                    }
11390    
11391                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11392                                            listener.onBeforeRemoveAssociation(entryId,
11393                                                    AssetCategory.class.getName(), categoryId);
11394                                    }
11395    
11396                                    _sqlUpdate.update(new Object[] {
11397                                                    new Long(categoryId), new Long(entryId)
11398                                            });
11399    
11400                                    for (ModelListener<AssetCategory> listener : listeners) {
11401                                            listener.onAfterRemoveAssociation(categoryId,
11402                                                    com.liferay.portlet.asset.model.AssetEntry.class.getName(),
11403                                                    entryId);
11404                                    }
11405    
11406                                    for (ModelListener<com.liferay.portlet.asset.model.AssetEntry> listener : assetEntryListeners) {
11407                                            listener.onAfterRemoveAssociation(entryId,
11408                                                    AssetCategory.class.getName(), categoryId);
11409                                    }
11410                            }
11411                    }
11412    
11413                    private SqlUpdate _sqlUpdate;
11414            }
11415    
11416            protected boolean rebuildTreeEnabled = true;
11417            protected ExpandTreeLeftCategoryId expandTreeLeftCategoryId;
11418            protected ExpandTreeRightCategoryId expandTreeRightCategoryId;
11419            protected ShrinkTreeLeftCategoryId shrinkTreeLeftCategoryId;
11420            protected ShrinkTreeRightCategoryId shrinkTreeRightCategoryId;
11421            protected UpdateTree updateTree;
11422    
11423            protected class ExpandTreeLeftCategoryId {
11424                    protected ExpandTreeLeftCategoryId() {
11425                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11426                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId + 2) WHERE (groupId = ?) AND (leftCategoryId > ?)",
11427                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
11428                    }
11429    
11430                    protected void expand(long groupId, long leftCategoryId) {
11431                            _sqlUpdate.update(new Object[] { groupId, leftCategoryId });
11432                    }
11433    
11434                    private SqlUpdate _sqlUpdate;
11435            }
11436    
11437            protected class ExpandTreeRightCategoryId {
11438                    protected ExpandTreeRightCategoryId() {
11439                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11440                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId + 2) WHERE (groupId = ?) AND (rightCategoryId > ?)",
11441                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
11442                    }
11443    
11444                    protected void expand(long groupId, long rightCategoryId) {
11445                            _sqlUpdate.update(new Object[] { groupId, rightCategoryId });
11446                    }
11447    
11448                    private SqlUpdate _sqlUpdate;
11449            }
11450    
11451            protected class ShrinkTreeLeftCategoryId {
11452                    protected ShrinkTreeLeftCategoryId() {
11453                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11454                                            "UPDATE AssetCategory SET leftCategoryId = (leftCategoryId - ?) WHERE (groupId = ?) AND (leftCategoryId > ?)",
11455                                            new int[] {
11456                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11457                                                    java.sql.Types.BIGINT
11458                                            });
11459                    }
11460    
11461                    protected void shrink(long groupId, long rightCategoryId, long delta) {
11462                            _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
11463                    }
11464    
11465                    private SqlUpdate _sqlUpdate;
11466            }
11467    
11468            protected class ShrinkTreeRightCategoryId {
11469                    protected ShrinkTreeRightCategoryId() {
11470                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11471                                            "UPDATE AssetCategory SET rightCategoryId = (rightCategoryId - ?) WHERE (groupId = ?) AND (rightCategoryId > ?)",
11472                                            new int[] {
11473                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11474                                                    java.sql.Types.BIGINT
11475                                            });
11476                    }
11477    
11478                    protected void shrink(long groupId, long rightCategoryId, long delta) {
11479                            _sqlUpdate.update(new Object[] { delta, groupId, rightCategoryId });
11480                    }
11481    
11482                    private SqlUpdate _sqlUpdate;
11483            }
11484    
11485            protected class UpdateTree {
11486                    protected UpdateTree() {
11487                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
11488                                            "UPDATE AssetCategory SET leftCategoryId = ?, rightCategoryId = ? WHERE categoryId = ?",
11489                                            new int[] {
11490                                                    java.sql.Types.BIGINT, java.sql.Types.BIGINT,
11491                                                    java.sql.Types.BIGINT
11492                                            });
11493                    }
11494    
11495                    protected void update(long categoryId, long leftCategoryId,
11496                            long rightCategoryId) {
11497                            _sqlUpdate.update(new Object[] {
11498                                            leftCategoryId, rightCategoryId, categoryId
11499                                    });
11500                    }
11501    
11502                    private SqlUpdate _sqlUpdate;
11503            }
11504    
11505            private static final String _SQL_SELECT_ASSETCATEGORY = "SELECT assetCategory FROM AssetCategory assetCategory";
11506            private static final String _SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT assetCategory FROM AssetCategory assetCategory WHERE ";
11507            private static final String _SQL_COUNT_ASSETCATEGORY = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory";
11508            private static final String _SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(assetCategory) FROM AssetCategory assetCategory WHERE ";
11509            private static final String _SQL_GETASSETENTRIES = "SELECT {AssetEntry.*} FROM AssetEntry INNER JOIN AssetEntries_AssetCategories ON (AssetEntries_AssetCategories.entryId = AssetEntry.entryId) WHERE (AssetEntries_AssetCategories.categoryId = ?)";
11510            private static final String _SQL_GETASSETENTRIESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ?";
11511            private static final String _SQL_CONTAINSASSETENTRY = "SELECT COUNT(*) AS COUNT_VALUE FROM AssetEntries_AssetCategories WHERE categoryId = ? AND entryId = ?";
11512            private static final String _FINDER_COLUMN_UUID_UUID_1 = "assetCategory.uuid IS NULL";
11513            private static final String _FINDER_COLUMN_UUID_UUID_2 = "assetCategory.uuid = ?";
11514            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?)";
11515            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "assetCategory.uuid IS NULL AND ";
11516            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "assetCategory.uuid = ? AND ";
11517            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(assetCategory.uuid IS NULL OR assetCategory.uuid = ?) AND ";
11518            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "assetCategory.groupId = ?";
11519            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "assetCategory.groupId = ?";
11520            private static final String _FINDER_COLUMN_PARENTCATEGORYID_PARENTCATEGORYID_2 =
11521                    "assetCategory.parentCategoryId = ?";
11522            private static final String _FINDER_COLUMN_VOCABULARYID_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11523            private static final String _FINDER_COLUMN_G_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
11524            private static final String _FINDER_COLUMN_G_V_GROUPID_5 = "(" +
11525                    _removeConjunction(_FINDER_COLUMN_G_V_GROUPID_2) + ")";
11526            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11527            private static final String _FINDER_COLUMN_G_V_VOCABULARYID_5 = "(" +
11528                    _removeConjunction(_FINDER_COLUMN_G_V_VOCABULARYID_2) + ")";
11529            private static final String _FINDER_COLUMN_P_N_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
11530            private static final String _FINDER_COLUMN_P_N_NAME_1 = "assetCategory.name IS NULL";
11531            private static final String _FINDER_COLUMN_P_N_NAME_2 = "assetCategory.name = ?";
11532            private static final String _FINDER_COLUMN_P_N_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?)";
11533            private static final String _FINDER_COLUMN_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
11534            private static final String _FINDER_COLUMN_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11535            private static final String _FINDER_COLUMN_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
11536            private static final String _FINDER_COLUMN_N_V_NAME_2 = "assetCategory.name = ? AND ";
11537            private static final String _FINDER_COLUMN_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
11538            private static final String _FINDER_COLUMN_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11539            private static final String _FINDER_COLUMN_G_P_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
11540            private static final String _FINDER_COLUMN_G_P_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
11541            private static final String _FINDER_COLUMN_G_P_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11542            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
11543            private static final String _FINDER_COLUMN_G_LIKEN_V_GROUPID_5 = "(" +
11544                    _removeConjunction(_FINDER_COLUMN_G_LIKEN_V_GROUPID_2) + ")";
11545            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_1 = "assetCategory.name LIKE NULL AND ";
11546            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_2 = "assetCategory.name LIKE ? AND ";
11547            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name LIKE ?) AND ";
11548            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_4 = "(" +
11549                    _removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_1) + ")";
11550            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_5 = "(" +
11551                    _removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_2) + ")";
11552            private static final String _FINDER_COLUMN_G_LIKEN_V_NAME_6 = "(" +
11553                    _removeConjunction(_FINDER_COLUMN_G_LIKEN_V_NAME_3) + ")";
11554            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11555            private static final String _FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_5 = "(" +
11556                    _removeConjunction(_FINDER_COLUMN_G_LIKEN_V_VOCABULARYID_2) + ")";
11557            private static final String _FINDER_COLUMN_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
11558            private static final String _FINDER_COLUMN_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
11559            private static final String _FINDER_COLUMN_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
11560            private static final String _FINDER_COLUMN_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
11561            private static final String _FINDER_COLUMN_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11562            private static final String _FINDER_COLUMN_G_P_N_V_GROUPID_2 = "assetCategory.groupId = ? AND ";
11563            private static final String _FINDER_COLUMN_G_P_N_V_PARENTCATEGORYID_2 = "assetCategory.parentCategoryId = ? AND ";
11564            private static final String _FINDER_COLUMN_G_P_N_V_NAME_1 = "assetCategory.name IS NULL AND ";
11565            private static final String _FINDER_COLUMN_G_P_N_V_NAME_2 = "assetCategory.name = ? AND ";
11566            private static final String _FINDER_COLUMN_G_P_N_V_NAME_3 = "(assetCategory.name IS NULL OR assetCategory.name = ?) AND ";
11567            private static final String _FINDER_COLUMN_G_P_N_V_VOCABULARYID_2 = "assetCategory.vocabularyId = ?";
11568    
11569            private static String _removeConjunction(String sql) {
11570                    int pos = sql.indexOf(" AND ");
11571    
11572                    if (pos != -1) {
11573                            sql = sql.substring(0, pos);
11574                    }
11575    
11576                    return sql;
11577            }
11578    
11579            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "assetCategory.categoryId";
11580            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_WHERE = "SELECT DISTINCT {assetCategory.*} FROM AssetCategory assetCategory WHERE ";
11581            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_1 =
11582                    "SELECT {AssetCategory.*} FROM (SELECT DISTINCT assetCategory.categoryId FROM AssetCategory assetCategory WHERE ";
11583            private static final String _FILTER_SQL_SELECT_ASSETCATEGORY_NO_INLINE_DISTINCT_WHERE_2 =
11584                    ") TEMP_TABLE INNER JOIN AssetCategory ON TEMP_TABLE.categoryId = AssetCategory.categoryId";
11585            private static final String _FILTER_SQL_COUNT_ASSETCATEGORY_WHERE = "SELECT COUNT(DISTINCT assetCategory.categoryId) AS COUNT_VALUE FROM AssetCategory assetCategory WHERE ";
11586            private static final String _FILTER_ENTITY_ALIAS = "assetCategory";
11587            private static final String _FILTER_ENTITY_TABLE = "AssetCategory";
11588            private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategory.";
11589            private static final String _ORDER_BY_ENTITY_TABLE = "AssetCategory.";
11590            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategory exists with the primary key ";
11591            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategory exists with the key {";
11592            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
11593            private static Log _log = LogFactoryUtil.getLog(AssetCategoryPersistenceImpl.class);
11594            private static AssetCategory _nullAssetCategory = new AssetCategoryImpl() {
11595                            @Override
11596                            public Object clone() {
11597                                    return this;
11598                            }
11599    
11600                            @Override
11601                            public CacheModel<AssetCategory> toCacheModel() {
11602                                    return _nullAssetCategoryCacheModel;
11603                            }
11604                    };
11605    
11606            private static CacheModel<AssetCategory> _nullAssetCategoryCacheModel = new CacheModel<AssetCategory>() {
11607                            public AssetCategory toEntityModel() {
11608                                    return _nullAssetCategory;
11609                            }
11610                    };
11611    }