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