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