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