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