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