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