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