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.NoSuchRepositoryEntryException;
018    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
019    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
020    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderPath;
022    import com.liferay.portal.kernel.dao.orm.Query;
023    import com.liferay.portal.kernel.dao.orm.QueryPos;
024    import com.liferay.portal.kernel.dao.orm.QueryUtil;
025    import com.liferay.portal.kernel.dao.orm.Session;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.log.Log;
028    import com.liferay.portal.kernel.log.LogFactoryUtil;
029    import com.liferay.portal.kernel.util.GetterUtil;
030    import com.liferay.portal.kernel.util.InstanceFactory;
031    import com.liferay.portal.kernel.util.OrderByComparator;
032    import com.liferay.portal.kernel.util.SetUtil;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.kernel.util.UnmodifiableList;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039    import com.liferay.portal.model.CacheModel;
040    import com.liferay.portal.model.ModelListener;
041    import com.liferay.portal.model.RepositoryEntry;
042    import com.liferay.portal.model.impl.RepositoryEntryImpl;
043    import com.liferay.portal.model.impl.RepositoryEntryModelImpl;
044    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045    
046    import java.io.Serializable;
047    
048    import java.util.ArrayList;
049    import java.util.Collections;
050    import java.util.List;
051    import java.util.Set;
052    
053    /**
054     * The persistence implementation for the repository entry service.
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see RepositoryEntryPersistence
062     * @see RepositoryEntryUtil
063     * @generated
064     */
065    public class RepositoryEntryPersistenceImpl extends BasePersistenceImpl<RepositoryEntry>
066            implements RepositoryEntryPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link RepositoryEntryUtil} to access the repository entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = RepositoryEntryImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
078                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
079                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
080                            "findAll", new String[0]);
081            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
082                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
083                            RepositoryEntryImpl.class,
084                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
086                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
087                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
088            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
089                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
090                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
091                            "findByUuid",
092                            new String[] {
093                                    String.class.getName(),
094                                    
095                            Integer.class.getName(), Integer.class.getName(),
096                                    OrderByComparator.class.getName()
097                            });
098            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
099                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
100                            RepositoryEntryImpl.class,
101                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102                            new String[] { String.class.getName() },
103                            RepositoryEntryModelImpl.UUID_COLUMN_BITMASK);
104            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
105                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107                            new String[] { String.class.getName() });
108    
109            /**
110             * Returns all the repository entries where uuid = &#63;.
111             *
112             * @param uuid the uuid
113             * @return the matching repository entries
114             * @throws SystemException if a system exception occurred
115             */
116            @Override
117            public List<RepositoryEntry> findByUuid(String uuid)
118                    throws SystemException {
119                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
120            }
121    
122            /**
123             * Returns a range of all the repository entries where uuid = &#63;.
124             *
125             * <p>
126             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
127             * </p>
128             *
129             * @param uuid the uuid
130             * @param start the lower bound of the range of repository entries
131             * @param end the upper bound of the range of repository entries (not inclusive)
132             * @return the range of matching repository entries
133             * @throws SystemException if a system exception occurred
134             */
135            @Override
136            public List<RepositoryEntry> findByUuid(String uuid, int start, int end)
137                    throws SystemException {
138                    return findByUuid(uuid, start, end, null);
139            }
140    
141            /**
142             * Returns an ordered range of all the repository entries where uuid = &#63;.
143             *
144             * <p>
145             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
146             * </p>
147             *
148             * @param uuid the uuid
149             * @param start the lower bound of the range of repository entries
150             * @param end the upper bound of the range of repository entries (not inclusive)
151             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
152             * @return the ordered range of matching repository entries
153             * @throws SystemException if a system exception occurred
154             */
155            @Override
156            public List<RepositoryEntry> findByUuid(String uuid, int start, int end,
157                    OrderByComparator orderByComparator) throws SystemException {
158                    boolean pagination = true;
159                    FinderPath finderPath = null;
160                    Object[] finderArgs = null;
161    
162                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
163                                    (orderByComparator == null)) {
164                            pagination = false;
165                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
166                            finderArgs = new Object[] { uuid };
167                    }
168                    else {
169                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
170                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
171                    }
172    
173                    List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
174                                    finderArgs, this);
175    
176                    if ((list != null) && !list.isEmpty()) {
177                            for (RepositoryEntry repositoryEntry : list) {
178                                    if (!Validator.equals(uuid, repositoryEntry.getUuid())) {
179                                            list = null;
180    
181                                            break;
182                                    }
183                            }
184                    }
185    
186                    if (list == null) {
187                            StringBundler query = null;
188    
189                            if (orderByComparator != null) {
190                                    query = new StringBundler(3 +
191                                                    (orderByComparator.getOrderByFields().length * 3));
192                            }
193                            else {
194                                    query = new StringBundler(3);
195                            }
196    
197                            query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
198    
199                            boolean bindUuid = false;
200    
201                            if (uuid == null) {
202                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
203                            }
204                            else if (uuid.equals(StringPool.BLANK)) {
205                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
206                            }
207                            else {
208                                    bindUuid = true;
209    
210                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
211                            }
212    
213                            if (orderByComparator != null) {
214                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
215                                            orderByComparator);
216                            }
217                            else
218                             if (pagination) {
219                                    query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
220                            }
221    
222                            String sql = query.toString();
223    
224                            Session session = null;
225    
226                            try {
227                                    session = openSession();
228    
229                                    Query q = session.createQuery(sql);
230    
231                                    QueryPos qPos = QueryPos.getInstance(q);
232    
233                                    if (bindUuid) {
234                                            qPos.add(uuid);
235                                    }
236    
237                                    if (!pagination) {
238                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
239                                                            getDialect(), start, end, false);
240    
241                                            Collections.sort(list);
242    
243                                            list = new UnmodifiableList<RepositoryEntry>(list);
244                                    }
245                                    else {
246                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
247                                                            getDialect(), start, end);
248                                    }
249    
250                                    cacheResult(list);
251    
252                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
253                            }
254                            catch (Exception e) {
255                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
256    
257                                    throw processException(e);
258                            }
259                            finally {
260                                    closeSession(session);
261                            }
262                    }
263    
264                    return list;
265            }
266    
267            /**
268             * Returns the first repository entry in the ordered set where uuid = &#63;.
269             *
270             * @param uuid the uuid
271             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
272             * @return the first matching repository entry
273             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
274             * @throws SystemException if a system exception occurred
275             */
276            @Override
277            public RepositoryEntry findByUuid_First(String uuid,
278                    OrderByComparator orderByComparator)
279                    throws NoSuchRepositoryEntryException, SystemException {
280                    RepositoryEntry repositoryEntry = fetchByUuid_First(uuid,
281                                    orderByComparator);
282    
283                    if (repositoryEntry != null) {
284                            return repositoryEntry;
285                    }
286    
287                    StringBundler msg = new StringBundler(4);
288    
289                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
290    
291                    msg.append("uuid=");
292                    msg.append(uuid);
293    
294                    msg.append(StringPool.CLOSE_CURLY_BRACE);
295    
296                    throw new NoSuchRepositoryEntryException(msg.toString());
297            }
298    
299            /**
300             * Returns the first repository entry in the ordered set where uuid = &#63;.
301             *
302             * @param uuid the uuid
303             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
304             * @return the first matching repository entry, or <code>null</code> if a matching repository entry could not be found
305             * @throws SystemException if a system exception occurred
306             */
307            @Override
308            public RepositoryEntry fetchByUuid_First(String uuid,
309                    OrderByComparator orderByComparator) throws SystemException {
310                    List<RepositoryEntry> list = findByUuid(uuid, 0, 1, orderByComparator);
311    
312                    if (!list.isEmpty()) {
313                            return list.get(0);
314                    }
315    
316                    return null;
317            }
318    
319            /**
320             * Returns the last repository entry in the ordered set where uuid = &#63;.
321             *
322             * @param uuid the uuid
323             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
324             * @return the last matching repository entry
325             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
326             * @throws SystemException if a system exception occurred
327             */
328            @Override
329            public RepositoryEntry findByUuid_Last(String uuid,
330                    OrderByComparator orderByComparator)
331                    throws NoSuchRepositoryEntryException, SystemException {
332                    RepositoryEntry repositoryEntry = fetchByUuid_Last(uuid,
333                                    orderByComparator);
334    
335                    if (repositoryEntry != null) {
336                            return repositoryEntry;
337                    }
338    
339                    StringBundler msg = new StringBundler(4);
340    
341                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
342    
343                    msg.append("uuid=");
344                    msg.append(uuid);
345    
346                    msg.append(StringPool.CLOSE_CURLY_BRACE);
347    
348                    throw new NoSuchRepositoryEntryException(msg.toString());
349            }
350    
351            /**
352             * Returns the last repository entry in the ordered set where uuid = &#63;.
353             *
354             * @param uuid the uuid
355             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
356             * @return the last matching repository entry, or <code>null</code> if a matching repository entry could not be found
357             * @throws SystemException if a system exception occurred
358             */
359            @Override
360            public RepositoryEntry fetchByUuid_Last(String uuid,
361                    OrderByComparator orderByComparator) throws SystemException {
362                    int count = countByUuid(uuid);
363    
364                    if (count == 0) {
365                            return null;
366                    }
367    
368                    List<RepositoryEntry> list = findByUuid(uuid, count - 1, count,
369                                    orderByComparator);
370    
371                    if (!list.isEmpty()) {
372                            return list.get(0);
373                    }
374    
375                    return null;
376            }
377    
378            /**
379             * Returns the repository entries before and after the current repository entry in the ordered set where uuid = &#63;.
380             *
381             * @param repositoryEntryId the primary key of the current repository entry
382             * @param uuid the uuid
383             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
384             * @return the previous, current, and next repository entry
385             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
386             * @throws SystemException if a system exception occurred
387             */
388            @Override
389            public RepositoryEntry[] findByUuid_PrevAndNext(long repositoryEntryId,
390                    String uuid, OrderByComparator orderByComparator)
391                    throws NoSuchRepositoryEntryException, SystemException {
392                    RepositoryEntry repositoryEntry = findByPrimaryKey(repositoryEntryId);
393    
394                    Session session = null;
395    
396                    try {
397                            session = openSession();
398    
399                            RepositoryEntry[] array = new RepositoryEntryImpl[3];
400    
401                            array[0] = getByUuid_PrevAndNext(session, repositoryEntry, uuid,
402                                            orderByComparator, true);
403    
404                            array[1] = repositoryEntry;
405    
406                            array[2] = getByUuid_PrevAndNext(session, repositoryEntry, uuid,
407                                            orderByComparator, false);
408    
409                            return array;
410                    }
411                    catch (Exception e) {
412                            throw processException(e);
413                    }
414                    finally {
415                            closeSession(session);
416                    }
417            }
418    
419            protected RepositoryEntry getByUuid_PrevAndNext(Session session,
420                    RepositoryEntry repositoryEntry, String uuid,
421                    OrderByComparator orderByComparator, boolean previous) {
422                    StringBundler query = null;
423    
424                    if (orderByComparator != null) {
425                            query = new StringBundler(6 +
426                                            (orderByComparator.getOrderByFields().length * 6));
427                    }
428                    else {
429                            query = new StringBundler(3);
430                    }
431    
432                    query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
433    
434                    boolean bindUuid = false;
435    
436                    if (uuid == null) {
437                            query.append(_FINDER_COLUMN_UUID_UUID_1);
438                    }
439                    else if (uuid.equals(StringPool.BLANK)) {
440                            query.append(_FINDER_COLUMN_UUID_UUID_3);
441                    }
442                    else {
443                            bindUuid = true;
444    
445                            query.append(_FINDER_COLUMN_UUID_UUID_2);
446                    }
447    
448                    if (orderByComparator != null) {
449                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
450    
451                            if (orderByConditionFields.length > 0) {
452                                    query.append(WHERE_AND);
453                            }
454    
455                            for (int i = 0; i < orderByConditionFields.length; i++) {
456                                    query.append(_ORDER_BY_ENTITY_ALIAS);
457                                    query.append(orderByConditionFields[i]);
458    
459                                    if ((i + 1) < orderByConditionFields.length) {
460                                            if (orderByComparator.isAscending() ^ previous) {
461                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
462                                            }
463                                            else {
464                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
465                                            }
466                                    }
467                                    else {
468                                            if (orderByComparator.isAscending() ^ previous) {
469                                                    query.append(WHERE_GREATER_THAN);
470                                            }
471                                            else {
472                                                    query.append(WHERE_LESSER_THAN);
473                                            }
474                                    }
475                            }
476    
477                            query.append(ORDER_BY_CLAUSE);
478    
479                            String[] orderByFields = orderByComparator.getOrderByFields();
480    
481                            for (int i = 0; i < orderByFields.length; i++) {
482                                    query.append(_ORDER_BY_ENTITY_ALIAS);
483                                    query.append(orderByFields[i]);
484    
485                                    if ((i + 1) < orderByFields.length) {
486                                            if (orderByComparator.isAscending() ^ previous) {
487                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
488                                            }
489                                            else {
490                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
491                                            }
492                                    }
493                                    else {
494                                            if (orderByComparator.isAscending() ^ previous) {
495                                                    query.append(ORDER_BY_ASC);
496                                            }
497                                            else {
498                                                    query.append(ORDER_BY_DESC);
499                                            }
500                                    }
501                            }
502                    }
503                    else {
504                            query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
505                    }
506    
507                    String sql = query.toString();
508    
509                    Query q = session.createQuery(sql);
510    
511                    q.setFirstResult(0);
512                    q.setMaxResults(2);
513    
514                    QueryPos qPos = QueryPos.getInstance(q);
515    
516                    if (bindUuid) {
517                            qPos.add(uuid);
518                    }
519    
520                    if (orderByComparator != null) {
521                            Object[] values = orderByComparator.getOrderByConditionValues(repositoryEntry);
522    
523                            for (Object value : values) {
524                                    qPos.add(value);
525                            }
526                    }
527    
528                    List<RepositoryEntry> list = q.list();
529    
530                    if (list.size() == 2) {
531                            return list.get(1);
532                    }
533                    else {
534                            return null;
535                    }
536            }
537    
538            /**
539             * Removes all the repository entries where uuid = &#63; from the database.
540             *
541             * @param uuid the uuid
542             * @throws SystemException if a system exception occurred
543             */
544            @Override
545            public void removeByUuid(String uuid) throws SystemException {
546                    for (RepositoryEntry repositoryEntry : findByUuid(uuid,
547                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
548                            remove(repositoryEntry);
549                    }
550            }
551    
552            /**
553             * Returns the number of repository entries where uuid = &#63;.
554             *
555             * @param uuid the uuid
556             * @return the number of matching repository entries
557             * @throws SystemException if a system exception occurred
558             */
559            @Override
560            public int countByUuid(String uuid) throws SystemException {
561                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
562    
563                    Object[] finderArgs = new Object[] { uuid };
564    
565                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
566                                    this);
567    
568                    if (count == null) {
569                            StringBundler query = new StringBundler(2);
570    
571                            query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
572    
573                            boolean bindUuid = false;
574    
575                            if (uuid == null) {
576                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
577                            }
578                            else if (uuid.equals(StringPool.BLANK)) {
579                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
580                            }
581                            else {
582                                    bindUuid = true;
583    
584                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
585                            }
586    
587                            String sql = query.toString();
588    
589                            Session session = null;
590    
591                            try {
592                                    session = openSession();
593    
594                                    Query q = session.createQuery(sql);
595    
596                                    QueryPos qPos = QueryPos.getInstance(q);
597    
598                                    if (bindUuid) {
599                                            qPos.add(uuid);
600                                    }
601    
602                                    count = (Long)q.uniqueResult();
603    
604                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
605                            }
606                            catch (Exception e) {
607                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
608    
609                                    throw processException(e);
610                            }
611                            finally {
612                                    closeSession(session);
613                            }
614                    }
615    
616                    return count.intValue();
617            }
618    
619            private static final String _FINDER_COLUMN_UUID_UUID_1 = "repositoryEntry.uuid IS NULL";
620            private static final String _FINDER_COLUMN_UUID_UUID_2 = "repositoryEntry.uuid = ?";
621            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(repositoryEntry.uuid IS NULL OR repositoryEntry.uuid = '')";
622            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
623                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
624                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_ENTITY,
625                            "fetchByUUID_G",
626                            new String[] { String.class.getName(), Long.class.getName() },
627                            RepositoryEntryModelImpl.UUID_COLUMN_BITMASK |
628                            RepositoryEntryModelImpl.GROUPID_COLUMN_BITMASK);
629            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
630                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
631                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
632                            new String[] { String.class.getName(), Long.class.getName() });
633    
634            /**
635             * Returns the repository entry where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portal.NoSuchRepositoryEntryException} if it could not be found.
636             *
637             * @param uuid the uuid
638             * @param groupId the group ID
639             * @return the matching repository entry
640             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
641             * @throws SystemException if a system exception occurred
642             */
643            @Override
644            public RepositoryEntry findByUUID_G(String uuid, long groupId)
645                    throws NoSuchRepositoryEntryException, SystemException {
646                    RepositoryEntry repositoryEntry = fetchByUUID_G(uuid, groupId);
647    
648                    if (repositoryEntry == null) {
649                            StringBundler msg = new StringBundler(6);
650    
651                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
652    
653                            msg.append("uuid=");
654                            msg.append(uuid);
655    
656                            msg.append(", groupId=");
657                            msg.append(groupId);
658    
659                            msg.append(StringPool.CLOSE_CURLY_BRACE);
660    
661                            if (_log.isWarnEnabled()) {
662                                    _log.warn(msg.toString());
663                            }
664    
665                            throw new NoSuchRepositoryEntryException(msg.toString());
666                    }
667    
668                    return repositoryEntry;
669            }
670    
671            /**
672             * Returns the repository entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
673             *
674             * @param uuid the uuid
675             * @param groupId the group ID
676             * @return the matching repository entry, or <code>null</code> if a matching repository entry could not be found
677             * @throws SystemException if a system exception occurred
678             */
679            @Override
680            public RepositoryEntry fetchByUUID_G(String uuid, long groupId)
681                    throws SystemException {
682                    return fetchByUUID_G(uuid, groupId, true);
683            }
684    
685            /**
686             * Returns the repository entry where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
687             *
688             * @param uuid the uuid
689             * @param groupId the group ID
690             * @param retrieveFromCache whether to use the finder cache
691             * @return the matching repository entry, or <code>null</code> if a matching repository entry could not be found
692             * @throws SystemException if a system exception occurred
693             */
694            @Override
695            public RepositoryEntry fetchByUUID_G(String uuid, long groupId,
696                    boolean retrieveFromCache) throws SystemException {
697                    Object[] finderArgs = new Object[] { uuid, groupId };
698    
699                    Object result = null;
700    
701                    if (retrieveFromCache) {
702                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
703                                            finderArgs, this);
704                    }
705    
706                    if (result instanceof RepositoryEntry) {
707                            RepositoryEntry repositoryEntry = (RepositoryEntry)result;
708    
709                            if (!Validator.equals(uuid, repositoryEntry.getUuid()) ||
710                                            (groupId != repositoryEntry.getGroupId())) {
711                                    result = null;
712                            }
713                    }
714    
715                    if (result == null) {
716                            StringBundler query = new StringBundler(4);
717    
718                            query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
719    
720                            boolean bindUuid = false;
721    
722                            if (uuid == null) {
723                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
724                            }
725                            else if (uuid.equals(StringPool.BLANK)) {
726                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
727                            }
728                            else {
729                                    bindUuid = true;
730    
731                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
732                            }
733    
734                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
735    
736                            String sql = query.toString();
737    
738                            Session session = null;
739    
740                            try {
741                                    session = openSession();
742    
743                                    Query q = session.createQuery(sql);
744    
745                                    QueryPos qPos = QueryPos.getInstance(q);
746    
747                                    if (bindUuid) {
748                                            qPos.add(uuid);
749                                    }
750    
751                                    qPos.add(groupId);
752    
753                                    List<RepositoryEntry> list = q.list();
754    
755                                    if (list.isEmpty()) {
756                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
757                                                    finderArgs, list);
758                                    }
759                                    else {
760                                            RepositoryEntry repositoryEntry = list.get(0);
761    
762                                            result = repositoryEntry;
763    
764                                            cacheResult(repositoryEntry);
765    
766                                            if ((repositoryEntry.getUuid() == null) ||
767                                                            !repositoryEntry.getUuid().equals(uuid) ||
768                                                            (repositoryEntry.getGroupId() != groupId)) {
769                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
770                                                            finderArgs, repositoryEntry);
771                                            }
772                                    }
773                            }
774                            catch (Exception e) {
775                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
776                                            finderArgs);
777    
778                                    throw processException(e);
779                            }
780                            finally {
781                                    closeSession(session);
782                            }
783                    }
784    
785                    if (result instanceof List<?>) {
786                            return null;
787                    }
788                    else {
789                            return (RepositoryEntry)result;
790                    }
791            }
792    
793            /**
794             * Removes the repository entry where uuid = &#63; and groupId = &#63; from the database.
795             *
796             * @param uuid the uuid
797             * @param groupId the group ID
798             * @return the repository entry that was removed
799             * @throws SystemException if a system exception occurred
800             */
801            @Override
802            public RepositoryEntry removeByUUID_G(String uuid, long groupId)
803                    throws NoSuchRepositoryEntryException, SystemException {
804                    RepositoryEntry repositoryEntry = findByUUID_G(uuid, groupId);
805    
806                    return remove(repositoryEntry);
807            }
808    
809            /**
810             * Returns the number of repository entries where uuid = &#63; and groupId = &#63;.
811             *
812             * @param uuid the uuid
813             * @param groupId the group ID
814             * @return the number of matching repository entries
815             * @throws SystemException if a system exception occurred
816             */
817            @Override
818            public int countByUUID_G(String uuid, long groupId)
819                    throws SystemException {
820                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
821    
822                    Object[] finderArgs = new Object[] { uuid, groupId };
823    
824                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
825                                    this);
826    
827                    if (count == null) {
828                            StringBundler query = new StringBundler(3);
829    
830                            query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
831    
832                            boolean bindUuid = false;
833    
834                            if (uuid == null) {
835                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
836                            }
837                            else if (uuid.equals(StringPool.BLANK)) {
838                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
839                            }
840                            else {
841                                    bindUuid = true;
842    
843                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
844                            }
845    
846                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
847    
848                            String sql = query.toString();
849    
850                            Session session = null;
851    
852                            try {
853                                    session = openSession();
854    
855                                    Query q = session.createQuery(sql);
856    
857                                    QueryPos qPos = QueryPos.getInstance(q);
858    
859                                    if (bindUuid) {
860                                            qPos.add(uuid);
861                                    }
862    
863                                    qPos.add(groupId);
864    
865                                    count = (Long)q.uniqueResult();
866    
867                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
868                            }
869                            catch (Exception e) {
870                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
871    
872                                    throw processException(e);
873                            }
874                            finally {
875                                    closeSession(session);
876                            }
877                    }
878    
879                    return count.intValue();
880            }
881    
882            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "repositoryEntry.uuid IS NULL AND ";
883            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "repositoryEntry.uuid = ? AND ";
884            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(repositoryEntry.uuid IS NULL OR repositoryEntry.uuid = '') AND ";
885            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "repositoryEntry.groupId = ?";
886            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
887                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
888                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
889                            "findByUuid_C",
890                            new String[] {
891                                    String.class.getName(), Long.class.getName(),
892                                    
893                            Integer.class.getName(), Integer.class.getName(),
894                                    OrderByComparator.class.getName()
895                            });
896            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
897                    new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
898                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
899                            RepositoryEntryImpl.class,
900                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
901                            new String[] { String.class.getName(), Long.class.getName() },
902                            RepositoryEntryModelImpl.UUID_COLUMN_BITMASK |
903                            RepositoryEntryModelImpl.COMPANYID_COLUMN_BITMASK);
904            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
905                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
906                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
907                            new String[] { String.class.getName(), Long.class.getName() });
908    
909            /**
910             * Returns all the repository entries where uuid = &#63; and companyId = &#63;.
911             *
912             * @param uuid the uuid
913             * @param companyId the company ID
914             * @return the matching repository entries
915             * @throws SystemException if a system exception occurred
916             */
917            @Override
918            public List<RepositoryEntry> findByUuid_C(String uuid, long companyId)
919                    throws SystemException {
920                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
921                            QueryUtil.ALL_POS, null);
922            }
923    
924            /**
925             * Returns a range of all the repository entries where uuid = &#63; and companyId = &#63;.
926             *
927             * <p>
928             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
929             * </p>
930             *
931             * @param uuid the uuid
932             * @param companyId the company ID
933             * @param start the lower bound of the range of repository entries
934             * @param end the upper bound of the range of repository entries (not inclusive)
935             * @return the range of matching repository entries
936             * @throws SystemException if a system exception occurred
937             */
938            @Override
939            public List<RepositoryEntry> findByUuid_C(String uuid, long companyId,
940                    int start, int end) throws SystemException {
941                    return findByUuid_C(uuid, companyId, start, end, null);
942            }
943    
944            /**
945             * Returns an ordered range of all the repository entries where uuid = &#63; and companyId = &#63;.
946             *
947             * <p>
948             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
949             * </p>
950             *
951             * @param uuid the uuid
952             * @param companyId the company ID
953             * @param start the lower bound of the range of repository entries
954             * @param end the upper bound of the range of repository entries (not inclusive)
955             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
956             * @return the ordered range of matching repository entries
957             * @throws SystemException if a system exception occurred
958             */
959            @Override
960            public List<RepositoryEntry> findByUuid_C(String uuid, long companyId,
961                    int start, int end, OrderByComparator orderByComparator)
962                    throws SystemException {
963                    boolean pagination = true;
964                    FinderPath finderPath = null;
965                    Object[] finderArgs = null;
966    
967                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
968                                    (orderByComparator == null)) {
969                            pagination = false;
970                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
971                            finderArgs = new Object[] { uuid, companyId };
972                    }
973                    else {
974                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
975                            finderArgs = new Object[] {
976                                            uuid, companyId,
977                                            
978                                            start, end, orderByComparator
979                                    };
980                    }
981    
982                    List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
983                                    finderArgs, this);
984    
985                    if ((list != null) && !list.isEmpty()) {
986                            for (RepositoryEntry repositoryEntry : list) {
987                                    if (!Validator.equals(uuid, repositoryEntry.getUuid()) ||
988                                                    (companyId != repositoryEntry.getCompanyId())) {
989                                            list = null;
990    
991                                            break;
992                                    }
993                            }
994                    }
995    
996                    if (list == null) {
997                            StringBundler query = null;
998    
999                            if (orderByComparator != null) {
1000                                    query = new StringBundler(4 +
1001                                                    (orderByComparator.getOrderByFields().length * 3));
1002                            }
1003                            else {
1004                                    query = new StringBundler(4);
1005                            }
1006    
1007                            query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1008    
1009                            boolean bindUuid = false;
1010    
1011                            if (uuid == null) {
1012                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1013                            }
1014                            else if (uuid.equals(StringPool.BLANK)) {
1015                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1016                            }
1017                            else {
1018                                    bindUuid = true;
1019    
1020                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1021                            }
1022    
1023                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1024    
1025                            if (orderByComparator != null) {
1026                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1027                                            orderByComparator);
1028                            }
1029                            else
1030                             if (pagination) {
1031                                    query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
1032                            }
1033    
1034                            String sql = query.toString();
1035    
1036                            Session session = null;
1037    
1038                            try {
1039                                    session = openSession();
1040    
1041                                    Query q = session.createQuery(sql);
1042    
1043                                    QueryPos qPos = QueryPos.getInstance(q);
1044    
1045                                    if (bindUuid) {
1046                                            qPos.add(uuid);
1047                                    }
1048    
1049                                    qPos.add(companyId);
1050    
1051                                    if (!pagination) {
1052                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
1053                                                            getDialect(), start, end, false);
1054    
1055                                            Collections.sort(list);
1056    
1057                                            list = new UnmodifiableList<RepositoryEntry>(list);
1058                                    }
1059                                    else {
1060                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
1061                                                            getDialect(), start, end);
1062                                    }
1063    
1064                                    cacheResult(list);
1065    
1066                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1067                            }
1068                            catch (Exception e) {
1069                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1070    
1071                                    throw processException(e);
1072                            }
1073                            finally {
1074                                    closeSession(session);
1075                            }
1076                    }
1077    
1078                    return list;
1079            }
1080    
1081            /**
1082             * Returns the first repository entry in the ordered set where uuid = &#63; and companyId = &#63;.
1083             *
1084             * @param uuid the uuid
1085             * @param companyId the company ID
1086             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1087             * @return the first matching repository entry
1088             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
1089             * @throws SystemException if a system exception occurred
1090             */
1091            @Override
1092            public RepositoryEntry findByUuid_C_First(String uuid, long companyId,
1093                    OrderByComparator orderByComparator)
1094                    throws NoSuchRepositoryEntryException, SystemException {
1095                    RepositoryEntry repositoryEntry = fetchByUuid_C_First(uuid, companyId,
1096                                    orderByComparator);
1097    
1098                    if (repositoryEntry != null) {
1099                            return repositoryEntry;
1100                    }
1101    
1102                    StringBundler msg = new StringBundler(6);
1103    
1104                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1105    
1106                    msg.append("uuid=");
1107                    msg.append(uuid);
1108    
1109                    msg.append(", companyId=");
1110                    msg.append(companyId);
1111    
1112                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1113    
1114                    throw new NoSuchRepositoryEntryException(msg.toString());
1115            }
1116    
1117            /**
1118             * Returns the first repository entry in the ordered set where uuid = &#63; and companyId = &#63;.
1119             *
1120             * @param uuid the uuid
1121             * @param companyId the company ID
1122             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1123             * @return the first matching repository entry, or <code>null</code> if a matching repository entry could not be found
1124             * @throws SystemException if a system exception occurred
1125             */
1126            @Override
1127            public RepositoryEntry fetchByUuid_C_First(String uuid, long companyId,
1128                    OrderByComparator orderByComparator) throws SystemException {
1129                    List<RepositoryEntry> list = findByUuid_C(uuid, companyId, 0, 1,
1130                                    orderByComparator);
1131    
1132                    if (!list.isEmpty()) {
1133                            return list.get(0);
1134                    }
1135    
1136                    return null;
1137            }
1138    
1139            /**
1140             * Returns the last repository entry in the ordered set where uuid = &#63; and companyId = &#63;.
1141             *
1142             * @param uuid the uuid
1143             * @param companyId the company ID
1144             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1145             * @return the last matching repository entry
1146             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
1147             * @throws SystemException if a system exception occurred
1148             */
1149            @Override
1150            public RepositoryEntry findByUuid_C_Last(String uuid, long companyId,
1151                    OrderByComparator orderByComparator)
1152                    throws NoSuchRepositoryEntryException, SystemException {
1153                    RepositoryEntry repositoryEntry = fetchByUuid_C_Last(uuid, companyId,
1154                                    orderByComparator);
1155    
1156                    if (repositoryEntry != null) {
1157                            return repositoryEntry;
1158                    }
1159    
1160                    StringBundler msg = new StringBundler(6);
1161    
1162                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1163    
1164                    msg.append("uuid=");
1165                    msg.append(uuid);
1166    
1167                    msg.append(", companyId=");
1168                    msg.append(companyId);
1169    
1170                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1171    
1172                    throw new NoSuchRepositoryEntryException(msg.toString());
1173            }
1174    
1175            /**
1176             * Returns the last repository entry in the ordered set where uuid = &#63; and companyId = &#63;.
1177             *
1178             * @param uuid the uuid
1179             * @param companyId the company ID
1180             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1181             * @return the last matching repository entry, or <code>null</code> if a matching repository entry could not be found
1182             * @throws SystemException if a system exception occurred
1183             */
1184            @Override
1185            public RepositoryEntry fetchByUuid_C_Last(String uuid, long companyId,
1186                    OrderByComparator orderByComparator) throws SystemException {
1187                    int count = countByUuid_C(uuid, companyId);
1188    
1189                    if (count == 0) {
1190                            return null;
1191                    }
1192    
1193                    List<RepositoryEntry> list = findByUuid_C(uuid, companyId, count - 1,
1194                                    count, orderByComparator);
1195    
1196                    if (!list.isEmpty()) {
1197                            return list.get(0);
1198                    }
1199    
1200                    return null;
1201            }
1202    
1203            /**
1204             * Returns the repository entries before and after the current repository entry in the ordered set where uuid = &#63; and companyId = &#63;.
1205             *
1206             * @param repositoryEntryId the primary key of the current repository entry
1207             * @param uuid the uuid
1208             * @param companyId the company ID
1209             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1210             * @return the previous, current, and next repository entry
1211             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
1212             * @throws SystemException if a system exception occurred
1213             */
1214            @Override
1215            public RepositoryEntry[] findByUuid_C_PrevAndNext(long repositoryEntryId,
1216                    String uuid, long companyId, OrderByComparator orderByComparator)
1217                    throws NoSuchRepositoryEntryException, SystemException {
1218                    RepositoryEntry repositoryEntry = findByPrimaryKey(repositoryEntryId);
1219    
1220                    Session session = null;
1221    
1222                    try {
1223                            session = openSession();
1224    
1225                            RepositoryEntry[] array = new RepositoryEntryImpl[3];
1226    
1227                            array[0] = getByUuid_C_PrevAndNext(session, repositoryEntry, uuid,
1228                                            companyId, orderByComparator, true);
1229    
1230                            array[1] = repositoryEntry;
1231    
1232                            array[2] = getByUuid_C_PrevAndNext(session, repositoryEntry, uuid,
1233                                            companyId, orderByComparator, false);
1234    
1235                            return array;
1236                    }
1237                    catch (Exception e) {
1238                            throw processException(e);
1239                    }
1240                    finally {
1241                            closeSession(session);
1242                    }
1243            }
1244    
1245            protected RepositoryEntry getByUuid_C_PrevAndNext(Session session,
1246                    RepositoryEntry repositoryEntry, String uuid, long companyId,
1247                    OrderByComparator orderByComparator, boolean previous) {
1248                    StringBundler query = null;
1249    
1250                    if (orderByComparator != null) {
1251                            query = new StringBundler(6 +
1252                                            (orderByComparator.getOrderByFields().length * 6));
1253                    }
1254                    else {
1255                            query = new StringBundler(3);
1256                    }
1257    
1258                    query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1259    
1260                    boolean bindUuid = false;
1261    
1262                    if (uuid == null) {
1263                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1264                    }
1265                    else if (uuid.equals(StringPool.BLANK)) {
1266                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1267                    }
1268                    else {
1269                            bindUuid = true;
1270    
1271                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1272                    }
1273    
1274                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1275    
1276                    if (orderByComparator != null) {
1277                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1278    
1279                            if (orderByConditionFields.length > 0) {
1280                                    query.append(WHERE_AND);
1281                            }
1282    
1283                            for (int i = 0; i < orderByConditionFields.length; i++) {
1284                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1285                                    query.append(orderByConditionFields[i]);
1286    
1287                                    if ((i + 1) < orderByConditionFields.length) {
1288                                            if (orderByComparator.isAscending() ^ previous) {
1289                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1290                                            }
1291                                            else {
1292                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1293                                            }
1294                                    }
1295                                    else {
1296                                            if (orderByComparator.isAscending() ^ previous) {
1297                                                    query.append(WHERE_GREATER_THAN);
1298                                            }
1299                                            else {
1300                                                    query.append(WHERE_LESSER_THAN);
1301                                            }
1302                                    }
1303                            }
1304    
1305                            query.append(ORDER_BY_CLAUSE);
1306    
1307                            String[] orderByFields = orderByComparator.getOrderByFields();
1308    
1309                            for (int i = 0; i < orderByFields.length; i++) {
1310                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1311                                    query.append(orderByFields[i]);
1312    
1313                                    if ((i + 1) < orderByFields.length) {
1314                                            if (orderByComparator.isAscending() ^ previous) {
1315                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1316                                            }
1317                                            else {
1318                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1319                                            }
1320                                    }
1321                                    else {
1322                                            if (orderByComparator.isAscending() ^ previous) {
1323                                                    query.append(ORDER_BY_ASC);
1324                                            }
1325                                            else {
1326                                                    query.append(ORDER_BY_DESC);
1327                                            }
1328                                    }
1329                            }
1330                    }
1331                    else {
1332                            query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
1333                    }
1334    
1335                    String sql = query.toString();
1336    
1337                    Query q = session.createQuery(sql);
1338    
1339                    q.setFirstResult(0);
1340                    q.setMaxResults(2);
1341    
1342                    QueryPos qPos = QueryPos.getInstance(q);
1343    
1344                    if (bindUuid) {
1345                            qPos.add(uuid);
1346                    }
1347    
1348                    qPos.add(companyId);
1349    
1350                    if (orderByComparator != null) {
1351                            Object[] values = orderByComparator.getOrderByConditionValues(repositoryEntry);
1352    
1353                            for (Object value : values) {
1354                                    qPos.add(value);
1355                            }
1356                    }
1357    
1358                    List<RepositoryEntry> list = q.list();
1359    
1360                    if (list.size() == 2) {
1361                            return list.get(1);
1362                    }
1363                    else {
1364                            return null;
1365                    }
1366            }
1367    
1368            /**
1369             * Removes all the repository entries where uuid = &#63; and companyId = &#63; from the database.
1370             *
1371             * @param uuid the uuid
1372             * @param companyId the company ID
1373             * @throws SystemException if a system exception occurred
1374             */
1375            @Override
1376            public void removeByUuid_C(String uuid, long companyId)
1377                    throws SystemException {
1378                    for (RepositoryEntry repositoryEntry : findByUuid_C(uuid, companyId,
1379                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1380                            remove(repositoryEntry);
1381                    }
1382            }
1383    
1384            /**
1385             * Returns the number of repository entries where uuid = &#63; and companyId = &#63;.
1386             *
1387             * @param uuid the uuid
1388             * @param companyId the company ID
1389             * @return the number of matching repository entries
1390             * @throws SystemException if a system exception occurred
1391             */
1392            @Override
1393            public int countByUuid_C(String uuid, long companyId)
1394                    throws SystemException {
1395                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1396    
1397                    Object[] finderArgs = new Object[] { uuid, companyId };
1398    
1399                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1400                                    this);
1401    
1402                    if (count == null) {
1403                            StringBundler query = new StringBundler(3);
1404    
1405                            query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
1406    
1407                            boolean bindUuid = false;
1408    
1409                            if (uuid == null) {
1410                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1411                            }
1412                            else if (uuid.equals(StringPool.BLANK)) {
1413                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1414                            }
1415                            else {
1416                                    bindUuid = true;
1417    
1418                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1419                            }
1420    
1421                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1422    
1423                            String sql = query.toString();
1424    
1425                            Session session = null;
1426    
1427                            try {
1428                                    session = openSession();
1429    
1430                                    Query q = session.createQuery(sql);
1431    
1432                                    QueryPos qPos = QueryPos.getInstance(q);
1433    
1434                                    if (bindUuid) {
1435                                            qPos.add(uuid);
1436                                    }
1437    
1438                                    qPos.add(companyId);
1439    
1440                                    count = (Long)q.uniqueResult();
1441    
1442                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1443                            }
1444                            catch (Exception e) {
1445                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1446    
1447                                    throw processException(e);
1448                            }
1449                            finally {
1450                                    closeSession(session);
1451                            }
1452                    }
1453    
1454                    return count.intValue();
1455            }
1456    
1457            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "repositoryEntry.uuid IS NULL AND ";
1458            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "repositoryEntry.uuid = ? AND ";
1459            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(repositoryEntry.uuid IS NULL OR repositoryEntry.uuid = '') AND ";
1460            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "repositoryEntry.companyId = ?";
1461            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID =
1462                    new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
1463                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
1464                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1465                            "findByRepositoryId",
1466                            new String[] {
1467                                    Long.class.getName(),
1468                                    
1469                            Integer.class.getName(), Integer.class.getName(),
1470                                    OrderByComparator.class.getName()
1471                            });
1472            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID =
1473                    new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
1474                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
1475                            RepositoryEntryImpl.class,
1476                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByRepositoryId",
1477                            new String[] { Long.class.getName() },
1478                            RepositoryEntryModelImpl.REPOSITORYID_COLUMN_BITMASK);
1479            public static final FinderPath FINDER_PATH_COUNT_BY_REPOSITORYID = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
1480                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1481                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByRepositoryId",
1482                            new String[] { Long.class.getName() });
1483    
1484            /**
1485             * Returns all the repository entries where repositoryId = &#63;.
1486             *
1487             * @param repositoryId the repository ID
1488             * @return the matching repository entries
1489             * @throws SystemException if a system exception occurred
1490             */
1491            @Override
1492            public List<RepositoryEntry> findByRepositoryId(long repositoryId)
1493                    throws SystemException {
1494                    return findByRepositoryId(repositoryId, QueryUtil.ALL_POS,
1495                            QueryUtil.ALL_POS, null);
1496            }
1497    
1498            /**
1499             * Returns a range of all the repository entries where repositoryId = &#63;.
1500             *
1501             * <p>
1502             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1503             * </p>
1504             *
1505             * @param repositoryId the repository ID
1506             * @param start the lower bound of the range of repository entries
1507             * @param end the upper bound of the range of repository entries (not inclusive)
1508             * @return the range of matching repository entries
1509             * @throws SystemException if a system exception occurred
1510             */
1511            @Override
1512            public List<RepositoryEntry> findByRepositoryId(long repositoryId,
1513                    int start, int end) throws SystemException {
1514                    return findByRepositoryId(repositoryId, start, end, null);
1515            }
1516    
1517            /**
1518             * Returns an ordered range of all the repository entries where repositoryId = &#63;.
1519             *
1520             * <p>
1521             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
1522             * </p>
1523             *
1524             * @param repositoryId the repository ID
1525             * @param start the lower bound of the range of repository entries
1526             * @param end the upper bound of the range of repository entries (not inclusive)
1527             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1528             * @return the ordered range of matching repository entries
1529             * @throws SystemException if a system exception occurred
1530             */
1531            @Override
1532            public List<RepositoryEntry> findByRepositoryId(long repositoryId,
1533                    int start, int end, OrderByComparator orderByComparator)
1534                    throws SystemException {
1535                    boolean pagination = true;
1536                    FinderPath finderPath = null;
1537                    Object[] finderArgs = null;
1538    
1539                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1540                                    (orderByComparator == null)) {
1541                            pagination = false;
1542                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID;
1543                            finderArgs = new Object[] { repositoryId };
1544                    }
1545                    else {
1546                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_REPOSITORYID;
1547                            finderArgs = new Object[] {
1548                                            repositoryId,
1549                                            
1550                                            start, end, orderByComparator
1551                                    };
1552                    }
1553    
1554                    List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
1555                                    finderArgs, this);
1556    
1557                    if ((list != null) && !list.isEmpty()) {
1558                            for (RepositoryEntry repositoryEntry : list) {
1559                                    if ((repositoryId != repositoryEntry.getRepositoryId())) {
1560                                            list = null;
1561    
1562                                            break;
1563                                    }
1564                            }
1565                    }
1566    
1567                    if (list == null) {
1568                            StringBundler query = null;
1569    
1570                            if (orderByComparator != null) {
1571                                    query = new StringBundler(3 +
1572                                                    (orderByComparator.getOrderByFields().length * 3));
1573                            }
1574                            else {
1575                                    query = new StringBundler(3);
1576                            }
1577    
1578                            query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1579    
1580                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1581    
1582                            if (orderByComparator != null) {
1583                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1584                                            orderByComparator);
1585                            }
1586                            else
1587                             if (pagination) {
1588                                    query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
1589                            }
1590    
1591                            String sql = query.toString();
1592    
1593                            Session session = null;
1594    
1595                            try {
1596                                    session = openSession();
1597    
1598                                    Query q = session.createQuery(sql);
1599    
1600                                    QueryPos qPos = QueryPos.getInstance(q);
1601    
1602                                    qPos.add(repositoryId);
1603    
1604                                    if (!pagination) {
1605                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
1606                                                            getDialect(), start, end, false);
1607    
1608                                            Collections.sort(list);
1609    
1610                                            list = new UnmodifiableList<RepositoryEntry>(list);
1611                                    }
1612                                    else {
1613                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
1614                                                            getDialect(), start, end);
1615                                    }
1616    
1617                                    cacheResult(list);
1618    
1619                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
1620                            }
1621                            catch (Exception e) {
1622                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1623    
1624                                    throw processException(e);
1625                            }
1626                            finally {
1627                                    closeSession(session);
1628                            }
1629                    }
1630    
1631                    return list;
1632            }
1633    
1634            /**
1635             * Returns the first repository entry in the ordered set where repositoryId = &#63;.
1636             *
1637             * @param repositoryId the repository ID
1638             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1639             * @return the first matching repository entry
1640             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
1641             * @throws SystemException if a system exception occurred
1642             */
1643            @Override
1644            public RepositoryEntry findByRepositoryId_First(long repositoryId,
1645                    OrderByComparator orderByComparator)
1646                    throws NoSuchRepositoryEntryException, SystemException {
1647                    RepositoryEntry repositoryEntry = fetchByRepositoryId_First(repositoryId,
1648                                    orderByComparator);
1649    
1650                    if (repositoryEntry != null) {
1651                            return repositoryEntry;
1652                    }
1653    
1654                    StringBundler msg = new StringBundler(4);
1655    
1656                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1657    
1658                    msg.append("repositoryId=");
1659                    msg.append(repositoryId);
1660    
1661                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1662    
1663                    throw new NoSuchRepositoryEntryException(msg.toString());
1664            }
1665    
1666            /**
1667             * Returns the first repository entry in the ordered set where repositoryId = &#63;.
1668             *
1669             * @param repositoryId the repository ID
1670             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1671             * @return the first matching repository entry, or <code>null</code> if a matching repository entry could not be found
1672             * @throws SystemException if a system exception occurred
1673             */
1674            @Override
1675            public RepositoryEntry fetchByRepositoryId_First(long repositoryId,
1676                    OrderByComparator orderByComparator) throws SystemException {
1677                    List<RepositoryEntry> list = findByRepositoryId(repositoryId, 0, 1,
1678                                    orderByComparator);
1679    
1680                    if (!list.isEmpty()) {
1681                            return list.get(0);
1682                    }
1683    
1684                    return null;
1685            }
1686    
1687            /**
1688             * Returns the last repository entry in the ordered set where repositoryId = &#63;.
1689             *
1690             * @param repositoryId the repository ID
1691             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1692             * @return the last matching repository entry
1693             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
1694             * @throws SystemException if a system exception occurred
1695             */
1696            @Override
1697            public RepositoryEntry findByRepositoryId_Last(long repositoryId,
1698                    OrderByComparator orderByComparator)
1699                    throws NoSuchRepositoryEntryException, SystemException {
1700                    RepositoryEntry repositoryEntry = fetchByRepositoryId_Last(repositoryId,
1701                                    orderByComparator);
1702    
1703                    if (repositoryEntry != null) {
1704                            return repositoryEntry;
1705                    }
1706    
1707                    StringBundler msg = new StringBundler(4);
1708    
1709                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1710    
1711                    msg.append("repositoryId=");
1712                    msg.append(repositoryId);
1713    
1714                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1715    
1716                    throw new NoSuchRepositoryEntryException(msg.toString());
1717            }
1718    
1719            /**
1720             * Returns the last repository entry in the ordered set where repositoryId = &#63;.
1721             *
1722             * @param repositoryId the repository ID
1723             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1724             * @return the last matching repository entry, or <code>null</code> if a matching repository entry could not be found
1725             * @throws SystemException if a system exception occurred
1726             */
1727            @Override
1728            public RepositoryEntry fetchByRepositoryId_Last(long repositoryId,
1729                    OrderByComparator orderByComparator) throws SystemException {
1730                    int count = countByRepositoryId(repositoryId);
1731    
1732                    if (count == 0) {
1733                            return null;
1734                    }
1735    
1736                    List<RepositoryEntry> list = findByRepositoryId(repositoryId,
1737                                    count - 1, count, orderByComparator);
1738    
1739                    if (!list.isEmpty()) {
1740                            return list.get(0);
1741                    }
1742    
1743                    return null;
1744            }
1745    
1746            /**
1747             * Returns the repository entries before and after the current repository entry in the ordered set where repositoryId = &#63;.
1748             *
1749             * @param repositoryEntryId the primary key of the current repository entry
1750             * @param repositoryId the repository ID
1751             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1752             * @return the previous, current, and next repository entry
1753             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
1754             * @throws SystemException if a system exception occurred
1755             */
1756            @Override
1757            public RepositoryEntry[] findByRepositoryId_PrevAndNext(
1758                    long repositoryEntryId, long repositoryId,
1759                    OrderByComparator orderByComparator)
1760                    throws NoSuchRepositoryEntryException, SystemException {
1761                    RepositoryEntry repositoryEntry = findByPrimaryKey(repositoryEntryId);
1762    
1763                    Session session = null;
1764    
1765                    try {
1766                            session = openSession();
1767    
1768                            RepositoryEntry[] array = new RepositoryEntryImpl[3];
1769    
1770                            array[0] = getByRepositoryId_PrevAndNext(session, repositoryEntry,
1771                                            repositoryId, orderByComparator, true);
1772    
1773                            array[1] = repositoryEntry;
1774    
1775                            array[2] = getByRepositoryId_PrevAndNext(session, repositoryEntry,
1776                                            repositoryId, orderByComparator, false);
1777    
1778                            return array;
1779                    }
1780                    catch (Exception e) {
1781                            throw processException(e);
1782                    }
1783                    finally {
1784                            closeSession(session);
1785                    }
1786            }
1787    
1788            protected RepositoryEntry getByRepositoryId_PrevAndNext(Session session,
1789                    RepositoryEntry repositoryEntry, long repositoryId,
1790                    OrderByComparator orderByComparator, boolean previous) {
1791                    StringBundler query = null;
1792    
1793                    if (orderByComparator != null) {
1794                            query = new StringBundler(6 +
1795                                            (orderByComparator.getOrderByFields().length * 6));
1796                    }
1797                    else {
1798                            query = new StringBundler(3);
1799                    }
1800    
1801                    query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
1802    
1803                    query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1804    
1805                    if (orderByComparator != null) {
1806                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1807    
1808                            if (orderByConditionFields.length > 0) {
1809                                    query.append(WHERE_AND);
1810                            }
1811    
1812                            for (int i = 0; i < orderByConditionFields.length; i++) {
1813                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1814                                    query.append(orderByConditionFields[i]);
1815    
1816                                    if ((i + 1) < orderByConditionFields.length) {
1817                                            if (orderByComparator.isAscending() ^ previous) {
1818                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1819                                            }
1820                                            else {
1821                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1822                                            }
1823                                    }
1824                                    else {
1825                                            if (orderByComparator.isAscending() ^ previous) {
1826                                                    query.append(WHERE_GREATER_THAN);
1827                                            }
1828                                            else {
1829                                                    query.append(WHERE_LESSER_THAN);
1830                                            }
1831                                    }
1832                            }
1833    
1834                            query.append(ORDER_BY_CLAUSE);
1835    
1836                            String[] orderByFields = orderByComparator.getOrderByFields();
1837    
1838                            for (int i = 0; i < orderByFields.length; i++) {
1839                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1840                                    query.append(orderByFields[i]);
1841    
1842                                    if ((i + 1) < orderByFields.length) {
1843                                            if (orderByComparator.isAscending() ^ previous) {
1844                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1845                                            }
1846                                            else {
1847                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1848                                            }
1849                                    }
1850                                    else {
1851                                            if (orderByComparator.isAscending() ^ previous) {
1852                                                    query.append(ORDER_BY_ASC);
1853                                            }
1854                                            else {
1855                                                    query.append(ORDER_BY_DESC);
1856                                            }
1857                                    }
1858                            }
1859                    }
1860                    else {
1861                            query.append(RepositoryEntryModelImpl.ORDER_BY_JPQL);
1862                    }
1863    
1864                    String sql = query.toString();
1865    
1866                    Query q = session.createQuery(sql);
1867    
1868                    q.setFirstResult(0);
1869                    q.setMaxResults(2);
1870    
1871                    QueryPos qPos = QueryPos.getInstance(q);
1872    
1873                    qPos.add(repositoryId);
1874    
1875                    if (orderByComparator != null) {
1876                            Object[] values = orderByComparator.getOrderByConditionValues(repositoryEntry);
1877    
1878                            for (Object value : values) {
1879                                    qPos.add(value);
1880                            }
1881                    }
1882    
1883                    List<RepositoryEntry> list = q.list();
1884    
1885                    if (list.size() == 2) {
1886                            return list.get(1);
1887                    }
1888                    else {
1889                            return null;
1890                    }
1891            }
1892    
1893            /**
1894             * Removes all the repository entries where repositoryId = &#63; from the database.
1895             *
1896             * @param repositoryId the repository ID
1897             * @throws SystemException if a system exception occurred
1898             */
1899            @Override
1900            public void removeByRepositoryId(long repositoryId)
1901                    throws SystemException {
1902                    for (RepositoryEntry repositoryEntry : findByRepositoryId(
1903                                    repositoryId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1904                            remove(repositoryEntry);
1905                    }
1906            }
1907    
1908            /**
1909             * Returns the number of repository entries where repositoryId = &#63;.
1910             *
1911             * @param repositoryId the repository ID
1912             * @return the number of matching repository entries
1913             * @throws SystemException if a system exception occurred
1914             */
1915            @Override
1916            public int countByRepositoryId(long repositoryId) throws SystemException {
1917                    FinderPath finderPath = FINDER_PATH_COUNT_BY_REPOSITORYID;
1918    
1919                    Object[] finderArgs = new Object[] { repositoryId };
1920    
1921                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
1922                                    this);
1923    
1924                    if (count == null) {
1925                            StringBundler query = new StringBundler(2);
1926    
1927                            query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
1928    
1929                            query.append(_FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2);
1930    
1931                            String sql = query.toString();
1932    
1933                            Session session = null;
1934    
1935                            try {
1936                                    session = openSession();
1937    
1938                                    Query q = session.createQuery(sql);
1939    
1940                                    QueryPos qPos = QueryPos.getInstance(q);
1941    
1942                                    qPos.add(repositoryId);
1943    
1944                                    count = (Long)q.uniqueResult();
1945    
1946                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
1947                            }
1948                            catch (Exception e) {
1949                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
1950    
1951                                    throw processException(e);
1952                            }
1953                            finally {
1954                                    closeSession(session);
1955                            }
1956                    }
1957    
1958                    return count.intValue();
1959            }
1960    
1961            private static final String _FINDER_COLUMN_REPOSITORYID_REPOSITORYID_2 = "repositoryEntry.repositoryId = ?";
1962            public static final FinderPath FINDER_PATH_FETCH_BY_R_M = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
1963                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED,
1964                            RepositoryEntryImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByR_M",
1965                            new String[] { Long.class.getName(), String.class.getName() },
1966                            RepositoryEntryModelImpl.REPOSITORYID_COLUMN_BITMASK |
1967                            RepositoryEntryModelImpl.MAPPEDID_COLUMN_BITMASK);
1968            public static final FinderPath FINDER_PATH_COUNT_BY_R_M = new FinderPath(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
1969                            RepositoryEntryModelImpl.FINDER_CACHE_ENABLED, Long.class,
1970                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByR_M",
1971                            new String[] { Long.class.getName(), String.class.getName() });
1972    
1973            /**
1974             * Returns the repository entry where repositoryId = &#63; and mappedId = &#63; or throws a {@link com.liferay.portal.NoSuchRepositoryEntryException} if it could not be found.
1975             *
1976             * @param repositoryId the repository ID
1977             * @param mappedId the mapped ID
1978             * @return the matching repository entry
1979             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a matching repository entry could not be found
1980             * @throws SystemException if a system exception occurred
1981             */
1982            @Override
1983            public RepositoryEntry findByR_M(long repositoryId, String mappedId)
1984                    throws NoSuchRepositoryEntryException, SystemException {
1985                    RepositoryEntry repositoryEntry = fetchByR_M(repositoryId, mappedId);
1986    
1987                    if (repositoryEntry == null) {
1988                            StringBundler msg = new StringBundler(6);
1989    
1990                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1991    
1992                            msg.append("repositoryId=");
1993                            msg.append(repositoryId);
1994    
1995                            msg.append(", mappedId=");
1996                            msg.append(mappedId);
1997    
1998                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1999    
2000                            if (_log.isWarnEnabled()) {
2001                                    _log.warn(msg.toString());
2002                            }
2003    
2004                            throw new NoSuchRepositoryEntryException(msg.toString());
2005                    }
2006    
2007                    return repositoryEntry;
2008            }
2009    
2010            /**
2011             * Returns the repository entry where repositoryId = &#63; and mappedId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2012             *
2013             * @param repositoryId the repository ID
2014             * @param mappedId the mapped ID
2015             * @return the matching repository entry, or <code>null</code> if a matching repository entry could not be found
2016             * @throws SystemException if a system exception occurred
2017             */
2018            @Override
2019            public RepositoryEntry fetchByR_M(long repositoryId, String mappedId)
2020                    throws SystemException {
2021                    return fetchByR_M(repositoryId, mappedId, true);
2022            }
2023    
2024            /**
2025             * Returns the repository entry where repositoryId = &#63; and mappedId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2026             *
2027             * @param repositoryId the repository ID
2028             * @param mappedId the mapped ID
2029             * @param retrieveFromCache whether to use the finder cache
2030             * @return the matching repository entry, or <code>null</code> if a matching repository entry could not be found
2031             * @throws SystemException if a system exception occurred
2032             */
2033            @Override
2034            public RepositoryEntry fetchByR_M(long repositoryId, String mappedId,
2035                    boolean retrieveFromCache) throws SystemException {
2036                    Object[] finderArgs = new Object[] { repositoryId, mappedId };
2037    
2038                    Object result = null;
2039    
2040                    if (retrieveFromCache) {
2041                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_R_M,
2042                                            finderArgs, this);
2043                    }
2044    
2045                    if (result instanceof RepositoryEntry) {
2046                            RepositoryEntry repositoryEntry = (RepositoryEntry)result;
2047    
2048                            if ((repositoryId != repositoryEntry.getRepositoryId()) ||
2049                                            !Validator.equals(mappedId, repositoryEntry.getMappedId())) {
2050                                    result = null;
2051                            }
2052                    }
2053    
2054                    if (result == null) {
2055                            StringBundler query = new StringBundler(4);
2056    
2057                            query.append(_SQL_SELECT_REPOSITORYENTRY_WHERE);
2058    
2059                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
2060    
2061                            boolean bindMappedId = false;
2062    
2063                            if (mappedId == null) {
2064                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_1);
2065                            }
2066                            else if (mappedId.equals(StringPool.BLANK)) {
2067                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_3);
2068                            }
2069                            else {
2070                                    bindMappedId = true;
2071    
2072                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_2);
2073                            }
2074    
2075                            String sql = query.toString();
2076    
2077                            Session session = null;
2078    
2079                            try {
2080                                    session = openSession();
2081    
2082                                    Query q = session.createQuery(sql);
2083    
2084                                    QueryPos qPos = QueryPos.getInstance(q);
2085    
2086                                    qPos.add(repositoryId);
2087    
2088                                    if (bindMappedId) {
2089                                            qPos.add(mappedId);
2090                                    }
2091    
2092                                    List<RepositoryEntry> list = q.list();
2093    
2094                                    if (list.isEmpty()) {
2095                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
2096                                                    finderArgs, list);
2097                                    }
2098                                    else {
2099                                            RepositoryEntry repositoryEntry = list.get(0);
2100    
2101                                            result = repositoryEntry;
2102    
2103                                            cacheResult(repositoryEntry);
2104    
2105                                            if ((repositoryEntry.getRepositoryId() != repositoryId) ||
2106                                                            (repositoryEntry.getMappedId() == null) ||
2107                                                            !repositoryEntry.getMappedId().equals(mappedId)) {
2108                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
2109                                                            finderArgs, repositoryEntry);
2110                                            }
2111                                    }
2112                            }
2113                            catch (Exception e) {
2114                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M,
2115                                            finderArgs);
2116    
2117                                    throw processException(e);
2118                            }
2119                            finally {
2120                                    closeSession(session);
2121                            }
2122                    }
2123    
2124                    if (result instanceof List<?>) {
2125                            return null;
2126                    }
2127                    else {
2128                            return (RepositoryEntry)result;
2129                    }
2130            }
2131    
2132            /**
2133             * Removes the repository entry where repositoryId = &#63; and mappedId = &#63; from the database.
2134             *
2135             * @param repositoryId the repository ID
2136             * @param mappedId the mapped ID
2137             * @return the repository entry that was removed
2138             * @throws SystemException if a system exception occurred
2139             */
2140            @Override
2141            public RepositoryEntry removeByR_M(long repositoryId, String mappedId)
2142                    throws NoSuchRepositoryEntryException, SystemException {
2143                    RepositoryEntry repositoryEntry = findByR_M(repositoryId, mappedId);
2144    
2145                    return remove(repositoryEntry);
2146            }
2147    
2148            /**
2149             * Returns the number of repository entries where repositoryId = &#63; and mappedId = &#63;.
2150             *
2151             * @param repositoryId the repository ID
2152             * @param mappedId the mapped ID
2153             * @return the number of matching repository entries
2154             * @throws SystemException if a system exception occurred
2155             */
2156            @Override
2157            public int countByR_M(long repositoryId, String mappedId)
2158                    throws SystemException {
2159                    FinderPath finderPath = FINDER_PATH_COUNT_BY_R_M;
2160    
2161                    Object[] finderArgs = new Object[] { repositoryId, mappedId };
2162    
2163                    Long count = (Long)FinderCacheUtil.getResult(finderPath, finderArgs,
2164                                    this);
2165    
2166                    if (count == null) {
2167                            StringBundler query = new StringBundler(3);
2168    
2169                            query.append(_SQL_COUNT_REPOSITORYENTRY_WHERE);
2170    
2171                            query.append(_FINDER_COLUMN_R_M_REPOSITORYID_2);
2172    
2173                            boolean bindMappedId = false;
2174    
2175                            if (mappedId == null) {
2176                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_1);
2177                            }
2178                            else if (mappedId.equals(StringPool.BLANK)) {
2179                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_3);
2180                            }
2181                            else {
2182                                    bindMappedId = true;
2183    
2184                                    query.append(_FINDER_COLUMN_R_M_MAPPEDID_2);
2185                            }
2186    
2187                            String sql = query.toString();
2188    
2189                            Session session = null;
2190    
2191                            try {
2192                                    session = openSession();
2193    
2194                                    Query q = session.createQuery(sql);
2195    
2196                                    QueryPos qPos = QueryPos.getInstance(q);
2197    
2198                                    qPos.add(repositoryId);
2199    
2200                                    if (bindMappedId) {
2201                                            qPos.add(mappedId);
2202                                    }
2203    
2204                                    count = (Long)q.uniqueResult();
2205    
2206                                    FinderCacheUtil.putResult(finderPath, finderArgs, count);
2207                            }
2208                            catch (Exception e) {
2209                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2210    
2211                                    throw processException(e);
2212                            }
2213                            finally {
2214                                    closeSession(session);
2215                            }
2216                    }
2217    
2218                    return count.intValue();
2219            }
2220    
2221            private static final String _FINDER_COLUMN_R_M_REPOSITORYID_2 = "repositoryEntry.repositoryId = ? AND ";
2222            private static final String _FINDER_COLUMN_R_M_MAPPEDID_1 = "repositoryEntry.mappedId IS NULL";
2223            private static final String _FINDER_COLUMN_R_M_MAPPEDID_2 = "repositoryEntry.mappedId = ?";
2224            private static final String _FINDER_COLUMN_R_M_MAPPEDID_3 = "(repositoryEntry.mappedId IS NULL OR repositoryEntry.mappedId = '')";
2225    
2226            public RepositoryEntryPersistenceImpl() {
2227                    setModelClass(RepositoryEntry.class);
2228            }
2229    
2230            /**
2231             * Caches the repository entry in the entity cache if it is enabled.
2232             *
2233             * @param repositoryEntry the repository entry
2234             */
2235            @Override
2236            public void cacheResult(RepositoryEntry repositoryEntry) {
2237                    EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2238                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
2239                            repositoryEntry);
2240    
2241                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2242                            new Object[] { repositoryEntry.getUuid(), repositoryEntry.getGroupId() },
2243                            repositoryEntry);
2244    
2245                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
2246                            new Object[] {
2247                                    repositoryEntry.getRepositoryId(), repositoryEntry.getMappedId()
2248                            }, repositoryEntry);
2249    
2250                    repositoryEntry.resetOriginalValues();
2251            }
2252    
2253            /**
2254             * Caches the repository entries in the entity cache if it is enabled.
2255             *
2256             * @param repositoryEntries the repository entries
2257             */
2258            @Override
2259            public void cacheResult(List<RepositoryEntry> repositoryEntries) {
2260                    for (RepositoryEntry repositoryEntry : repositoryEntries) {
2261                            if (EntityCacheUtil.getResult(
2262                                                    RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2263                                                    RepositoryEntryImpl.class,
2264                                                    repositoryEntry.getPrimaryKey()) == null) {
2265                                    cacheResult(repositoryEntry);
2266                            }
2267                            else {
2268                                    repositoryEntry.resetOriginalValues();
2269                            }
2270                    }
2271            }
2272    
2273            /**
2274             * Clears the cache for all repository entries.
2275             *
2276             * <p>
2277             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2278             * </p>
2279             */
2280            @Override
2281            public void clearCache() {
2282                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2283                            CacheRegistryUtil.clear(RepositoryEntryImpl.class.getName());
2284                    }
2285    
2286                    EntityCacheUtil.clearCache(RepositoryEntryImpl.class.getName());
2287    
2288                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2289                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2290                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2291            }
2292    
2293            /**
2294             * Clears the cache for the repository entry.
2295             *
2296             * <p>
2297             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2298             * </p>
2299             */
2300            @Override
2301            public void clearCache(RepositoryEntry repositoryEntry) {
2302                    EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2303                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
2304    
2305                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2306                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2307    
2308                    clearUniqueFindersCache(repositoryEntry);
2309            }
2310    
2311            @Override
2312            public void clearCache(List<RepositoryEntry> repositoryEntries) {
2313                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2314                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2315    
2316                    for (RepositoryEntry repositoryEntry : repositoryEntries) {
2317                            EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2318                                    RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
2319    
2320                            clearUniqueFindersCache(repositoryEntry);
2321                    }
2322            }
2323    
2324            protected void cacheUniqueFindersCache(RepositoryEntry repositoryEntry) {
2325                    if (repositoryEntry.isNew()) {
2326                            Object[] args = new Object[] {
2327                                            repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2328                                    };
2329    
2330                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2331                                    Long.valueOf(1));
2332                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2333                                    repositoryEntry);
2334    
2335                            args = new Object[] {
2336                                            repositoryEntry.getRepositoryId(),
2337                                            repositoryEntry.getMappedId()
2338                                    };
2339    
2340                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
2341                                    Long.valueOf(1));
2342                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args,
2343                                    repositoryEntry);
2344                    }
2345                    else {
2346                            RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2347    
2348                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2349                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2350                                    Object[] args = new Object[] {
2351                                                    repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2352                                            };
2353    
2354                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2355                                            Long.valueOf(1));
2356                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2357                                            repositoryEntry);
2358                            }
2359    
2360                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2361                                            FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
2362                                    Object[] args = new Object[] {
2363                                                    repositoryEntry.getRepositoryId(),
2364                                                    repositoryEntry.getMappedId()
2365                                            };
2366    
2367                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
2368                                            Long.valueOf(1));
2369                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args,
2370                                            repositoryEntry);
2371                            }
2372                    }
2373            }
2374    
2375            protected void clearUniqueFindersCache(RepositoryEntry repositoryEntry) {
2376                    RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2377    
2378                    Object[] args = new Object[] {
2379                                    repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2380                            };
2381    
2382                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2383                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2384    
2385                    if ((repositoryEntryModelImpl.getColumnBitmask() &
2386                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2387                            args = new Object[] {
2388                                            repositoryEntryModelImpl.getOriginalUuid(),
2389                                            repositoryEntryModelImpl.getOriginalGroupId()
2390                                    };
2391    
2392                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2393                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2394                    }
2395    
2396                    args = new Object[] {
2397                                    repositoryEntry.getRepositoryId(), repositoryEntry.getMappedId()
2398                            };
2399    
2400                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
2401                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
2402    
2403                    if ((repositoryEntryModelImpl.getColumnBitmask() &
2404                                    FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
2405                            args = new Object[] {
2406                                            repositoryEntryModelImpl.getOriginalRepositoryId(),
2407                                            repositoryEntryModelImpl.getOriginalMappedId()
2408                                    };
2409    
2410                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
2411                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
2412                    }
2413            }
2414    
2415            /**
2416             * Creates a new repository entry with the primary key. Does not add the repository entry to the database.
2417             *
2418             * @param repositoryEntryId the primary key for the new repository entry
2419             * @return the new repository entry
2420             */
2421            @Override
2422            public RepositoryEntry create(long repositoryEntryId) {
2423                    RepositoryEntry repositoryEntry = new RepositoryEntryImpl();
2424    
2425                    repositoryEntry.setNew(true);
2426                    repositoryEntry.setPrimaryKey(repositoryEntryId);
2427    
2428                    String uuid = PortalUUIDUtil.generate();
2429    
2430                    repositoryEntry.setUuid(uuid);
2431    
2432                    return repositoryEntry;
2433            }
2434    
2435            /**
2436             * Removes the repository entry with the primary key from the database. Also notifies the appropriate model listeners.
2437             *
2438             * @param repositoryEntryId the primary key of the repository entry
2439             * @return the repository entry that was removed
2440             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2441             * @throws SystemException if a system exception occurred
2442             */
2443            @Override
2444            public RepositoryEntry remove(long repositoryEntryId)
2445                    throws NoSuchRepositoryEntryException, SystemException {
2446                    return remove((Serializable)repositoryEntryId);
2447            }
2448    
2449            /**
2450             * Removes the repository entry with the primary key from the database. Also notifies the appropriate model listeners.
2451             *
2452             * @param primaryKey the primary key of the repository entry
2453             * @return the repository entry that was removed
2454             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2455             * @throws SystemException if a system exception occurred
2456             */
2457            @Override
2458            public RepositoryEntry remove(Serializable primaryKey)
2459                    throws NoSuchRepositoryEntryException, SystemException {
2460                    Session session = null;
2461    
2462                    try {
2463                            session = openSession();
2464    
2465                            RepositoryEntry repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2466                                            primaryKey);
2467    
2468                            if (repositoryEntry == null) {
2469                                    if (_log.isWarnEnabled()) {
2470                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2471                                    }
2472    
2473                                    throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2474                                            primaryKey);
2475                            }
2476    
2477                            return remove(repositoryEntry);
2478                    }
2479                    catch (NoSuchRepositoryEntryException nsee) {
2480                            throw nsee;
2481                    }
2482                    catch (Exception e) {
2483                            throw processException(e);
2484                    }
2485                    finally {
2486                            closeSession(session);
2487                    }
2488            }
2489    
2490            @Override
2491            protected RepositoryEntry removeImpl(RepositoryEntry repositoryEntry)
2492                    throws SystemException {
2493                    repositoryEntry = toUnwrappedModel(repositoryEntry);
2494    
2495                    Session session = null;
2496    
2497                    try {
2498                            session = openSession();
2499    
2500                            if (!session.contains(repositoryEntry)) {
2501                                    repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2502                                                    repositoryEntry.getPrimaryKeyObj());
2503                            }
2504    
2505                            if (repositoryEntry != null) {
2506                                    session.delete(repositoryEntry);
2507                            }
2508                    }
2509                    catch (Exception e) {
2510                            throw processException(e);
2511                    }
2512                    finally {
2513                            closeSession(session);
2514                    }
2515    
2516                    if (repositoryEntry != null) {
2517                            clearCache(repositoryEntry);
2518                    }
2519    
2520                    return repositoryEntry;
2521            }
2522    
2523            @Override
2524            public RepositoryEntry updateImpl(
2525                    com.liferay.portal.model.RepositoryEntry repositoryEntry)
2526                    throws SystemException {
2527                    repositoryEntry = toUnwrappedModel(repositoryEntry);
2528    
2529                    boolean isNew = repositoryEntry.isNew();
2530    
2531                    RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2532    
2533                    if (Validator.isNull(repositoryEntry.getUuid())) {
2534                            String uuid = PortalUUIDUtil.generate();
2535    
2536                            repositoryEntry.setUuid(uuid);
2537                    }
2538    
2539                    Session session = null;
2540    
2541                    try {
2542                            session = openSession();
2543    
2544                            if (repositoryEntry.isNew()) {
2545                                    session.save(repositoryEntry);
2546    
2547                                    repositoryEntry.setNew(false);
2548                            }
2549                            else {
2550                                    session.merge(repositoryEntry);
2551                            }
2552                    }
2553                    catch (Exception e) {
2554                            throw processException(e);
2555                    }
2556                    finally {
2557                            closeSession(session);
2558                    }
2559    
2560                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2561    
2562                    if (isNew || !RepositoryEntryModelImpl.COLUMN_BITMASK_ENABLED) {
2563                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2564                    }
2565    
2566                    else {
2567                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2568                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2569                                    Object[] args = new Object[] {
2570                                                    repositoryEntryModelImpl.getOriginalUuid()
2571                                            };
2572    
2573                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2574                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2575                                            args);
2576    
2577                                    args = new Object[] { repositoryEntryModelImpl.getUuid() };
2578    
2579                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2580                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2581                                            args);
2582                            }
2583    
2584                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2585                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2586                                    Object[] args = new Object[] {
2587                                                    repositoryEntryModelImpl.getOriginalUuid(),
2588                                                    repositoryEntryModelImpl.getOriginalCompanyId()
2589                                            };
2590    
2591                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2592                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2593                                            args);
2594    
2595                                    args = new Object[] {
2596                                                    repositoryEntryModelImpl.getUuid(),
2597                                                    repositoryEntryModelImpl.getCompanyId()
2598                                            };
2599    
2600                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2601                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2602                                            args);
2603                            }
2604    
2605                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2606                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
2607                                    Object[] args = new Object[] {
2608                                                    repositoryEntryModelImpl.getOriginalRepositoryId()
2609                                            };
2610    
2611                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
2612                                            args);
2613                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
2614                                            args);
2615    
2616                                    args = new Object[] { repositoryEntryModelImpl.getRepositoryId() };
2617    
2618                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
2619                                            args);
2620                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
2621                                            args);
2622                            }
2623                    }
2624    
2625                    EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2626                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
2627                            repositoryEntry);
2628    
2629                    clearUniqueFindersCache(repositoryEntry);
2630                    cacheUniqueFindersCache(repositoryEntry);
2631    
2632                    return repositoryEntry;
2633            }
2634    
2635            protected RepositoryEntry toUnwrappedModel(RepositoryEntry repositoryEntry) {
2636                    if (repositoryEntry instanceof RepositoryEntryImpl) {
2637                            return repositoryEntry;
2638                    }
2639    
2640                    RepositoryEntryImpl repositoryEntryImpl = new RepositoryEntryImpl();
2641    
2642                    repositoryEntryImpl.setNew(repositoryEntry.isNew());
2643                    repositoryEntryImpl.setPrimaryKey(repositoryEntry.getPrimaryKey());
2644    
2645                    repositoryEntryImpl.setUuid(repositoryEntry.getUuid());
2646                    repositoryEntryImpl.setRepositoryEntryId(repositoryEntry.getRepositoryEntryId());
2647                    repositoryEntryImpl.setGroupId(repositoryEntry.getGroupId());
2648                    repositoryEntryImpl.setCompanyId(repositoryEntry.getCompanyId());
2649                    repositoryEntryImpl.setUserId(repositoryEntry.getUserId());
2650                    repositoryEntryImpl.setUserName(repositoryEntry.getUserName());
2651                    repositoryEntryImpl.setCreateDate(repositoryEntry.getCreateDate());
2652                    repositoryEntryImpl.setModifiedDate(repositoryEntry.getModifiedDate());
2653                    repositoryEntryImpl.setRepositoryId(repositoryEntry.getRepositoryId());
2654                    repositoryEntryImpl.setMappedId(repositoryEntry.getMappedId());
2655                    repositoryEntryImpl.setManualCheckInRequired(repositoryEntry.isManualCheckInRequired());
2656    
2657                    return repositoryEntryImpl;
2658            }
2659    
2660            /**
2661             * Returns the repository entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2662             *
2663             * @param primaryKey the primary key of the repository entry
2664             * @return the repository entry
2665             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2666             * @throws SystemException if a system exception occurred
2667             */
2668            @Override
2669            public RepositoryEntry findByPrimaryKey(Serializable primaryKey)
2670                    throws NoSuchRepositoryEntryException, SystemException {
2671                    RepositoryEntry repositoryEntry = fetchByPrimaryKey(primaryKey);
2672    
2673                    if (repositoryEntry == null) {
2674                            if (_log.isWarnEnabled()) {
2675                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2676                            }
2677    
2678                            throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2679                                    primaryKey);
2680                    }
2681    
2682                    return repositoryEntry;
2683            }
2684    
2685            /**
2686             * Returns the repository entry with the primary key or throws a {@link com.liferay.portal.NoSuchRepositoryEntryException} if it could not be found.
2687             *
2688             * @param repositoryEntryId the primary key of the repository entry
2689             * @return the repository entry
2690             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2691             * @throws SystemException if a system exception occurred
2692             */
2693            @Override
2694            public RepositoryEntry findByPrimaryKey(long repositoryEntryId)
2695                    throws NoSuchRepositoryEntryException, SystemException {
2696                    return findByPrimaryKey((Serializable)repositoryEntryId);
2697            }
2698    
2699            /**
2700             * Returns the repository entry with the primary key or returns <code>null</code> if it could not be found.
2701             *
2702             * @param primaryKey the primary key of the repository entry
2703             * @return the repository entry, or <code>null</code> if a repository entry with the primary key could not be found
2704             * @throws SystemException if a system exception occurred
2705             */
2706            @Override
2707            public RepositoryEntry fetchByPrimaryKey(Serializable primaryKey)
2708                    throws SystemException {
2709                    RepositoryEntry repositoryEntry = (RepositoryEntry)EntityCacheUtil.getResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2710                                    RepositoryEntryImpl.class, primaryKey);
2711    
2712                    if (repositoryEntry == _nullRepositoryEntry) {
2713                            return null;
2714                    }
2715    
2716                    if (repositoryEntry == null) {
2717                            Session session = null;
2718    
2719                            try {
2720                                    session = openSession();
2721    
2722                                    repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2723                                                    primaryKey);
2724    
2725                                    if (repositoryEntry != null) {
2726                                            cacheResult(repositoryEntry);
2727                                    }
2728                                    else {
2729                                            EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2730                                                    RepositoryEntryImpl.class, primaryKey,
2731                                                    _nullRepositoryEntry);
2732                                    }
2733                            }
2734                            catch (Exception e) {
2735                                    EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2736                                            RepositoryEntryImpl.class, primaryKey);
2737    
2738                                    throw processException(e);
2739                            }
2740                            finally {
2741                                    closeSession(session);
2742                            }
2743                    }
2744    
2745                    return repositoryEntry;
2746            }
2747    
2748            /**
2749             * Returns the repository entry with the primary key or returns <code>null</code> if it could not be found.
2750             *
2751             * @param repositoryEntryId the primary key of the repository entry
2752             * @return the repository entry, or <code>null</code> if a repository entry with the primary key could not be found
2753             * @throws SystemException if a system exception occurred
2754             */
2755            @Override
2756            public RepositoryEntry fetchByPrimaryKey(long repositoryEntryId)
2757                    throws SystemException {
2758                    return fetchByPrimaryKey((Serializable)repositoryEntryId);
2759            }
2760    
2761            /**
2762             * Returns all the repository entries.
2763             *
2764             * @return the repository entries
2765             * @throws SystemException if a system exception occurred
2766             */
2767            @Override
2768            public List<RepositoryEntry> findAll() throws SystemException {
2769                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2770            }
2771    
2772            /**
2773             * Returns a range of all the repository entries.
2774             *
2775             * <p>
2776             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2777             * </p>
2778             *
2779             * @param start the lower bound of the range of repository entries
2780             * @param end the upper bound of the range of repository entries (not inclusive)
2781             * @return the range of repository entries
2782             * @throws SystemException if a system exception occurred
2783             */
2784            @Override
2785            public List<RepositoryEntry> findAll(int start, int end)
2786                    throws SystemException {
2787                    return findAll(start, end, null);
2788            }
2789    
2790            /**
2791             * Returns an ordered range of all the repository entries.
2792             *
2793             * <p>
2794             * 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. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.RepositoryEntryModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
2795             * </p>
2796             *
2797             * @param start the lower bound of the range of repository entries
2798             * @param end the upper bound of the range of repository entries (not inclusive)
2799             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2800             * @return the ordered range of repository entries
2801             * @throws SystemException if a system exception occurred
2802             */
2803            @Override
2804            public List<RepositoryEntry> findAll(int start, int end,
2805                    OrderByComparator orderByComparator) throws SystemException {
2806                    boolean pagination = true;
2807                    FinderPath finderPath = null;
2808                    Object[] finderArgs = null;
2809    
2810                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2811                                    (orderByComparator == null)) {
2812                            pagination = false;
2813                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2814                            finderArgs = FINDER_ARGS_EMPTY;
2815                    }
2816                    else {
2817                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2818                            finderArgs = new Object[] { start, end, orderByComparator };
2819                    }
2820    
2821                    List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
2822                                    finderArgs, this);
2823    
2824                    if (list == null) {
2825                            StringBundler query = null;
2826                            String sql = null;
2827    
2828                            if (orderByComparator != null) {
2829                                    query = new StringBundler(2 +
2830                                                    (orderByComparator.getOrderByFields().length * 3));
2831    
2832                                    query.append(_SQL_SELECT_REPOSITORYENTRY);
2833    
2834                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2835                                            orderByComparator);
2836    
2837                                    sql = query.toString();
2838                            }
2839                            else {
2840                                    sql = _SQL_SELECT_REPOSITORYENTRY;
2841    
2842                                    if (pagination) {
2843                                            sql = sql.concat(RepositoryEntryModelImpl.ORDER_BY_JPQL);
2844                                    }
2845                            }
2846    
2847                            Session session = null;
2848    
2849                            try {
2850                                    session = openSession();
2851    
2852                                    Query q = session.createQuery(sql);
2853    
2854                                    if (!pagination) {
2855                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
2856                                                            getDialect(), start, end, false);
2857    
2858                                            Collections.sort(list);
2859    
2860                                            list = new UnmodifiableList<RepositoryEntry>(list);
2861                                    }
2862                                    else {
2863                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
2864                                                            getDialect(), start, end);
2865                                    }
2866    
2867                                    cacheResult(list);
2868    
2869                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2870                            }
2871                            catch (Exception e) {
2872                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2873    
2874                                    throw processException(e);
2875                            }
2876                            finally {
2877                                    closeSession(session);
2878                            }
2879                    }
2880    
2881                    return list;
2882            }
2883    
2884            /**
2885             * Removes all the repository entries from the database.
2886             *
2887             * @throws SystemException if a system exception occurred
2888             */
2889            @Override
2890            public void removeAll() throws SystemException {
2891                    for (RepositoryEntry repositoryEntry : findAll()) {
2892                            remove(repositoryEntry);
2893                    }
2894            }
2895    
2896            /**
2897             * Returns the number of repository entries.
2898             *
2899             * @return the number of repository entries
2900             * @throws SystemException if a system exception occurred
2901             */
2902            @Override
2903            public int countAll() throws SystemException {
2904                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2905                                    FINDER_ARGS_EMPTY, this);
2906    
2907                    if (count == null) {
2908                            Session session = null;
2909    
2910                            try {
2911                                    session = openSession();
2912    
2913                                    Query q = session.createQuery(_SQL_COUNT_REPOSITORYENTRY);
2914    
2915                                    count = (Long)q.uniqueResult();
2916    
2917                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2918                                            FINDER_ARGS_EMPTY, count);
2919                            }
2920                            catch (Exception e) {
2921                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2922                                            FINDER_ARGS_EMPTY);
2923    
2924                                    throw processException(e);
2925                            }
2926                            finally {
2927                                    closeSession(session);
2928                            }
2929                    }
2930    
2931                    return count.intValue();
2932            }
2933    
2934            @Override
2935            protected Set<String> getBadColumnNames() {
2936                    return _badColumnNames;
2937            }
2938    
2939            /**
2940             * Initializes the repository entry persistence.
2941             */
2942            public void afterPropertiesSet() {
2943                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2944                                            com.liferay.portal.util.PropsUtil.get(
2945                                                    "value.object.listener.com.liferay.portal.model.RepositoryEntry")));
2946    
2947                    if (listenerClassNames.length > 0) {
2948                            try {
2949                                    List<ModelListener<RepositoryEntry>> listenersList = new ArrayList<ModelListener<RepositoryEntry>>();
2950    
2951                                    for (String listenerClassName : listenerClassNames) {
2952                                            listenersList.add((ModelListener<RepositoryEntry>)InstanceFactory.newInstance(
2953                                                            getClassLoader(), listenerClassName));
2954                                    }
2955    
2956                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2957                            }
2958                            catch (Exception e) {
2959                                    _log.error(e);
2960                            }
2961                    }
2962            }
2963    
2964            public void destroy() {
2965                    EntityCacheUtil.removeCache(RepositoryEntryImpl.class.getName());
2966                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2967                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2968                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2969            }
2970    
2971            private static final String _SQL_SELECT_REPOSITORYENTRY = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry";
2972            private static final String _SQL_SELECT_REPOSITORYENTRY_WHERE = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry WHERE ";
2973            private static final String _SQL_COUNT_REPOSITORYENTRY = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry";
2974            private static final String _SQL_COUNT_REPOSITORYENTRY_WHERE = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry WHERE ";
2975            private static final String _ORDER_BY_ENTITY_ALIAS = "repositoryEntry.";
2976            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RepositoryEntry exists with the primary key ";
2977            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RepositoryEntry exists with the key {";
2978            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2979            private static Log _log = LogFactoryUtil.getLog(RepositoryEntryPersistenceImpl.class);
2980            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2981                                    "uuid"
2982                            });
2983            private static RepositoryEntry _nullRepositoryEntry = new RepositoryEntryImpl() {
2984                            @Override
2985                            public Object clone() {
2986                                    return this;
2987                            }
2988    
2989                            @Override
2990                            public CacheModel<RepositoryEntry> toCacheModel() {
2991                                    return _nullRepositoryEntryCacheModel;
2992                            }
2993                    };
2994    
2995            private static CacheModel<RepositoryEntry> _nullRepositoryEntryCacheModel = new CacheModel<RepositoryEntry>() {
2996                            @Override
2997                            public RepositoryEntry toEntityModel() {
2998                                    return _nullRepositoryEntry;
2999                            }
3000                    };
3001    }