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.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.Validator;
037    import com.liferay.portal.model.CacheModel;
038    import com.liferay.portal.model.ModelListener;
039    import com.liferay.portal.service.persistence.BatchSessionUtil;
040    import com.liferay.portal.service.persistence.ResourcePersistence;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
043    
044    import com.liferay.portlet.asset.NoSuchCategoryPropertyException;
045    import com.liferay.portlet.asset.model.AssetCategoryProperty;
046    import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyImpl;
047    import com.liferay.portlet.asset.model.impl.AssetCategoryPropertyModelImpl;
048    
049    import java.io.Serializable;
050    
051    import java.util.ArrayList;
052    import java.util.Collections;
053    import java.util.List;
054    
055    /**
056     * The persistence implementation for the asset category property service.
057     *
058     * <p>
059     * Caching information and settings can be found in <code>portal.properties</code>
060     * </p>
061     *
062     * @author Brian Wing Shun Chan
063     * @see AssetCategoryPropertyPersistence
064     * @see AssetCategoryPropertyUtil
065     * @generated
066     */
067    public class AssetCategoryPropertyPersistenceImpl extends BasePersistenceImpl<AssetCategoryProperty>
068            implements AssetCategoryPropertyPersistence {
069            /*
070             * NOTE FOR DEVELOPERS:
071             *
072             * Never modify or reference this class directly. Always use {@link AssetCategoryPropertyUtil} to access the asset category property persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
073             */
074            public static final String FINDER_CLASS_NAME_ENTITY = AssetCategoryPropertyImpl.class.getName();
075            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List1";
077            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
078                    ".List2";
079            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
080                    new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
081                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
082                            AssetCategoryPropertyImpl.class,
083                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
084                            new String[] {
085                                    Long.class.getName(),
086                                    
087                            "java.lang.Integer", "java.lang.Integer",
088                                    "com.liferay.portal.kernel.util.OrderByComparator"
089                            });
090            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
091                    new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
092                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
093                            AssetCategoryPropertyImpl.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
095                            new String[] { Long.class.getName() },
096                            AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK);
097            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
098                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
099                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
100                            new String[] { Long.class.getName() });
101            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID =
102                    new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
103                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
104                            AssetCategoryPropertyImpl.class,
105                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCategoryId",
106                            new String[] {
107                                    Long.class.getName(),
108                                    
109                            "java.lang.Integer", "java.lang.Integer",
110                                    "com.liferay.portal.kernel.util.OrderByComparator"
111                            });
112            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID =
113                    new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
114                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
115                            AssetCategoryPropertyImpl.class,
116                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCategoryId",
117                            new String[] { Long.class.getName() },
118                            AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK);
119            public static final FinderPath FINDER_PATH_COUNT_BY_CATEGORYID = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
120                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCategoryId",
122                            new String[] { Long.class.getName() });
123            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
124                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
125                            AssetCategoryPropertyImpl.class,
126                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_K",
127                            new String[] {
128                                    Long.class.getName(), String.class.getName(),
129                                    
130                            "java.lang.Integer", "java.lang.Integer",
131                                    "com.liferay.portal.kernel.util.OrderByComparator"
132                            });
133            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
134                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
135                            AssetCategoryPropertyImpl.class,
136                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_K",
137                            new String[] { Long.class.getName(), String.class.getName() },
138                            AssetCategoryPropertyModelImpl.COMPANYID_COLUMN_BITMASK |
139                            AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
140            public static final FinderPath FINDER_PATH_COUNT_BY_C_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
141                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
142                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_K",
143                            new String[] { Long.class.getName(), String.class.getName() });
144            public static final FinderPath FINDER_PATH_FETCH_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
145                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
146                            AssetCategoryPropertyImpl.class, FINDER_CLASS_NAME_ENTITY,
147                            "fetchByCA_K",
148                            new String[] { Long.class.getName(), String.class.getName() },
149                            AssetCategoryPropertyModelImpl.CATEGORYID_COLUMN_BITMASK |
150                            AssetCategoryPropertyModelImpl.KEY_COLUMN_BITMASK);
151            public static final FinderPath FINDER_PATH_COUNT_BY_CA_K = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
152                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCA_K",
154                            new String[] { Long.class.getName(), String.class.getName() });
155            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
156                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
157                            AssetCategoryPropertyImpl.class,
158                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
159            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
160                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED,
161                            AssetCategoryPropertyImpl.class,
162                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
163            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
164                            AssetCategoryPropertyModelImpl.FINDER_CACHE_ENABLED, Long.class,
165                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
166    
167            /**
168             * Caches the asset category property in the entity cache if it is enabled.
169             *
170             * @param assetCategoryProperty the asset category property
171             */
172            public void cacheResult(AssetCategoryProperty assetCategoryProperty) {
173                    EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
174                            AssetCategoryPropertyImpl.class,
175                            assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
176    
177                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
178                            new Object[] {
179                                    Long.valueOf(assetCategoryProperty.getCategoryId()),
180                                    
181                            assetCategoryProperty.getKey()
182                            }, assetCategoryProperty);
183    
184                    assetCategoryProperty.resetOriginalValues();
185            }
186    
187            /**
188             * Caches the asset category properties in the entity cache if it is enabled.
189             *
190             * @param assetCategoryProperties the asset category properties
191             */
192            public void cacheResult(List<AssetCategoryProperty> assetCategoryProperties) {
193                    for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
194                            if (EntityCacheUtil.getResult(
195                                                    AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
196                                                    AssetCategoryPropertyImpl.class,
197                                                    assetCategoryProperty.getPrimaryKey()) == null) {
198                                    cacheResult(assetCategoryProperty);
199                            }
200                            else {
201                                    assetCategoryProperty.resetOriginalValues();
202                            }
203                    }
204            }
205    
206            /**
207             * Clears the cache for all asset category properties.
208             *
209             * <p>
210             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
211             * </p>
212             */
213            @Override
214            public void clearCache() {
215                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
216                            CacheRegistryUtil.clear(AssetCategoryPropertyImpl.class.getName());
217                    }
218    
219                    EntityCacheUtil.clearCache(AssetCategoryPropertyImpl.class.getName());
220    
221                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
222                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
223                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
224            }
225    
226            /**
227             * Clears the cache for the asset category property.
228             *
229             * <p>
230             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
231             * </p>
232             */
233            @Override
234            public void clearCache(AssetCategoryProperty assetCategoryProperty) {
235                    EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
236                            AssetCategoryPropertyImpl.class,
237                            assetCategoryProperty.getPrimaryKey());
238    
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
241    
242                    clearUniqueFindersCache(assetCategoryProperty);
243            }
244    
245            @Override
246            public void clearCache(List<AssetCategoryProperty> assetCategoryProperties) {
247                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
248                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
249    
250                    for (AssetCategoryProperty assetCategoryProperty : assetCategoryProperties) {
251                            EntityCacheUtil.removeResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
252                                    AssetCategoryPropertyImpl.class,
253                                    assetCategoryProperty.getPrimaryKey());
254    
255                            clearUniqueFindersCache(assetCategoryProperty);
256                    }
257            }
258    
259            protected void cacheUniqueFindersCache(
260                    AssetCategoryProperty assetCategoryProperty) {
261                    if (assetCategoryProperty.isNew()) {
262                            Object[] args = new Object[] {
263                                            Long.valueOf(assetCategoryProperty.getCategoryId()),
264                                            
265                                            assetCategoryProperty.getKey()
266                                    };
267    
268                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
269                                    Long.valueOf(1));
270                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
271                                    assetCategoryProperty);
272                    }
273                    else {
274                            AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
275    
276                            if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
277                                            FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
278                                    Object[] args = new Object[] {
279                                                    Long.valueOf(assetCategoryProperty.getCategoryId()),
280                                                    
281                                                    assetCategoryProperty.getKey()
282                                            };
283    
284                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K, args,
285                                            Long.valueOf(1));
286                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K, args,
287                                            assetCategoryProperty);
288                            }
289                    }
290            }
291    
292            protected void clearUniqueFindersCache(
293                    AssetCategoryProperty assetCategoryProperty) {
294                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
295    
296                    Object[] args = new Object[] {
297                                    Long.valueOf(assetCategoryProperty.getCategoryId()),
298                                    
299                                    assetCategoryProperty.getKey()
300                            };
301    
302                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
303                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
304    
305                    if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
306                                    FINDER_PATH_FETCH_BY_CA_K.getColumnBitmask()) != 0) {
307                            args = new Object[] {
308                                            Long.valueOf(assetCategoryPropertyModelImpl.getOriginalCategoryId()),
309                                            
310                                            assetCategoryPropertyModelImpl.getOriginalKey()
311                                    };
312    
313                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CA_K, args);
314                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K, args);
315                    }
316            }
317    
318            /**
319             * Creates a new asset category property with the primary key. Does not add the asset category property to the database.
320             *
321             * @param categoryPropertyId the primary key for the new asset category property
322             * @return the new asset category property
323             */
324            public AssetCategoryProperty create(long categoryPropertyId) {
325                    AssetCategoryProperty assetCategoryProperty = new AssetCategoryPropertyImpl();
326    
327                    assetCategoryProperty.setNew(true);
328                    assetCategoryProperty.setPrimaryKey(categoryPropertyId);
329    
330                    return assetCategoryProperty;
331            }
332    
333            /**
334             * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners.
335             *
336             * @param categoryPropertyId the primary key of the asset category property
337             * @return the asset category property that was removed
338             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
339             * @throws SystemException if a system exception occurred
340             */
341            public AssetCategoryProperty remove(long categoryPropertyId)
342                    throws NoSuchCategoryPropertyException, SystemException {
343                    return remove(Long.valueOf(categoryPropertyId));
344            }
345    
346            /**
347             * Removes the asset category property with the primary key from the database. Also notifies the appropriate model listeners.
348             *
349             * @param primaryKey the primary key of the asset category property
350             * @return the asset category property that was removed
351             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
352             * @throws SystemException if a system exception occurred
353             */
354            @Override
355            public AssetCategoryProperty remove(Serializable primaryKey)
356                    throws NoSuchCategoryPropertyException, SystemException {
357                    Session session = null;
358    
359                    try {
360                            session = openSession();
361    
362                            AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
363                                            primaryKey);
364    
365                            if (assetCategoryProperty == null) {
366                                    if (_log.isWarnEnabled()) {
367                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
368                                    }
369    
370                                    throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
371                                            primaryKey);
372                            }
373    
374                            return remove(assetCategoryProperty);
375                    }
376                    catch (NoSuchCategoryPropertyException nsee) {
377                            throw nsee;
378                    }
379                    catch (Exception e) {
380                            throw processException(e);
381                    }
382                    finally {
383                            closeSession(session);
384                    }
385            }
386    
387            @Override
388            protected AssetCategoryProperty removeImpl(
389                    AssetCategoryProperty assetCategoryProperty) throws SystemException {
390                    assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
391    
392                    Session session = null;
393    
394                    try {
395                            session = openSession();
396    
397                            BatchSessionUtil.delete(session, assetCategoryProperty);
398                    }
399                    catch (Exception e) {
400                            throw processException(e);
401                    }
402                    finally {
403                            closeSession(session);
404                    }
405    
406                    clearCache(assetCategoryProperty);
407    
408                    return assetCategoryProperty;
409            }
410    
411            @Override
412            public AssetCategoryProperty updateImpl(
413                    com.liferay.portlet.asset.model.AssetCategoryProperty assetCategoryProperty,
414                    boolean merge) throws SystemException {
415                    assetCategoryProperty = toUnwrappedModel(assetCategoryProperty);
416    
417                    boolean isNew = assetCategoryProperty.isNew();
418    
419                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = (AssetCategoryPropertyModelImpl)assetCategoryProperty;
420    
421                    Session session = null;
422    
423                    try {
424                            session = openSession();
425    
426                            BatchSessionUtil.update(session, assetCategoryProperty, merge);
427    
428                            assetCategoryProperty.setNew(false);
429                    }
430                    catch (Exception e) {
431                            throw processException(e);
432                    }
433                    finally {
434                            closeSession(session);
435                    }
436    
437                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
438    
439                    if (isNew || !AssetCategoryPropertyModelImpl.COLUMN_BITMASK_ENABLED) {
440                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
441                    }
442    
443                    else {
444                            if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
445                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
446                                    Object[] args = new Object[] {
447                                                    Long.valueOf(assetCategoryPropertyModelImpl.getOriginalCompanyId())
448                                            };
449    
450                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
451                                            args);
452                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
453                                            args);
454    
455                                    args = new Object[] {
456                                                    Long.valueOf(assetCategoryPropertyModelImpl.getCompanyId())
457                                            };
458    
459                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
460                                            args);
461                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
462                                            args);
463                            }
464    
465                            if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
466                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID.getColumnBitmask()) != 0) {
467                                    Object[] args = new Object[] {
468                                                    Long.valueOf(assetCategoryPropertyModelImpl.getOriginalCategoryId())
469                                            };
470    
471                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
472                                            args);
473                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
474                                            args);
475    
476                                    args = new Object[] {
477                                                    Long.valueOf(assetCategoryPropertyModelImpl.getCategoryId())
478                                            };
479    
480                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORYID,
481                                            args);
482                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID,
483                                            args);
484                            }
485    
486                            if ((assetCategoryPropertyModelImpl.getColumnBitmask() &
487                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K.getColumnBitmask()) != 0) {
488                                    Object[] args = new Object[] {
489                                                    Long.valueOf(assetCategoryPropertyModelImpl.getOriginalCompanyId()),
490                                                    
491                                                    assetCategoryPropertyModelImpl.getOriginalKey()
492                                            };
493    
494                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
495                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
496                                            args);
497    
498                                    args = new Object[] {
499                                                    Long.valueOf(assetCategoryPropertyModelImpl.getCompanyId()),
500                                                    
501                                                    assetCategoryPropertyModelImpl.getKey()
502                                            };
503    
504                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_K, args);
505                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K,
506                                            args);
507                            }
508                    }
509    
510                    EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
511                            AssetCategoryPropertyImpl.class,
512                            assetCategoryProperty.getPrimaryKey(), assetCategoryProperty);
513    
514                    clearUniqueFindersCache(assetCategoryProperty);
515                    cacheUniqueFindersCache(assetCategoryProperty);
516    
517                    return assetCategoryProperty;
518            }
519    
520            protected AssetCategoryProperty toUnwrappedModel(
521                    AssetCategoryProperty assetCategoryProperty) {
522                    if (assetCategoryProperty instanceof AssetCategoryPropertyImpl) {
523                            return assetCategoryProperty;
524                    }
525    
526                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
527    
528                    assetCategoryPropertyImpl.setNew(assetCategoryProperty.isNew());
529                    assetCategoryPropertyImpl.setPrimaryKey(assetCategoryProperty.getPrimaryKey());
530    
531                    assetCategoryPropertyImpl.setCategoryPropertyId(assetCategoryProperty.getCategoryPropertyId());
532                    assetCategoryPropertyImpl.setCompanyId(assetCategoryProperty.getCompanyId());
533                    assetCategoryPropertyImpl.setUserId(assetCategoryProperty.getUserId());
534                    assetCategoryPropertyImpl.setUserName(assetCategoryProperty.getUserName());
535                    assetCategoryPropertyImpl.setCreateDate(assetCategoryProperty.getCreateDate());
536                    assetCategoryPropertyImpl.setModifiedDate(assetCategoryProperty.getModifiedDate());
537                    assetCategoryPropertyImpl.setCategoryId(assetCategoryProperty.getCategoryId());
538                    assetCategoryPropertyImpl.setKey(assetCategoryProperty.getKey());
539                    assetCategoryPropertyImpl.setValue(assetCategoryProperty.getValue());
540    
541                    return assetCategoryPropertyImpl;
542            }
543    
544            /**
545             * Returns the asset category property with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
546             *
547             * @param primaryKey the primary key of the asset category property
548             * @return the asset category property
549             * @throws com.liferay.portal.NoSuchModelException if a asset category property with the primary key could not be found
550             * @throws SystemException if a system exception occurred
551             */
552            @Override
553            public AssetCategoryProperty findByPrimaryKey(Serializable primaryKey)
554                    throws NoSuchModelException, SystemException {
555                    return findByPrimaryKey(((Long)primaryKey).longValue());
556            }
557    
558            /**
559             * Returns the asset category property with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchCategoryPropertyException} if it could not be found.
560             *
561             * @param categoryPropertyId the primary key of the asset category property
562             * @return the asset category property
563             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
564             * @throws SystemException if a system exception occurred
565             */
566            public AssetCategoryProperty findByPrimaryKey(long categoryPropertyId)
567                    throws NoSuchCategoryPropertyException, SystemException {
568                    AssetCategoryProperty assetCategoryProperty = fetchByPrimaryKey(categoryPropertyId);
569    
570                    if (assetCategoryProperty == null) {
571                            if (_log.isWarnEnabled()) {
572                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
573                                            categoryPropertyId);
574                            }
575    
576                            throw new NoSuchCategoryPropertyException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
577                                    categoryPropertyId);
578                    }
579    
580                    return assetCategoryProperty;
581            }
582    
583            /**
584             * Returns the asset category property with the primary key or returns <code>null</code> if it could not be found.
585             *
586             * @param primaryKey the primary key of the asset category property
587             * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found
588             * @throws SystemException if a system exception occurred
589             */
590            @Override
591            public AssetCategoryProperty fetchByPrimaryKey(Serializable primaryKey)
592                    throws SystemException {
593                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
594            }
595    
596            /**
597             * Returns the asset category property with the primary key or returns <code>null</code> if it could not be found.
598             *
599             * @param categoryPropertyId the primary key of the asset category property
600             * @return the asset category property, or <code>null</code> if a asset category property with the primary key could not be found
601             * @throws SystemException if a system exception occurred
602             */
603            public AssetCategoryProperty fetchByPrimaryKey(long categoryPropertyId)
604                    throws SystemException {
605                    AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)EntityCacheUtil.getResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
606                                    AssetCategoryPropertyImpl.class, categoryPropertyId);
607    
608                    if (assetCategoryProperty == _nullAssetCategoryProperty) {
609                            return null;
610                    }
611    
612                    if (assetCategoryProperty == null) {
613                            Session session = null;
614    
615                            boolean hasException = false;
616    
617                            try {
618                                    session = openSession();
619    
620                                    assetCategoryProperty = (AssetCategoryProperty)session.get(AssetCategoryPropertyImpl.class,
621                                                    Long.valueOf(categoryPropertyId));
622                            }
623                            catch (Exception e) {
624                                    hasException = true;
625    
626                                    throw processException(e);
627                            }
628                            finally {
629                                    if (assetCategoryProperty != null) {
630                                            cacheResult(assetCategoryProperty);
631                                    }
632                                    else if (!hasException) {
633                                            EntityCacheUtil.putResult(AssetCategoryPropertyModelImpl.ENTITY_CACHE_ENABLED,
634                                                    AssetCategoryPropertyImpl.class, categoryPropertyId,
635                                                    _nullAssetCategoryProperty);
636                                    }
637    
638                                    closeSession(session);
639                            }
640                    }
641    
642                    return assetCategoryProperty;
643            }
644    
645            /**
646             * Returns all the asset category properties where companyId = &#63;.
647             *
648             * @param companyId the company ID
649             * @return the matching asset category properties
650             * @throws SystemException if a system exception occurred
651             */
652            public List<AssetCategoryProperty> findByCompanyId(long companyId)
653                    throws SystemException {
654                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
655                            null);
656            }
657    
658            /**
659             * Returns a range of all the asset category properties where companyId = &#63;.
660             *
661             * <p>
662             * 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.
663             * </p>
664             *
665             * @param companyId the company ID
666             * @param start the lower bound of the range of asset category properties
667             * @param end the upper bound of the range of asset category properties (not inclusive)
668             * @return the range of matching asset category properties
669             * @throws SystemException if a system exception occurred
670             */
671            public List<AssetCategoryProperty> findByCompanyId(long companyId,
672                    int start, int end) throws SystemException {
673                    return findByCompanyId(companyId, start, end, null);
674            }
675    
676            /**
677             * Returns an ordered range of all the asset category properties where companyId = &#63;.
678             *
679             * <p>
680             * 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.
681             * </p>
682             *
683             * @param companyId the company ID
684             * @param start the lower bound of the range of asset category properties
685             * @param end the upper bound of the range of asset category properties (not inclusive)
686             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
687             * @return the ordered range of matching asset category properties
688             * @throws SystemException if a system exception occurred
689             */
690            public List<AssetCategoryProperty> findByCompanyId(long companyId,
691                    int start, int end, OrderByComparator orderByComparator)
692                    throws SystemException {
693                    FinderPath finderPath = null;
694                    Object[] finderArgs = null;
695    
696                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
697                                    (orderByComparator == null)) {
698                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
699                            finderArgs = new Object[] { companyId };
700                    }
701                    else {
702                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
703                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
704                    }
705    
706                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
707                                    finderArgs, this);
708    
709                    if ((list != null) && !list.isEmpty()) {
710                            for (AssetCategoryProperty assetCategoryProperty : list) {
711                                    if ((companyId != assetCategoryProperty.getCompanyId())) {
712                                            list = null;
713    
714                                            break;
715                                    }
716                            }
717                    }
718    
719                    if (list == null) {
720                            StringBundler query = null;
721    
722                            if (orderByComparator != null) {
723                                    query = new StringBundler(3 +
724                                                    (orderByComparator.getOrderByFields().length * 3));
725                            }
726                            else {
727                                    query = new StringBundler(3);
728                            }
729    
730                            query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
731    
732                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
733    
734                            if (orderByComparator != null) {
735                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
736                                            orderByComparator);
737                            }
738    
739                            else {
740                                    query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
741                            }
742    
743                            String sql = query.toString();
744    
745                            Session session = null;
746    
747                            try {
748                                    session = openSession();
749    
750                                    Query q = session.createQuery(sql);
751    
752                                    QueryPos qPos = QueryPos.getInstance(q);
753    
754                                    qPos.add(companyId);
755    
756                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
757                                                    getDialect(), start, end);
758                            }
759                            catch (Exception e) {
760                                    throw processException(e);
761                            }
762                            finally {
763                                    if (list == null) {
764                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
765                                    }
766                                    else {
767                                            cacheResult(list);
768    
769                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
770                                    }
771    
772                                    closeSession(session);
773                            }
774                    }
775    
776                    return list;
777            }
778    
779            /**
780             * Returns the first asset category property in the ordered set where companyId = &#63;.
781             *
782             * @param companyId the company ID
783             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
784             * @return the first matching asset category property
785             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
786             * @throws SystemException if a system exception occurred
787             */
788            public AssetCategoryProperty findByCompanyId_First(long companyId,
789                    OrderByComparator orderByComparator)
790                    throws NoSuchCategoryPropertyException, SystemException {
791                    AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_First(companyId,
792                                    orderByComparator);
793    
794                    if (assetCategoryProperty != null) {
795                            return assetCategoryProperty;
796                    }
797    
798                    StringBundler msg = new StringBundler(4);
799    
800                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
801    
802                    msg.append("companyId=");
803                    msg.append(companyId);
804    
805                    msg.append(StringPool.CLOSE_CURLY_BRACE);
806    
807                    throw new NoSuchCategoryPropertyException(msg.toString());
808            }
809    
810            /**
811             * Returns the first asset category property in the ordered set where companyId = &#63;.
812             *
813             * @param companyId the company ID
814             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
815             * @return the first matching asset category property, or <code>null</code> if a matching asset category property could not be found
816             * @throws SystemException if a system exception occurred
817             */
818            public AssetCategoryProperty fetchByCompanyId_First(long companyId,
819                    OrderByComparator orderByComparator) throws SystemException {
820                    List<AssetCategoryProperty> list = findByCompanyId(companyId, 0, 1,
821                                    orderByComparator);
822    
823                    if (!list.isEmpty()) {
824                            return list.get(0);
825                    }
826    
827                    return null;
828            }
829    
830            /**
831             * Returns the last asset category property in the ordered set where companyId = &#63;.
832             *
833             * @param companyId the company ID
834             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
835             * @return the last matching asset category property
836             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
837             * @throws SystemException if a system exception occurred
838             */
839            public AssetCategoryProperty findByCompanyId_Last(long companyId,
840                    OrderByComparator orderByComparator)
841                    throws NoSuchCategoryPropertyException, SystemException {
842                    AssetCategoryProperty assetCategoryProperty = fetchByCompanyId_Last(companyId,
843                                    orderByComparator);
844    
845                    if (assetCategoryProperty != null) {
846                            return assetCategoryProperty;
847                    }
848    
849                    StringBundler msg = new StringBundler(4);
850    
851                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
852    
853                    msg.append("companyId=");
854                    msg.append(companyId);
855    
856                    msg.append(StringPool.CLOSE_CURLY_BRACE);
857    
858                    throw new NoSuchCategoryPropertyException(msg.toString());
859            }
860    
861            /**
862             * Returns the last asset category property in the ordered set where companyId = &#63;.
863             *
864             * @param companyId the company ID
865             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
866             * @return the last matching asset category property, or <code>null</code> if a matching asset category property could not be found
867             * @throws SystemException if a system exception occurred
868             */
869            public AssetCategoryProperty fetchByCompanyId_Last(long companyId,
870                    OrderByComparator orderByComparator) throws SystemException {
871                    int count = countByCompanyId(companyId);
872    
873                    List<AssetCategoryProperty> list = findByCompanyId(companyId,
874                                    count - 1, count, orderByComparator);
875    
876                    if (!list.isEmpty()) {
877                            return list.get(0);
878                    }
879    
880                    return null;
881            }
882    
883            /**
884             * Returns the asset category properties before and after the current asset category property in the ordered set where companyId = &#63;.
885             *
886             * @param categoryPropertyId the primary key of the current asset category property
887             * @param companyId the company ID
888             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
889             * @return the previous, current, and next asset category property
890             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
891             * @throws SystemException if a system exception occurred
892             */
893            public AssetCategoryProperty[] findByCompanyId_PrevAndNext(
894                    long categoryPropertyId, long companyId,
895                    OrderByComparator orderByComparator)
896                    throws NoSuchCategoryPropertyException, SystemException {
897                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
898    
899                    Session session = null;
900    
901                    try {
902                            session = openSession();
903    
904                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
905    
906                            array[0] = getByCompanyId_PrevAndNext(session,
907                                            assetCategoryProperty, companyId, orderByComparator, true);
908    
909                            array[1] = assetCategoryProperty;
910    
911                            array[2] = getByCompanyId_PrevAndNext(session,
912                                            assetCategoryProperty, companyId, orderByComparator, false);
913    
914                            return array;
915                    }
916                    catch (Exception e) {
917                            throw processException(e);
918                    }
919                    finally {
920                            closeSession(session);
921                    }
922            }
923    
924            protected AssetCategoryProperty getByCompanyId_PrevAndNext(
925                    Session session, AssetCategoryProperty assetCategoryProperty,
926                    long companyId, OrderByComparator orderByComparator, boolean previous) {
927                    StringBundler query = null;
928    
929                    if (orderByComparator != null) {
930                            query = new StringBundler(6 +
931                                            (orderByComparator.getOrderByFields().length * 6));
932                    }
933                    else {
934                            query = new StringBundler(3);
935                    }
936    
937                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
938    
939                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
940    
941                    if (orderByComparator != null) {
942                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
943    
944                            if (orderByConditionFields.length > 0) {
945                                    query.append(WHERE_AND);
946                            }
947    
948                            for (int i = 0; i < orderByConditionFields.length; i++) {
949                                    query.append(_ORDER_BY_ENTITY_ALIAS);
950                                    query.append(orderByConditionFields[i]);
951    
952                                    if ((i + 1) < orderByConditionFields.length) {
953                                            if (orderByComparator.isAscending() ^ previous) {
954                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
955                                            }
956                                            else {
957                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
958                                            }
959                                    }
960                                    else {
961                                            if (orderByComparator.isAscending() ^ previous) {
962                                                    query.append(WHERE_GREATER_THAN);
963                                            }
964                                            else {
965                                                    query.append(WHERE_LESSER_THAN);
966                                            }
967                                    }
968                            }
969    
970                            query.append(ORDER_BY_CLAUSE);
971    
972                            String[] orderByFields = orderByComparator.getOrderByFields();
973    
974                            for (int i = 0; i < orderByFields.length; i++) {
975                                    query.append(_ORDER_BY_ENTITY_ALIAS);
976                                    query.append(orderByFields[i]);
977    
978                                    if ((i + 1) < orderByFields.length) {
979                                            if (orderByComparator.isAscending() ^ previous) {
980                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
981                                            }
982                                            else {
983                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
984                                            }
985                                    }
986                                    else {
987                                            if (orderByComparator.isAscending() ^ previous) {
988                                                    query.append(ORDER_BY_ASC);
989                                            }
990                                            else {
991                                                    query.append(ORDER_BY_DESC);
992                                            }
993                                    }
994                            }
995                    }
996    
997                    else {
998                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
999                    }
1000    
1001                    String sql = query.toString();
1002    
1003                    Query q = session.createQuery(sql);
1004    
1005                    q.setFirstResult(0);
1006                    q.setMaxResults(2);
1007    
1008                    QueryPos qPos = QueryPos.getInstance(q);
1009    
1010                    qPos.add(companyId);
1011    
1012                    if (orderByComparator != null) {
1013                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1014    
1015                            for (Object value : values) {
1016                                    qPos.add(value);
1017                            }
1018                    }
1019    
1020                    List<AssetCategoryProperty> list = q.list();
1021    
1022                    if (list.size() == 2) {
1023                            return list.get(1);
1024                    }
1025                    else {
1026                            return null;
1027                    }
1028            }
1029    
1030            /**
1031             * Returns all the asset category properties where categoryId = &#63;.
1032             *
1033             * @param categoryId the category ID
1034             * @return the matching asset category properties
1035             * @throws SystemException if a system exception occurred
1036             */
1037            public List<AssetCategoryProperty> findByCategoryId(long categoryId)
1038                    throws SystemException {
1039                    return findByCategoryId(categoryId, QueryUtil.ALL_POS,
1040                            QueryUtil.ALL_POS, null);
1041            }
1042    
1043            /**
1044             * Returns a range of all the asset category properties where categoryId = &#63;.
1045             *
1046             * <p>
1047             * 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.
1048             * </p>
1049             *
1050             * @param categoryId the category ID
1051             * @param start the lower bound of the range of asset category properties
1052             * @param end the upper bound of the range of asset category properties (not inclusive)
1053             * @return the range of matching asset category properties
1054             * @throws SystemException if a system exception occurred
1055             */
1056            public List<AssetCategoryProperty> findByCategoryId(long categoryId,
1057                    int start, int end) throws SystemException {
1058                    return findByCategoryId(categoryId, start, end, null);
1059            }
1060    
1061            /**
1062             * Returns an ordered range of all the asset category properties where categoryId = &#63;.
1063             *
1064             * <p>
1065             * 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.
1066             * </p>
1067             *
1068             * @param categoryId the category ID
1069             * @param start the lower bound of the range of asset category properties
1070             * @param end the upper bound of the range of asset category properties (not inclusive)
1071             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1072             * @return the ordered range of matching asset category properties
1073             * @throws SystemException if a system exception occurred
1074             */
1075            public List<AssetCategoryProperty> findByCategoryId(long categoryId,
1076                    int start, int end, OrderByComparator orderByComparator)
1077                    throws SystemException {
1078                    FinderPath finderPath = null;
1079                    Object[] finderArgs = null;
1080    
1081                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1082                                    (orderByComparator == null)) {
1083                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORYID;
1084                            finderArgs = new Object[] { categoryId };
1085                    }
1086                    else {
1087                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CATEGORYID;
1088                            finderArgs = new Object[] { categoryId, start, end, orderByComparator };
1089                    }
1090    
1091                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
1092                                    finderArgs, this);
1093    
1094                    if ((list != null) && !list.isEmpty()) {
1095                            for (AssetCategoryProperty assetCategoryProperty : list) {
1096                                    if ((categoryId != assetCategoryProperty.getCategoryId())) {
1097                                            list = null;
1098    
1099                                            break;
1100                                    }
1101                            }
1102                    }
1103    
1104                    if (list == null) {
1105                            StringBundler query = null;
1106    
1107                            if (orderByComparator != null) {
1108                                    query = new StringBundler(3 +
1109                                                    (orderByComparator.getOrderByFields().length * 3));
1110                            }
1111                            else {
1112                                    query = new StringBundler(3);
1113                            }
1114    
1115                            query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1116    
1117                            query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1118    
1119                            if (orderByComparator != null) {
1120                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1121                                            orderByComparator);
1122                            }
1123    
1124                            else {
1125                                    query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1126                            }
1127    
1128                            String sql = query.toString();
1129    
1130                            Session session = null;
1131    
1132                            try {
1133                                    session = openSession();
1134    
1135                                    Query q = session.createQuery(sql);
1136    
1137                                    QueryPos qPos = QueryPos.getInstance(q);
1138    
1139                                    qPos.add(categoryId);
1140    
1141                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1142                                                    getDialect(), start, end);
1143                            }
1144                            catch (Exception e) {
1145                                    throw processException(e);
1146                            }
1147                            finally {
1148                                    if (list == null) {
1149                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1150                                    }
1151                                    else {
1152                                            cacheResult(list);
1153    
1154                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1155                                    }
1156    
1157                                    closeSession(session);
1158                            }
1159                    }
1160    
1161                    return list;
1162            }
1163    
1164            /**
1165             * Returns the first asset category property in the ordered set where categoryId = &#63;.
1166             *
1167             * @param categoryId the category ID
1168             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1169             * @return the first matching asset category property
1170             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1171             * @throws SystemException if a system exception occurred
1172             */
1173            public AssetCategoryProperty findByCategoryId_First(long categoryId,
1174                    OrderByComparator orderByComparator)
1175                    throws NoSuchCategoryPropertyException, SystemException {
1176                    AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_First(categoryId,
1177                                    orderByComparator);
1178    
1179                    if (assetCategoryProperty != null) {
1180                            return assetCategoryProperty;
1181                    }
1182    
1183                    StringBundler msg = new StringBundler(4);
1184    
1185                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1186    
1187                    msg.append("categoryId=");
1188                    msg.append(categoryId);
1189    
1190                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1191    
1192                    throw new NoSuchCategoryPropertyException(msg.toString());
1193            }
1194    
1195            /**
1196             * Returns the first asset category property in the ordered set where categoryId = &#63;.
1197             *
1198             * @param categoryId the category ID
1199             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1200             * @return the first matching asset category property, or <code>null</code> if a matching asset category property could not be found
1201             * @throws SystemException if a system exception occurred
1202             */
1203            public AssetCategoryProperty fetchByCategoryId_First(long categoryId,
1204                    OrderByComparator orderByComparator) throws SystemException {
1205                    List<AssetCategoryProperty> list = findByCategoryId(categoryId, 0, 1,
1206                                    orderByComparator);
1207    
1208                    if (!list.isEmpty()) {
1209                            return list.get(0);
1210                    }
1211    
1212                    return null;
1213            }
1214    
1215            /**
1216             * Returns the last asset category property in the ordered set where categoryId = &#63;.
1217             *
1218             * @param categoryId the category ID
1219             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1220             * @return the last matching asset category property
1221             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1222             * @throws SystemException if a system exception occurred
1223             */
1224            public AssetCategoryProperty findByCategoryId_Last(long categoryId,
1225                    OrderByComparator orderByComparator)
1226                    throws NoSuchCategoryPropertyException, SystemException {
1227                    AssetCategoryProperty assetCategoryProperty = fetchByCategoryId_Last(categoryId,
1228                                    orderByComparator);
1229    
1230                    if (assetCategoryProperty != null) {
1231                            return assetCategoryProperty;
1232                    }
1233    
1234                    StringBundler msg = new StringBundler(4);
1235    
1236                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1237    
1238                    msg.append("categoryId=");
1239                    msg.append(categoryId);
1240    
1241                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1242    
1243                    throw new NoSuchCategoryPropertyException(msg.toString());
1244            }
1245    
1246            /**
1247             * Returns the last asset category property in the ordered set where categoryId = &#63;.
1248             *
1249             * @param categoryId the category ID
1250             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1251             * @return the last matching asset category property, or <code>null</code> if a matching asset category property could not be found
1252             * @throws SystemException if a system exception occurred
1253             */
1254            public AssetCategoryProperty fetchByCategoryId_Last(long categoryId,
1255                    OrderByComparator orderByComparator) throws SystemException {
1256                    int count = countByCategoryId(categoryId);
1257    
1258                    List<AssetCategoryProperty> list = findByCategoryId(categoryId,
1259                                    count - 1, count, orderByComparator);
1260    
1261                    if (!list.isEmpty()) {
1262                            return list.get(0);
1263                    }
1264    
1265                    return null;
1266            }
1267    
1268            /**
1269             * Returns the asset category properties before and after the current asset category property in the ordered set where categoryId = &#63;.
1270             *
1271             * @param categoryPropertyId the primary key of the current asset category property
1272             * @param categoryId the category ID
1273             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1274             * @return the previous, current, and next asset category property
1275             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
1276             * @throws SystemException if a system exception occurred
1277             */
1278            public AssetCategoryProperty[] findByCategoryId_PrevAndNext(
1279                    long categoryPropertyId, long categoryId,
1280                    OrderByComparator orderByComparator)
1281                    throws NoSuchCategoryPropertyException, SystemException {
1282                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1283    
1284                    Session session = null;
1285    
1286                    try {
1287                            session = openSession();
1288    
1289                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1290    
1291                            array[0] = getByCategoryId_PrevAndNext(session,
1292                                            assetCategoryProperty, categoryId, orderByComparator, true);
1293    
1294                            array[1] = assetCategoryProperty;
1295    
1296                            array[2] = getByCategoryId_PrevAndNext(session,
1297                                            assetCategoryProperty, categoryId, orderByComparator, false);
1298    
1299                            return array;
1300                    }
1301                    catch (Exception e) {
1302                            throw processException(e);
1303                    }
1304                    finally {
1305                            closeSession(session);
1306                    }
1307            }
1308    
1309            protected AssetCategoryProperty getByCategoryId_PrevAndNext(
1310                    Session session, AssetCategoryProperty assetCategoryProperty,
1311                    long categoryId, OrderByComparator orderByComparator, boolean previous) {
1312                    StringBundler query = null;
1313    
1314                    if (orderByComparator != null) {
1315                            query = new StringBundler(6 +
1316                                            (orderByComparator.getOrderByFields().length * 6));
1317                    }
1318                    else {
1319                            query = new StringBundler(3);
1320                    }
1321    
1322                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1323    
1324                    query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
1325    
1326                    if (orderByComparator != null) {
1327                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1328    
1329                            if (orderByConditionFields.length > 0) {
1330                                    query.append(WHERE_AND);
1331                            }
1332    
1333                            for (int i = 0; i < orderByConditionFields.length; i++) {
1334                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1335                                    query.append(orderByConditionFields[i]);
1336    
1337                                    if ((i + 1) < orderByConditionFields.length) {
1338                                            if (orderByComparator.isAscending() ^ previous) {
1339                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1340                                            }
1341                                            else {
1342                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1343                                            }
1344                                    }
1345                                    else {
1346                                            if (orderByComparator.isAscending() ^ previous) {
1347                                                    query.append(WHERE_GREATER_THAN);
1348                                            }
1349                                            else {
1350                                                    query.append(WHERE_LESSER_THAN);
1351                                            }
1352                                    }
1353                            }
1354    
1355                            query.append(ORDER_BY_CLAUSE);
1356    
1357                            String[] orderByFields = orderByComparator.getOrderByFields();
1358    
1359                            for (int i = 0; i < orderByFields.length; i++) {
1360                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1361                                    query.append(orderByFields[i]);
1362    
1363                                    if ((i + 1) < orderByFields.length) {
1364                                            if (orderByComparator.isAscending() ^ previous) {
1365                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1366                                            }
1367                                            else {
1368                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1369                                            }
1370                                    }
1371                                    else {
1372                                            if (orderByComparator.isAscending() ^ previous) {
1373                                                    query.append(ORDER_BY_ASC);
1374                                            }
1375                                            else {
1376                                                    query.append(ORDER_BY_DESC);
1377                                            }
1378                                    }
1379                            }
1380                    }
1381    
1382                    else {
1383                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1384                    }
1385    
1386                    String sql = query.toString();
1387    
1388                    Query q = session.createQuery(sql);
1389    
1390                    q.setFirstResult(0);
1391                    q.setMaxResults(2);
1392    
1393                    QueryPos qPos = QueryPos.getInstance(q);
1394    
1395                    qPos.add(categoryId);
1396    
1397                    if (orderByComparator != null) {
1398                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1399    
1400                            for (Object value : values) {
1401                                    qPos.add(value);
1402                            }
1403                    }
1404    
1405                    List<AssetCategoryProperty> list = q.list();
1406    
1407                    if (list.size() == 2) {
1408                            return list.get(1);
1409                    }
1410                    else {
1411                            return null;
1412                    }
1413            }
1414    
1415            /**
1416             * Returns all the asset category properties where companyId = &#63; and key = &#63;.
1417             *
1418             * @param companyId the company ID
1419             * @param key the key
1420             * @return the matching asset category properties
1421             * @throws SystemException if a system exception occurred
1422             */
1423            public List<AssetCategoryProperty> findByC_K(long companyId, String key)
1424                    throws SystemException {
1425                    return findByC_K(companyId, key, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1426                            null);
1427            }
1428    
1429            /**
1430             * Returns a range of all the asset category properties where companyId = &#63; and key = &#63;.
1431             *
1432             * <p>
1433             * 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.
1434             * </p>
1435             *
1436             * @param companyId the company ID
1437             * @param key the key
1438             * @param start the lower bound of the range of asset category properties
1439             * @param end the upper bound of the range of asset category properties (not inclusive)
1440             * @return the range of matching asset category properties
1441             * @throws SystemException if a system exception occurred
1442             */
1443            public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1444                    int start, int end) throws SystemException {
1445                    return findByC_K(companyId, key, start, end, null);
1446            }
1447    
1448            /**
1449             * Returns an ordered range of all the asset category properties where companyId = &#63; and key = &#63;.
1450             *
1451             * <p>
1452             * 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.
1453             * </p>
1454             *
1455             * @param companyId the company ID
1456             * @param key the key
1457             * @param start the lower bound of the range of asset category properties
1458             * @param end the upper bound of the range of asset category properties (not inclusive)
1459             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1460             * @return the ordered range of matching asset category properties
1461             * @throws SystemException if a system exception occurred
1462             */
1463            public List<AssetCategoryProperty> findByC_K(long companyId, String key,
1464                    int start, int end, OrderByComparator orderByComparator)
1465                    throws SystemException {
1466                    FinderPath finderPath = null;
1467                    Object[] finderArgs = null;
1468    
1469                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1470                                    (orderByComparator == null)) {
1471                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_K;
1472                            finderArgs = new Object[] { companyId, key };
1473                    }
1474                    else {
1475                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_K;
1476                            finderArgs = new Object[] {
1477                                            companyId, key,
1478                                            
1479                                            start, end, orderByComparator
1480                                    };
1481                    }
1482    
1483                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
1484                                    finderArgs, this);
1485    
1486                    if ((list != null) && !list.isEmpty()) {
1487                            for (AssetCategoryProperty assetCategoryProperty : list) {
1488                                    if ((companyId != assetCategoryProperty.getCompanyId()) ||
1489                                                    !Validator.equals(key, assetCategoryProperty.getKey())) {
1490                                            list = null;
1491    
1492                                            break;
1493                                    }
1494                            }
1495                    }
1496    
1497                    if (list == null) {
1498                            StringBundler query = null;
1499    
1500                            if (orderByComparator != null) {
1501                                    query = new StringBundler(4 +
1502                                                    (orderByComparator.getOrderByFields().length * 3));
1503                            }
1504                            else {
1505                                    query = new StringBundler(4);
1506                            }
1507    
1508                            query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1509    
1510                            query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1511    
1512                            if (key == null) {
1513                                    query.append(_FINDER_COLUMN_C_K_KEY_1);
1514                            }
1515                            else {
1516                                    if (key.equals(StringPool.BLANK)) {
1517                                            query.append(_FINDER_COLUMN_C_K_KEY_3);
1518                                    }
1519                                    else {
1520                                            query.append(_FINDER_COLUMN_C_K_KEY_2);
1521                                    }
1522                            }
1523    
1524                            if (orderByComparator != null) {
1525                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1526                                            orderByComparator);
1527                            }
1528    
1529                            else {
1530                                    query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1531                            }
1532    
1533                            String sql = query.toString();
1534    
1535                            Session session = null;
1536    
1537                            try {
1538                                    session = openSession();
1539    
1540                                    Query q = session.createQuery(sql);
1541    
1542                                    QueryPos qPos = QueryPos.getInstance(q);
1543    
1544                                    qPos.add(companyId);
1545    
1546                                    if (key != null) {
1547                                            qPos.add(key);
1548                                    }
1549    
1550                                    list = (List<AssetCategoryProperty>)QueryUtil.list(q,
1551                                                    getDialect(), start, end);
1552                            }
1553                            catch (Exception e) {
1554                                    throw processException(e);
1555                            }
1556                            finally {
1557                                    if (list == null) {
1558                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1559                                    }
1560                                    else {
1561                                            cacheResult(list);
1562    
1563                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1564                                    }
1565    
1566                                    closeSession(session);
1567                            }
1568                    }
1569    
1570                    return list;
1571            }
1572    
1573            /**
1574             * Returns the first asset category property in the ordered set where companyId = &#63; and key = &#63;.
1575             *
1576             * @param companyId the company ID
1577             * @param key the key
1578             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1579             * @return the first matching asset category property
1580             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1581             * @throws SystemException if a system exception occurred
1582             */
1583            public AssetCategoryProperty findByC_K_First(long companyId, String key,
1584                    OrderByComparator orderByComparator)
1585                    throws NoSuchCategoryPropertyException, SystemException {
1586                    AssetCategoryProperty assetCategoryProperty = fetchByC_K_First(companyId,
1587                                    key, orderByComparator);
1588    
1589                    if (assetCategoryProperty != null) {
1590                            return assetCategoryProperty;
1591                    }
1592    
1593                    StringBundler msg = new StringBundler(6);
1594    
1595                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1596    
1597                    msg.append("companyId=");
1598                    msg.append(companyId);
1599    
1600                    msg.append(", key=");
1601                    msg.append(key);
1602    
1603                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1604    
1605                    throw new NoSuchCategoryPropertyException(msg.toString());
1606            }
1607    
1608            /**
1609             * Returns the first asset category property in the ordered set where companyId = &#63; and key = &#63;.
1610             *
1611             * @param companyId the company ID
1612             * @param key the key
1613             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1614             * @return the first matching asset category property, or <code>null</code> if a matching asset category property could not be found
1615             * @throws SystemException if a system exception occurred
1616             */
1617            public AssetCategoryProperty fetchByC_K_First(long companyId, String key,
1618                    OrderByComparator orderByComparator) throws SystemException {
1619                    List<AssetCategoryProperty> list = findByC_K(companyId, key, 0, 1,
1620                                    orderByComparator);
1621    
1622                    if (!list.isEmpty()) {
1623                            return list.get(0);
1624                    }
1625    
1626                    return null;
1627            }
1628    
1629            /**
1630             * Returns the last asset category property in the ordered set where companyId = &#63; and key = &#63;.
1631             *
1632             * @param companyId the company ID
1633             * @param key the key
1634             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1635             * @return the last matching asset category property
1636             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1637             * @throws SystemException if a system exception occurred
1638             */
1639            public AssetCategoryProperty findByC_K_Last(long companyId, String key,
1640                    OrderByComparator orderByComparator)
1641                    throws NoSuchCategoryPropertyException, SystemException {
1642                    AssetCategoryProperty assetCategoryProperty = fetchByC_K_Last(companyId,
1643                                    key, orderByComparator);
1644    
1645                    if (assetCategoryProperty != null) {
1646                            return assetCategoryProperty;
1647                    }
1648    
1649                    StringBundler msg = new StringBundler(6);
1650    
1651                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1652    
1653                    msg.append("companyId=");
1654                    msg.append(companyId);
1655    
1656                    msg.append(", key=");
1657                    msg.append(key);
1658    
1659                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1660    
1661                    throw new NoSuchCategoryPropertyException(msg.toString());
1662            }
1663    
1664            /**
1665             * Returns the last asset category property in the ordered set where companyId = &#63; and key = &#63;.
1666             *
1667             * @param companyId the company ID
1668             * @param key the key
1669             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1670             * @return the last matching asset category property, or <code>null</code> if a matching asset category property could not be found
1671             * @throws SystemException if a system exception occurred
1672             */
1673            public AssetCategoryProperty fetchByC_K_Last(long companyId, String key,
1674                    OrderByComparator orderByComparator) throws SystemException {
1675                    int count = countByC_K(companyId, key);
1676    
1677                    List<AssetCategoryProperty> list = findByC_K(companyId, key, count - 1,
1678                                    count, orderByComparator);
1679    
1680                    if (!list.isEmpty()) {
1681                            return list.get(0);
1682                    }
1683    
1684                    return null;
1685            }
1686    
1687            /**
1688             * Returns the asset category properties before and after the current asset category property in the ordered set where companyId = &#63; and key = &#63;.
1689             *
1690             * @param categoryPropertyId the primary key of the current asset category property
1691             * @param companyId the company ID
1692             * @param key the key
1693             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1694             * @return the previous, current, and next asset category property
1695             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a asset category property with the primary key could not be found
1696             * @throws SystemException if a system exception occurred
1697             */
1698            public AssetCategoryProperty[] findByC_K_PrevAndNext(
1699                    long categoryPropertyId, long companyId, String key,
1700                    OrderByComparator orderByComparator)
1701                    throws NoSuchCategoryPropertyException, SystemException {
1702                    AssetCategoryProperty assetCategoryProperty = findByPrimaryKey(categoryPropertyId);
1703    
1704                    Session session = null;
1705    
1706                    try {
1707                            session = openSession();
1708    
1709                            AssetCategoryProperty[] array = new AssetCategoryPropertyImpl[3];
1710    
1711                            array[0] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1712                                            companyId, key, orderByComparator, true);
1713    
1714                            array[1] = assetCategoryProperty;
1715    
1716                            array[2] = getByC_K_PrevAndNext(session, assetCategoryProperty,
1717                                            companyId, key, orderByComparator, false);
1718    
1719                            return array;
1720                    }
1721                    catch (Exception e) {
1722                            throw processException(e);
1723                    }
1724                    finally {
1725                            closeSession(session);
1726                    }
1727            }
1728    
1729            protected AssetCategoryProperty getByC_K_PrevAndNext(Session session,
1730                    AssetCategoryProperty assetCategoryProperty, long companyId,
1731                    String key, OrderByComparator orderByComparator, boolean previous) {
1732                    StringBundler query = null;
1733    
1734                    if (orderByComparator != null) {
1735                            query = new StringBundler(6 +
1736                                            (orderByComparator.getOrderByFields().length * 6));
1737                    }
1738                    else {
1739                            query = new StringBundler(3);
1740                    }
1741    
1742                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1743    
1744                    query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
1745    
1746                    if (key == null) {
1747                            query.append(_FINDER_COLUMN_C_K_KEY_1);
1748                    }
1749                    else {
1750                            if (key.equals(StringPool.BLANK)) {
1751                                    query.append(_FINDER_COLUMN_C_K_KEY_3);
1752                            }
1753                            else {
1754                                    query.append(_FINDER_COLUMN_C_K_KEY_2);
1755                            }
1756                    }
1757    
1758                    if (orderByComparator != null) {
1759                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1760    
1761                            if (orderByConditionFields.length > 0) {
1762                                    query.append(WHERE_AND);
1763                            }
1764    
1765                            for (int i = 0; i < orderByConditionFields.length; i++) {
1766                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1767                                    query.append(orderByConditionFields[i]);
1768    
1769                                    if ((i + 1) < orderByConditionFields.length) {
1770                                            if (orderByComparator.isAscending() ^ previous) {
1771                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1772                                            }
1773                                            else {
1774                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1775                                            }
1776                                    }
1777                                    else {
1778                                            if (orderByComparator.isAscending() ^ previous) {
1779                                                    query.append(WHERE_GREATER_THAN);
1780                                            }
1781                                            else {
1782                                                    query.append(WHERE_LESSER_THAN);
1783                                            }
1784                                    }
1785                            }
1786    
1787                            query.append(ORDER_BY_CLAUSE);
1788    
1789                            String[] orderByFields = orderByComparator.getOrderByFields();
1790    
1791                            for (int i = 0; i < orderByFields.length; i++) {
1792                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1793                                    query.append(orderByFields[i]);
1794    
1795                                    if ((i + 1) < orderByFields.length) {
1796                                            if (orderByComparator.isAscending() ^ previous) {
1797                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1798                                            }
1799                                            else {
1800                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1801                                            }
1802                                    }
1803                                    else {
1804                                            if (orderByComparator.isAscending() ^ previous) {
1805                                                    query.append(ORDER_BY_ASC);
1806                                            }
1807                                            else {
1808                                                    query.append(ORDER_BY_DESC);
1809                                            }
1810                                    }
1811                            }
1812                    }
1813    
1814                    else {
1815                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1816                    }
1817    
1818                    String sql = query.toString();
1819    
1820                    Query q = session.createQuery(sql);
1821    
1822                    q.setFirstResult(0);
1823                    q.setMaxResults(2);
1824    
1825                    QueryPos qPos = QueryPos.getInstance(q);
1826    
1827                    qPos.add(companyId);
1828    
1829                    if (key != null) {
1830                            qPos.add(key);
1831                    }
1832    
1833                    if (orderByComparator != null) {
1834                            Object[] values = orderByComparator.getOrderByConditionValues(assetCategoryProperty);
1835    
1836                            for (Object value : values) {
1837                                    qPos.add(value);
1838                            }
1839                    }
1840    
1841                    List<AssetCategoryProperty> list = q.list();
1842    
1843                    if (list.size() == 2) {
1844                            return list.get(1);
1845                    }
1846                    else {
1847                            return null;
1848                    }
1849            }
1850    
1851            /**
1852             * Returns the asset category property where categoryId = &#63; and key = &#63; or throws a {@link com.liferay.portlet.asset.NoSuchCategoryPropertyException} if it could not be found.
1853             *
1854             * @param categoryId the category ID
1855             * @param key the key
1856             * @return the matching asset category property
1857             * @throws com.liferay.portlet.asset.NoSuchCategoryPropertyException if a matching asset category property could not be found
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public AssetCategoryProperty findByCA_K(long categoryId, String key)
1861                    throws NoSuchCategoryPropertyException, SystemException {
1862                    AssetCategoryProperty assetCategoryProperty = fetchByCA_K(categoryId,
1863                                    key);
1864    
1865                    if (assetCategoryProperty == null) {
1866                            StringBundler msg = new StringBundler(6);
1867    
1868                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1869    
1870                            msg.append("categoryId=");
1871                            msg.append(categoryId);
1872    
1873                            msg.append(", key=");
1874                            msg.append(key);
1875    
1876                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1877    
1878                            if (_log.isWarnEnabled()) {
1879                                    _log.warn(msg.toString());
1880                            }
1881    
1882                            throw new NoSuchCategoryPropertyException(msg.toString());
1883                    }
1884    
1885                    return assetCategoryProperty;
1886            }
1887    
1888            /**
1889             * Returns the asset category property where categoryId = &#63; and key = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1890             *
1891             * @param categoryId the category ID
1892             * @param key the key
1893             * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found
1894             * @throws SystemException if a system exception occurred
1895             */
1896            public AssetCategoryProperty fetchByCA_K(long categoryId, String key)
1897                    throws SystemException {
1898                    return fetchByCA_K(categoryId, key, true);
1899            }
1900    
1901            /**
1902             * Returns the asset category property where categoryId = &#63; and key = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1903             *
1904             * @param categoryId the category ID
1905             * @param key the key
1906             * @param retrieveFromCache whether to use the finder cache
1907             * @return the matching asset category property, or <code>null</code> if a matching asset category property could not be found
1908             * @throws SystemException if a system exception occurred
1909             */
1910            public AssetCategoryProperty fetchByCA_K(long categoryId, String key,
1911                    boolean retrieveFromCache) throws SystemException {
1912                    Object[] finderArgs = new Object[] { categoryId, key };
1913    
1914                    Object result = null;
1915    
1916                    if (retrieveFromCache) {
1917                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CA_K,
1918                                            finderArgs, this);
1919                    }
1920    
1921                    if (result instanceof AssetCategoryProperty) {
1922                            AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)result;
1923    
1924                            if ((categoryId != assetCategoryProperty.getCategoryId()) ||
1925                                            !Validator.equals(key, assetCategoryProperty.getKey())) {
1926                                    result = null;
1927                            }
1928                    }
1929    
1930                    if (result == null) {
1931                            StringBundler query = new StringBundler(4);
1932    
1933                            query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE);
1934    
1935                            query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
1936    
1937                            if (key == null) {
1938                                    query.append(_FINDER_COLUMN_CA_K_KEY_1);
1939                            }
1940                            else {
1941                                    if (key.equals(StringPool.BLANK)) {
1942                                            query.append(_FINDER_COLUMN_CA_K_KEY_3);
1943                                    }
1944                                    else {
1945                                            query.append(_FINDER_COLUMN_CA_K_KEY_2);
1946                                    }
1947                            }
1948    
1949                            query.append(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
1950    
1951                            String sql = query.toString();
1952    
1953                            Session session = null;
1954    
1955                            try {
1956                                    session = openSession();
1957    
1958                                    Query q = session.createQuery(sql);
1959    
1960                                    QueryPos qPos = QueryPos.getInstance(q);
1961    
1962                                    qPos.add(categoryId);
1963    
1964                                    if (key != null) {
1965                                            qPos.add(key);
1966                                    }
1967    
1968                                    List<AssetCategoryProperty> list = q.list();
1969    
1970                                    result = list;
1971    
1972                                    AssetCategoryProperty assetCategoryProperty = null;
1973    
1974                                    if (list.isEmpty()) {
1975                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1976                                                    finderArgs, list);
1977                                    }
1978                                    else {
1979                                            assetCategoryProperty = list.get(0);
1980    
1981                                            cacheResult(assetCategoryProperty);
1982    
1983                                            if ((assetCategoryProperty.getCategoryId() != categoryId) ||
1984                                                            (assetCategoryProperty.getKey() == null) ||
1985                                                            !assetCategoryProperty.getKey().equals(key)) {
1986                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CA_K,
1987                                                            finderArgs, assetCategoryProperty);
1988                                            }
1989                                    }
1990    
1991                                    return assetCategoryProperty;
1992                            }
1993                            catch (Exception e) {
1994                                    throw processException(e);
1995                            }
1996                            finally {
1997                                    if (result == null) {
1998                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CA_K,
1999                                                    finderArgs);
2000                                    }
2001    
2002                                    closeSession(session);
2003                            }
2004                    }
2005                    else {
2006                            if (result instanceof List<?>) {
2007                                    return null;
2008                            }
2009                            else {
2010                                    return (AssetCategoryProperty)result;
2011                            }
2012                    }
2013            }
2014    
2015            /**
2016             * Returns all the asset category properties.
2017             *
2018             * @return the asset category properties
2019             * @throws SystemException if a system exception occurred
2020             */
2021            public List<AssetCategoryProperty> findAll() throws SystemException {
2022                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2023            }
2024    
2025            /**
2026             * Returns a range of all the asset category properties.
2027             *
2028             * <p>
2029             * 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.
2030             * </p>
2031             *
2032             * @param start the lower bound of the range of asset category properties
2033             * @param end the upper bound of the range of asset category properties (not inclusive)
2034             * @return the range of asset category properties
2035             * @throws SystemException if a system exception occurred
2036             */
2037            public List<AssetCategoryProperty> findAll(int start, int end)
2038                    throws SystemException {
2039                    return findAll(start, end, null);
2040            }
2041    
2042            /**
2043             * Returns an ordered range of all the asset category properties.
2044             *
2045             * <p>
2046             * 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.
2047             * </p>
2048             *
2049             * @param start the lower bound of the range of asset category properties
2050             * @param end the upper bound of the range of asset category properties (not inclusive)
2051             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2052             * @return the ordered range of asset category properties
2053             * @throws SystemException if a system exception occurred
2054             */
2055            public List<AssetCategoryProperty> findAll(int start, int end,
2056                    OrderByComparator orderByComparator) throws SystemException {
2057                    FinderPath finderPath = null;
2058                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2059    
2060                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2061                                    (orderByComparator == null)) {
2062                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2063                            finderArgs = FINDER_ARGS_EMPTY;
2064                    }
2065                    else {
2066                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2067                            finderArgs = new Object[] { start, end, orderByComparator };
2068                    }
2069    
2070                    List<AssetCategoryProperty> list = (List<AssetCategoryProperty>)FinderCacheUtil.getResult(finderPath,
2071                                    finderArgs, this);
2072    
2073                    if (list == null) {
2074                            StringBundler query = null;
2075                            String sql = null;
2076    
2077                            if (orderByComparator != null) {
2078                                    query = new StringBundler(2 +
2079                                                    (orderByComparator.getOrderByFields().length * 3));
2080    
2081                                    query.append(_SQL_SELECT_ASSETCATEGORYPROPERTY);
2082    
2083                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2084                                            orderByComparator);
2085    
2086                                    sql = query.toString();
2087                            }
2088                            else {
2089                                    sql = _SQL_SELECT_ASSETCATEGORYPROPERTY.concat(AssetCategoryPropertyModelImpl.ORDER_BY_JPQL);
2090                            }
2091    
2092                            Session session = null;
2093    
2094                            try {
2095                                    session = openSession();
2096    
2097                                    Query q = session.createQuery(sql);
2098    
2099                                    if (orderByComparator == null) {
2100                                            list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2101                                                            getDialect(), start, end, false);
2102    
2103                                            Collections.sort(list);
2104                                    }
2105                                    else {
2106                                            list = (List<AssetCategoryProperty>)QueryUtil.list(q,
2107                                                            getDialect(), start, end);
2108                                    }
2109                            }
2110                            catch (Exception e) {
2111                                    throw processException(e);
2112                            }
2113                            finally {
2114                                    if (list == null) {
2115                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2116                                    }
2117                                    else {
2118                                            cacheResult(list);
2119    
2120                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2121                                    }
2122    
2123                                    closeSession(session);
2124                            }
2125                    }
2126    
2127                    return list;
2128            }
2129    
2130            /**
2131             * Removes all the asset category properties where companyId = &#63; from the database.
2132             *
2133             * @param companyId the company ID
2134             * @throws SystemException if a system exception occurred
2135             */
2136            public void removeByCompanyId(long companyId) throws SystemException {
2137                    for (AssetCategoryProperty assetCategoryProperty : findByCompanyId(
2138                                    companyId)) {
2139                            remove(assetCategoryProperty);
2140                    }
2141            }
2142    
2143            /**
2144             * Removes all the asset category properties where categoryId = &#63; from the database.
2145             *
2146             * @param categoryId the category ID
2147             * @throws SystemException if a system exception occurred
2148             */
2149            public void removeByCategoryId(long categoryId) throws SystemException {
2150                    for (AssetCategoryProperty assetCategoryProperty : findByCategoryId(
2151                                    categoryId)) {
2152                            remove(assetCategoryProperty);
2153                    }
2154            }
2155    
2156            /**
2157             * Removes all the asset category properties where companyId = &#63; and key = &#63; from the database.
2158             *
2159             * @param companyId the company ID
2160             * @param key the key
2161             * @throws SystemException if a system exception occurred
2162             */
2163            public void removeByC_K(long companyId, String key)
2164                    throws SystemException {
2165                    for (AssetCategoryProperty assetCategoryProperty : findByC_K(
2166                                    companyId, key)) {
2167                            remove(assetCategoryProperty);
2168                    }
2169            }
2170    
2171            /**
2172             * Removes the asset category property where categoryId = &#63; and key = &#63; from the database.
2173             *
2174             * @param categoryId the category ID
2175             * @param key the key
2176             * @return the asset category property that was removed
2177             * @throws SystemException if a system exception occurred
2178             */
2179            public AssetCategoryProperty removeByCA_K(long categoryId, String key)
2180                    throws NoSuchCategoryPropertyException, SystemException {
2181                    AssetCategoryProperty assetCategoryProperty = findByCA_K(categoryId, key);
2182    
2183                    return remove(assetCategoryProperty);
2184            }
2185    
2186            /**
2187             * Removes all the asset category properties from the database.
2188             *
2189             * @throws SystemException if a system exception occurred
2190             */
2191            public void removeAll() throws SystemException {
2192                    for (AssetCategoryProperty assetCategoryProperty : findAll()) {
2193                            remove(assetCategoryProperty);
2194                    }
2195            }
2196    
2197            /**
2198             * Returns the number of asset category properties where companyId = &#63;.
2199             *
2200             * @param companyId the company ID
2201             * @return the number of matching asset category properties
2202             * @throws SystemException if a system exception occurred
2203             */
2204            public int countByCompanyId(long companyId) throws SystemException {
2205                    Object[] finderArgs = new Object[] { companyId };
2206    
2207                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2208                                    finderArgs, this);
2209    
2210                    if (count == null) {
2211                            StringBundler query = new StringBundler(2);
2212    
2213                            query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2214    
2215                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2216    
2217                            String sql = query.toString();
2218    
2219                            Session session = null;
2220    
2221                            try {
2222                                    session = openSession();
2223    
2224                                    Query q = session.createQuery(sql);
2225    
2226                                    QueryPos qPos = QueryPos.getInstance(q);
2227    
2228                                    qPos.add(companyId);
2229    
2230                                    count = (Long)q.uniqueResult();
2231                            }
2232                            catch (Exception e) {
2233                                    throw processException(e);
2234                            }
2235                            finally {
2236                                    if (count == null) {
2237                                            count = Long.valueOf(0);
2238                                    }
2239    
2240                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2241                                            finderArgs, count);
2242    
2243                                    closeSession(session);
2244                            }
2245                    }
2246    
2247                    return count.intValue();
2248            }
2249    
2250            /**
2251             * Returns the number of asset category properties where categoryId = &#63;.
2252             *
2253             * @param categoryId the category ID
2254             * @return the number of matching asset category properties
2255             * @throws SystemException if a system exception occurred
2256             */
2257            public int countByCategoryId(long categoryId) throws SystemException {
2258                    Object[] finderArgs = new Object[] { categoryId };
2259    
2260                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2261                                    finderArgs, this);
2262    
2263                    if (count == null) {
2264                            StringBundler query = new StringBundler(2);
2265    
2266                            query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2267    
2268                            query.append(_FINDER_COLUMN_CATEGORYID_CATEGORYID_2);
2269    
2270                            String sql = query.toString();
2271    
2272                            Session session = null;
2273    
2274                            try {
2275                                    session = openSession();
2276    
2277                                    Query q = session.createQuery(sql);
2278    
2279                                    QueryPos qPos = QueryPos.getInstance(q);
2280    
2281                                    qPos.add(categoryId);
2282    
2283                                    count = (Long)q.uniqueResult();
2284                            }
2285                            catch (Exception e) {
2286                                    throw processException(e);
2287                            }
2288                            finally {
2289                                    if (count == null) {
2290                                            count = Long.valueOf(0);
2291                                    }
2292    
2293                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CATEGORYID,
2294                                            finderArgs, count);
2295    
2296                                    closeSession(session);
2297                            }
2298                    }
2299    
2300                    return count.intValue();
2301            }
2302    
2303            /**
2304             * Returns the number of asset category properties where companyId = &#63; and key = &#63;.
2305             *
2306             * @param companyId the company ID
2307             * @param key the key
2308             * @return the number of matching asset category properties
2309             * @throws SystemException if a system exception occurred
2310             */
2311            public int countByC_K(long companyId, String key) throws SystemException {
2312                    Object[] finderArgs = new Object[] { companyId, key };
2313    
2314                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_K,
2315                                    finderArgs, this);
2316    
2317                    if (count == null) {
2318                            StringBundler query = new StringBundler(3);
2319    
2320                            query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2321    
2322                            query.append(_FINDER_COLUMN_C_K_COMPANYID_2);
2323    
2324                            if (key == null) {
2325                                    query.append(_FINDER_COLUMN_C_K_KEY_1);
2326                            }
2327                            else {
2328                                    if (key.equals(StringPool.BLANK)) {
2329                                            query.append(_FINDER_COLUMN_C_K_KEY_3);
2330                                    }
2331                                    else {
2332                                            query.append(_FINDER_COLUMN_C_K_KEY_2);
2333                                    }
2334                            }
2335    
2336                            String sql = query.toString();
2337    
2338                            Session session = null;
2339    
2340                            try {
2341                                    session = openSession();
2342    
2343                                    Query q = session.createQuery(sql);
2344    
2345                                    QueryPos qPos = QueryPos.getInstance(q);
2346    
2347                                    qPos.add(companyId);
2348    
2349                                    if (key != null) {
2350                                            qPos.add(key);
2351                                    }
2352    
2353                                    count = (Long)q.uniqueResult();
2354                            }
2355                            catch (Exception e) {
2356                                    throw processException(e);
2357                            }
2358                            finally {
2359                                    if (count == null) {
2360                                            count = Long.valueOf(0);
2361                                    }
2362    
2363                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_K, finderArgs,
2364                                            count);
2365    
2366                                    closeSession(session);
2367                            }
2368                    }
2369    
2370                    return count.intValue();
2371            }
2372    
2373            /**
2374             * Returns the number of asset category properties where categoryId = &#63; and key = &#63;.
2375             *
2376             * @param categoryId the category ID
2377             * @param key the key
2378             * @return the number of matching asset category properties
2379             * @throws SystemException if a system exception occurred
2380             */
2381            public int countByCA_K(long categoryId, String key)
2382                    throws SystemException {
2383                    Object[] finderArgs = new Object[] { categoryId, key };
2384    
2385                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CA_K,
2386                                    finderArgs, this);
2387    
2388                    if (count == null) {
2389                            StringBundler query = new StringBundler(3);
2390    
2391                            query.append(_SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE);
2392    
2393                            query.append(_FINDER_COLUMN_CA_K_CATEGORYID_2);
2394    
2395                            if (key == null) {
2396                                    query.append(_FINDER_COLUMN_CA_K_KEY_1);
2397                            }
2398                            else {
2399                                    if (key.equals(StringPool.BLANK)) {
2400                                            query.append(_FINDER_COLUMN_CA_K_KEY_3);
2401                                    }
2402                                    else {
2403                                            query.append(_FINDER_COLUMN_CA_K_KEY_2);
2404                                    }
2405                            }
2406    
2407                            String sql = query.toString();
2408    
2409                            Session session = null;
2410    
2411                            try {
2412                                    session = openSession();
2413    
2414                                    Query q = session.createQuery(sql);
2415    
2416                                    QueryPos qPos = QueryPos.getInstance(q);
2417    
2418                                    qPos.add(categoryId);
2419    
2420                                    if (key != null) {
2421                                            qPos.add(key);
2422                                    }
2423    
2424                                    count = (Long)q.uniqueResult();
2425                            }
2426                            catch (Exception e) {
2427                                    throw processException(e);
2428                            }
2429                            finally {
2430                                    if (count == null) {
2431                                            count = Long.valueOf(0);
2432                                    }
2433    
2434                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CA_K,
2435                                            finderArgs, count);
2436    
2437                                    closeSession(session);
2438                            }
2439                    }
2440    
2441                    return count.intValue();
2442            }
2443    
2444            /**
2445             * Returns the number of asset category properties.
2446             *
2447             * @return the number of asset category properties
2448             * @throws SystemException if a system exception occurred
2449             */
2450            public int countAll() throws SystemException {
2451                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2452                                    FINDER_ARGS_EMPTY, this);
2453    
2454                    if (count == null) {
2455                            Session session = null;
2456    
2457                            try {
2458                                    session = openSession();
2459    
2460                                    Query q = session.createQuery(_SQL_COUNT_ASSETCATEGORYPROPERTY);
2461    
2462                                    count = (Long)q.uniqueResult();
2463                            }
2464                            catch (Exception e) {
2465                                    throw processException(e);
2466                            }
2467                            finally {
2468                                    if (count == null) {
2469                                            count = Long.valueOf(0);
2470                                    }
2471    
2472                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2473                                            FINDER_ARGS_EMPTY, count);
2474    
2475                                    closeSession(session);
2476                            }
2477                    }
2478    
2479                    return count.intValue();
2480            }
2481    
2482            /**
2483             * Initializes the asset category property persistence.
2484             */
2485            public void afterPropertiesSet() {
2486                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2487                                            com.liferay.portal.util.PropsUtil.get(
2488                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetCategoryProperty")));
2489    
2490                    if (listenerClassNames.length > 0) {
2491                            try {
2492                                    List<ModelListener<AssetCategoryProperty>> listenersList = new ArrayList<ModelListener<AssetCategoryProperty>>();
2493    
2494                                    for (String listenerClassName : listenerClassNames) {
2495                                            Class<?> clazz = getClass();
2496    
2497                                            listenersList.add((ModelListener<AssetCategoryProperty>)InstanceFactory.newInstance(
2498                                                            clazz.getClassLoader(), listenerClassName));
2499                                    }
2500    
2501                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2502                            }
2503                            catch (Exception e) {
2504                                    _log.error(e);
2505                            }
2506                    }
2507            }
2508    
2509            public void destroy() {
2510                    EntityCacheUtil.removeCache(AssetCategoryPropertyImpl.class.getName());
2511                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2512                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2513            }
2514    
2515            @BeanReference(type = AssetCategoryPersistence.class)
2516            protected AssetCategoryPersistence assetCategoryPersistence;
2517            @BeanReference(type = AssetCategoryPropertyPersistence.class)
2518            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
2519            @BeanReference(type = AssetEntryPersistence.class)
2520            protected AssetEntryPersistence assetEntryPersistence;
2521            @BeanReference(type = AssetLinkPersistence.class)
2522            protected AssetLinkPersistence assetLinkPersistence;
2523            @BeanReference(type = AssetTagPersistence.class)
2524            protected AssetTagPersistence assetTagPersistence;
2525            @BeanReference(type = AssetTagPropertyPersistence.class)
2526            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
2527            @BeanReference(type = AssetTagStatsPersistence.class)
2528            protected AssetTagStatsPersistence assetTagStatsPersistence;
2529            @BeanReference(type = AssetVocabularyPersistence.class)
2530            protected AssetVocabularyPersistence assetVocabularyPersistence;
2531            @BeanReference(type = ResourcePersistence.class)
2532            protected ResourcePersistence resourcePersistence;
2533            @BeanReference(type = UserPersistence.class)
2534            protected UserPersistence userPersistence;
2535            private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty";
2536            private static final String _SQL_SELECT_ASSETCATEGORYPROPERTY_WHERE = "SELECT assetCategoryProperty FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2537            private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty";
2538            private static final String _SQL_COUNT_ASSETCATEGORYPROPERTY_WHERE = "SELECT COUNT(assetCategoryProperty) FROM AssetCategoryProperty assetCategoryProperty WHERE ";
2539            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "assetCategoryProperty.companyId = ?";
2540            private static final String _FINDER_COLUMN_CATEGORYID_CATEGORYID_2 = "assetCategoryProperty.categoryId = ?";
2541            private static final String _FINDER_COLUMN_C_K_COMPANYID_2 = "assetCategoryProperty.companyId = ? AND ";
2542            private static final String _FINDER_COLUMN_C_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2543            private static final String _FINDER_COLUMN_C_K_KEY_2 = "assetCategoryProperty.key = ?";
2544            private static final String _FINDER_COLUMN_C_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2545            private static final String _FINDER_COLUMN_CA_K_CATEGORYID_2 = "assetCategoryProperty.categoryId = ? AND ";
2546            private static final String _FINDER_COLUMN_CA_K_KEY_1 = "assetCategoryProperty.key IS NULL";
2547            private static final String _FINDER_COLUMN_CA_K_KEY_2 = "assetCategoryProperty.key = ?";
2548            private static final String _FINDER_COLUMN_CA_K_KEY_3 = "(assetCategoryProperty.key IS NULL OR assetCategoryProperty.key = ?)";
2549            private static final String _ORDER_BY_ENTITY_ALIAS = "assetCategoryProperty.";
2550            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetCategoryProperty exists with the primary key ";
2551            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetCategoryProperty exists with the key {";
2552            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2553            private static Log _log = LogFactoryUtil.getLog(AssetCategoryPropertyPersistenceImpl.class);
2554            private static AssetCategoryProperty _nullAssetCategoryProperty = new AssetCategoryPropertyImpl() {
2555                            @Override
2556                            public Object clone() {
2557                                    return this;
2558                            }
2559    
2560                            @Override
2561                            public CacheModel<AssetCategoryProperty> toCacheModel() {
2562                                    return _nullAssetCategoryPropertyCacheModel;
2563                            }
2564                    };
2565    
2566            private static CacheModel<AssetCategoryProperty> _nullAssetCategoryPropertyCacheModel =
2567                    new CacheModel<AssetCategoryProperty>() {
2568                            public AssetCategoryProperty toEntityModel() {
2569                                    return _nullAssetCategoryProperty;
2570                            }
2571                    };
2572    }