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