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            /**
2227             * Caches the repository entry in the entity cache if it is enabled.
2228             *
2229             * @param repositoryEntry the repository entry
2230             */
2231            @Override
2232            public void cacheResult(RepositoryEntry repositoryEntry) {
2233                    EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2234                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
2235                            repositoryEntry);
2236    
2237                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
2238                            new Object[] { repositoryEntry.getUuid(), repositoryEntry.getGroupId() },
2239                            repositoryEntry);
2240    
2241                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M,
2242                            new Object[] {
2243                                    repositoryEntry.getRepositoryId(), repositoryEntry.getMappedId()
2244                            }, repositoryEntry);
2245    
2246                    repositoryEntry.resetOriginalValues();
2247            }
2248    
2249            /**
2250             * Caches the repository entries in the entity cache if it is enabled.
2251             *
2252             * @param repositoryEntries the repository entries
2253             */
2254            @Override
2255            public void cacheResult(List<RepositoryEntry> repositoryEntries) {
2256                    for (RepositoryEntry repositoryEntry : repositoryEntries) {
2257                            if (EntityCacheUtil.getResult(
2258                                                    RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2259                                                    RepositoryEntryImpl.class,
2260                                                    repositoryEntry.getPrimaryKey()) == null) {
2261                                    cacheResult(repositoryEntry);
2262                            }
2263                            else {
2264                                    repositoryEntry.resetOriginalValues();
2265                            }
2266                    }
2267            }
2268    
2269            /**
2270             * Clears the cache for all repository entries.
2271             *
2272             * <p>
2273             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2274             * </p>
2275             */
2276            @Override
2277            public void clearCache() {
2278                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2279                            CacheRegistryUtil.clear(RepositoryEntryImpl.class.getName());
2280                    }
2281    
2282                    EntityCacheUtil.clearCache(RepositoryEntryImpl.class.getName());
2283    
2284                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2285                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2286                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2287            }
2288    
2289            /**
2290             * Clears the cache for the repository entry.
2291             *
2292             * <p>
2293             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2294             * </p>
2295             */
2296            @Override
2297            public void clearCache(RepositoryEntry repositoryEntry) {
2298                    EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2299                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
2300    
2301                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2302                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2303    
2304                    clearUniqueFindersCache(repositoryEntry);
2305            }
2306    
2307            @Override
2308            public void clearCache(List<RepositoryEntry> repositoryEntries) {
2309                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2310                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2311    
2312                    for (RepositoryEntry repositoryEntry : repositoryEntries) {
2313                            EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2314                                    RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey());
2315    
2316                            clearUniqueFindersCache(repositoryEntry);
2317                    }
2318            }
2319    
2320            protected void cacheUniqueFindersCache(RepositoryEntry repositoryEntry) {
2321                    if (repositoryEntry.isNew()) {
2322                            Object[] args = new Object[] {
2323                                            repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2324                                    };
2325    
2326                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2327                                    Long.valueOf(1));
2328                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2329                                    repositoryEntry);
2330    
2331                            args = new Object[] {
2332                                            repositoryEntry.getRepositoryId(),
2333                                            repositoryEntry.getMappedId()
2334                                    };
2335    
2336                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
2337                                    Long.valueOf(1));
2338                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args,
2339                                    repositoryEntry);
2340                    }
2341                    else {
2342                            RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2343    
2344                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2345                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2346                                    Object[] args = new Object[] {
2347                                                    repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2348                                            };
2349    
2350                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
2351                                            Long.valueOf(1));
2352                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
2353                                            repositoryEntry);
2354                            }
2355    
2356                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2357                                            FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
2358                                    Object[] args = new Object[] {
2359                                                    repositoryEntry.getRepositoryId(),
2360                                                    repositoryEntry.getMappedId()
2361                                            };
2362    
2363                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_R_M, args,
2364                                            Long.valueOf(1));
2365                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_R_M, args,
2366                                            repositoryEntry);
2367                            }
2368                    }
2369            }
2370    
2371            protected void clearUniqueFindersCache(RepositoryEntry repositoryEntry) {
2372                    RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2373    
2374                    Object[] args = new Object[] {
2375                                    repositoryEntry.getUuid(), repositoryEntry.getGroupId()
2376                            };
2377    
2378                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2379                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2380    
2381                    if ((repositoryEntryModelImpl.getColumnBitmask() &
2382                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
2383                            args = new Object[] {
2384                                            repositoryEntryModelImpl.getOriginalUuid(),
2385                                            repositoryEntryModelImpl.getOriginalGroupId()
2386                                    };
2387    
2388                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
2389                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
2390                    }
2391    
2392                    args = new Object[] {
2393                                    repositoryEntry.getRepositoryId(), repositoryEntry.getMappedId()
2394                            };
2395    
2396                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
2397                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
2398    
2399                    if ((repositoryEntryModelImpl.getColumnBitmask() &
2400                                    FINDER_PATH_FETCH_BY_R_M.getColumnBitmask()) != 0) {
2401                            args = new Object[] {
2402                                            repositoryEntryModelImpl.getOriginalRepositoryId(),
2403                                            repositoryEntryModelImpl.getOriginalMappedId()
2404                                    };
2405    
2406                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_R_M, args);
2407                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_R_M, args);
2408                    }
2409            }
2410    
2411            /**
2412             * Creates a new repository entry with the primary key. Does not add the repository entry to the database.
2413             *
2414             * @param repositoryEntryId the primary key for the new repository entry
2415             * @return the new repository entry
2416             */
2417            @Override
2418            public RepositoryEntry create(long repositoryEntryId) {
2419                    RepositoryEntry repositoryEntry = new RepositoryEntryImpl();
2420    
2421                    repositoryEntry.setNew(true);
2422                    repositoryEntry.setPrimaryKey(repositoryEntryId);
2423    
2424                    String uuid = PortalUUIDUtil.generate();
2425    
2426                    repositoryEntry.setUuid(uuid);
2427    
2428                    return repositoryEntry;
2429            }
2430    
2431            /**
2432             * Removes the repository entry with the primary key from the database. Also notifies the appropriate model listeners.
2433             *
2434             * @param repositoryEntryId the primary key of the repository entry
2435             * @return the repository entry that was removed
2436             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2437             * @throws SystemException if a system exception occurred
2438             */
2439            @Override
2440            public RepositoryEntry remove(long repositoryEntryId)
2441                    throws NoSuchRepositoryEntryException, SystemException {
2442                    return remove((Serializable)repositoryEntryId);
2443            }
2444    
2445            /**
2446             * Removes the repository entry with the primary key from the database. Also notifies the appropriate model listeners.
2447             *
2448             * @param primaryKey the primary key of the repository entry
2449             * @return the repository entry that was removed
2450             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2451             * @throws SystemException if a system exception occurred
2452             */
2453            @Override
2454            public RepositoryEntry remove(Serializable primaryKey)
2455                    throws NoSuchRepositoryEntryException, SystemException {
2456                    Session session = null;
2457    
2458                    try {
2459                            session = openSession();
2460    
2461                            RepositoryEntry repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2462                                            primaryKey);
2463    
2464                            if (repositoryEntry == null) {
2465                                    if (_log.isWarnEnabled()) {
2466                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2467                                    }
2468    
2469                                    throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2470                                            primaryKey);
2471                            }
2472    
2473                            return remove(repositoryEntry);
2474                    }
2475                    catch (NoSuchRepositoryEntryException nsee) {
2476                            throw nsee;
2477                    }
2478                    catch (Exception e) {
2479                            throw processException(e);
2480                    }
2481                    finally {
2482                            closeSession(session);
2483                    }
2484            }
2485    
2486            @Override
2487            protected RepositoryEntry removeImpl(RepositoryEntry repositoryEntry)
2488                    throws SystemException {
2489                    repositoryEntry = toUnwrappedModel(repositoryEntry);
2490    
2491                    Session session = null;
2492    
2493                    try {
2494                            session = openSession();
2495    
2496                            if (!session.contains(repositoryEntry)) {
2497                                    repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2498                                                    repositoryEntry.getPrimaryKeyObj());
2499                            }
2500    
2501                            if (repositoryEntry != null) {
2502                                    session.delete(repositoryEntry);
2503                            }
2504                    }
2505                    catch (Exception e) {
2506                            throw processException(e);
2507                    }
2508                    finally {
2509                            closeSession(session);
2510                    }
2511    
2512                    if (repositoryEntry != null) {
2513                            clearCache(repositoryEntry);
2514                    }
2515    
2516                    return repositoryEntry;
2517            }
2518    
2519            @Override
2520            public RepositoryEntry updateImpl(
2521                    com.liferay.portal.model.RepositoryEntry repositoryEntry)
2522                    throws SystemException {
2523                    repositoryEntry = toUnwrappedModel(repositoryEntry);
2524    
2525                    boolean isNew = repositoryEntry.isNew();
2526    
2527                    RepositoryEntryModelImpl repositoryEntryModelImpl = (RepositoryEntryModelImpl)repositoryEntry;
2528    
2529                    if (Validator.isNull(repositoryEntry.getUuid())) {
2530                            String uuid = PortalUUIDUtil.generate();
2531    
2532                            repositoryEntry.setUuid(uuid);
2533                    }
2534    
2535                    Session session = null;
2536    
2537                    try {
2538                            session = openSession();
2539    
2540                            if (repositoryEntry.isNew()) {
2541                                    session.save(repositoryEntry);
2542    
2543                                    repositoryEntry.setNew(false);
2544                            }
2545                            else {
2546                                    session.merge(repositoryEntry);
2547                            }
2548                    }
2549                    catch (Exception e) {
2550                            throw processException(e);
2551                    }
2552                    finally {
2553                            closeSession(session);
2554                    }
2555    
2556                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2557    
2558                    if (isNew || !RepositoryEntryModelImpl.COLUMN_BITMASK_ENABLED) {
2559                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2560                    }
2561    
2562                    else {
2563                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2564                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
2565                                    Object[] args = new Object[] {
2566                                                    repositoryEntryModelImpl.getOriginalUuid()
2567                                            };
2568    
2569                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2570                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2571                                            args);
2572    
2573                                    args = new Object[] { repositoryEntryModelImpl.getUuid() };
2574    
2575                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
2576                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
2577                                            args);
2578                            }
2579    
2580                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2581                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
2582                                    Object[] args = new Object[] {
2583                                                    repositoryEntryModelImpl.getOriginalUuid(),
2584                                                    repositoryEntryModelImpl.getOriginalCompanyId()
2585                                            };
2586    
2587                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2588                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2589                                            args);
2590    
2591                                    args = new Object[] {
2592                                                    repositoryEntryModelImpl.getUuid(),
2593                                                    repositoryEntryModelImpl.getCompanyId()
2594                                            };
2595    
2596                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
2597                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
2598                                            args);
2599                            }
2600    
2601                            if ((repositoryEntryModelImpl.getColumnBitmask() &
2602                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID.getColumnBitmask()) != 0) {
2603                                    Object[] args = new Object[] {
2604                                                    repositoryEntryModelImpl.getOriginalRepositoryId()
2605                                            };
2606    
2607                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
2608                                            args);
2609                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
2610                                            args);
2611    
2612                                    args = new Object[] { repositoryEntryModelImpl.getRepositoryId() };
2613    
2614                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_REPOSITORYID,
2615                                            args);
2616                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_REPOSITORYID,
2617                                            args);
2618                            }
2619                    }
2620    
2621                    EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2622                            RepositoryEntryImpl.class, repositoryEntry.getPrimaryKey(),
2623                            repositoryEntry);
2624    
2625                    clearUniqueFindersCache(repositoryEntry);
2626                    cacheUniqueFindersCache(repositoryEntry);
2627    
2628                    return repositoryEntry;
2629            }
2630    
2631            protected RepositoryEntry toUnwrappedModel(RepositoryEntry repositoryEntry) {
2632                    if (repositoryEntry instanceof RepositoryEntryImpl) {
2633                            return repositoryEntry;
2634                    }
2635    
2636                    RepositoryEntryImpl repositoryEntryImpl = new RepositoryEntryImpl();
2637    
2638                    repositoryEntryImpl.setNew(repositoryEntry.isNew());
2639                    repositoryEntryImpl.setPrimaryKey(repositoryEntry.getPrimaryKey());
2640    
2641                    repositoryEntryImpl.setUuid(repositoryEntry.getUuid());
2642                    repositoryEntryImpl.setRepositoryEntryId(repositoryEntry.getRepositoryEntryId());
2643                    repositoryEntryImpl.setGroupId(repositoryEntry.getGroupId());
2644                    repositoryEntryImpl.setCompanyId(repositoryEntry.getCompanyId());
2645                    repositoryEntryImpl.setUserId(repositoryEntry.getUserId());
2646                    repositoryEntryImpl.setUserName(repositoryEntry.getUserName());
2647                    repositoryEntryImpl.setCreateDate(repositoryEntry.getCreateDate());
2648                    repositoryEntryImpl.setModifiedDate(repositoryEntry.getModifiedDate());
2649                    repositoryEntryImpl.setRepositoryId(repositoryEntry.getRepositoryId());
2650                    repositoryEntryImpl.setMappedId(repositoryEntry.getMappedId());
2651                    repositoryEntryImpl.setManualCheckInRequired(repositoryEntry.isManualCheckInRequired());
2652    
2653                    return repositoryEntryImpl;
2654            }
2655    
2656            /**
2657             * Returns the repository entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
2658             *
2659             * @param primaryKey the primary key of the repository entry
2660             * @return the repository entry
2661             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2662             * @throws SystemException if a system exception occurred
2663             */
2664            @Override
2665            public RepositoryEntry findByPrimaryKey(Serializable primaryKey)
2666                    throws NoSuchRepositoryEntryException, SystemException {
2667                    RepositoryEntry repositoryEntry = fetchByPrimaryKey(primaryKey);
2668    
2669                    if (repositoryEntry == null) {
2670                            if (_log.isWarnEnabled()) {
2671                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
2672                            }
2673    
2674                            throw new NoSuchRepositoryEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
2675                                    primaryKey);
2676                    }
2677    
2678                    return repositoryEntry;
2679            }
2680    
2681            /**
2682             * Returns the repository entry with the primary key or throws a {@link com.liferay.portal.NoSuchRepositoryEntryException} if it could not be found.
2683             *
2684             * @param repositoryEntryId the primary key of the repository entry
2685             * @return the repository entry
2686             * @throws com.liferay.portal.NoSuchRepositoryEntryException if a repository entry with the primary key could not be found
2687             * @throws SystemException if a system exception occurred
2688             */
2689            @Override
2690            public RepositoryEntry findByPrimaryKey(long repositoryEntryId)
2691                    throws NoSuchRepositoryEntryException, SystemException {
2692                    return findByPrimaryKey((Serializable)repositoryEntryId);
2693            }
2694    
2695            /**
2696             * Returns the repository entry with the primary key or returns <code>null</code> if it could not be found.
2697             *
2698             * @param primaryKey the primary key of the repository entry
2699             * @return the repository entry, or <code>null</code> if a repository entry with the primary key could not be found
2700             * @throws SystemException if a system exception occurred
2701             */
2702            @Override
2703            public RepositoryEntry fetchByPrimaryKey(Serializable primaryKey)
2704                    throws SystemException {
2705                    RepositoryEntry repositoryEntry = (RepositoryEntry)EntityCacheUtil.getResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2706                                    RepositoryEntryImpl.class, primaryKey);
2707    
2708                    if (repositoryEntry == _nullRepositoryEntry) {
2709                            return null;
2710                    }
2711    
2712                    if (repositoryEntry == null) {
2713                            Session session = null;
2714    
2715                            try {
2716                                    session = openSession();
2717    
2718                                    repositoryEntry = (RepositoryEntry)session.get(RepositoryEntryImpl.class,
2719                                                    primaryKey);
2720    
2721                                    if (repositoryEntry != null) {
2722                                            cacheResult(repositoryEntry);
2723                                    }
2724                                    else {
2725                                            EntityCacheUtil.putResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2726                                                    RepositoryEntryImpl.class, primaryKey,
2727                                                    _nullRepositoryEntry);
2728                                    }
2729                            }
2730                            catch (Exception e) {
2731                                    EntityCacheUtil.removeResult(RepositoryEntryModelImpl.ENTITY_CACHE_ENABLED,
2732                                            RepositoryEntryImpl.class, primaryKey);
2733    
2734                                    throw processException(e);
2735                            }
2736                            finally {
2737                                    closeSession(session);
2738                            }
2739                    }
2740    
2741                    return repositoryEntry;
2742            }
2743    
2744            /**
2745             * Returns the repository entry with the primary key or returns <code>null</code> if it could not be found.
2746             *
2747             * @param repositoryEntryId the primary key of the repository entry
2748             * @return the repository entry, or <code>null</code> if a repository entry with the primary key could not be found
2749             * @throws SystemException if a system exception occurred
2750             */
2751            @Override
2752            public RepositoryEntry fetchByPrimaryKey(long repositoryEntryId)
2753                    throws SystemException {
2754                    return fetchByPrimaryKey((Serializable)repositoryEntryId);
2755            }
2756    
2757            /**
2758             * Returns all the repository entries.
2759             *
2760             * @return the repository entries
2761             * @throws SystemException if a system exception occurred
2762             */
2763            @Override
2764            public List<RepositoryEntry> findAll() throws SystemException {
2765                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2766            }
2767    
2768            /**
2769             * Returns a range of all the repository entries.
2770             *
2771             * <p>
2772             * 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.
2773             * </p>
2774             *
2775             * @param start the lower bound of the range of repository entries
2776             * @param end the upper bound of the range of repository entries (not inclusive)
2777             * @return the range of repository entries
2778             * @throws SystemException if a system exception occurred
2779             */
2780            @Override
2781            public List<RepositoryEntry> findAll(int start, int end)
2782                    throws SystemException {
2783                    return findAll(start, end, null);
2784            }
2785    
2786            /**
2787             * Returns an ordered range of all the repository entries.
2788             *
2789             * <p>
2790             * 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.
2791             * </p>
2792             *
2793             * @param start the lower bound of the range of repository entries
2794             * @param end the upper bound of the range of repository entries (not inclusive)
2795             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2796             * @return the ordered range of repository entries
2797             * @throws SystemException if a system exception occurred
2798             */
2799            @Override
2800            public List<RepositoryEntry> findAll(int start, int end,
2801                    OrderByComparator orderByComparator) throws SystemException {
2802                    boolean pagination = true;
2803                    FinderPath finderPath = null;
2804                    Object[] finderArgs = null;
2805    
2806                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2807                                    (orderByComparator == null)) {
2808                            pagination = false;
2809                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2810                            finderArgs = FINDER_ARGS_EMPTY;
2811                    }
2812                    else {
2813                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2814                            finderArgs = new Object[] { start, end, orderByComparator };
2815                    }
2816    
2817                    List<RepositoryEntry> list = (List<RepositoryEntry>)FinderCacheUtil.getResult(finderPath,
2818                                    finderArgs, this);
2819    
2820                    if (list == null) {
2821                            StringBundler query = null;
2822                            String sql = null;
2823    
2824                            if (orderByComparator != null) {
2825                                    query = new StringBundler(2 +
2826                                                    (orderByComparator.getOrderByFields().length * 3));
2827    
2828                                    query.append(_SQL_SELECT_REPOSITORYENTRY);
2829    
2830                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2831                                            orderByComparator);
2832    
2833                                    sql = query.toString();
2834                            }
2835                            else {
2836                                    sql = _SQL_SELECT_REPOSITORYENTRY;
2837    
2838                                    if (pagination) {
2839                                            sql = sql.concat(RepositoryEntryModelImpl.ORDER_BY_JPQL);
2840                                    }
2841                            }
2842    
2843                            Session session = null;
2844    
2845                            try {
2846                                    session = openSession();
2847    
2848                                    Query q = session.createQuery(sql);
2849    
2850                                    if (!pagination) {
2851                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
2852                                                            getDialect(), start, end, false);
2853    
2854                                            Collections.sort(list);
2855    
2856                                            list = new UnmodifiableList<RepositoryEntry>(list);
2857                                    }
2858                                    else {
2859                                            list = (List<RepositoryEntry>)QueryUtil.list(q,
2860                                                            getDialect(), start, end);
2861                                    }
2862    
2863                                    cacheResult(list);
2864    
2865                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
2866                            }
2867                            catch (Exception e) {
2868                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
2869    
2870                                    throw processException(e);
2871                            }
2872                            finally {
2873                                    closeSession(session);
2874                            }
2875                    }
2876    
2877                    return list;
2878            }
2879    
2880            /**
2881             * Removes all the repository entries from the database.
2882             *
2883             * @throws SystemException if a system exception occurred
2884             */
2885            @Override
2886            public void removeAll() throws SystemException {
2887                    for (RepositoryEntry repositoryEntry : findAll()) {
2888                            remove(repositoryEntry);
2889                    }
2890            }
2891    
2892            /**
2893             * Returns the number of repository entries.
2894             *
2895             * @return the number of repository entries
2896             * @throws SystemException if a system exception occurred
2897             */
2898            @Override
2899            public int countAll() throws SystemException {
2900                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2901                                    FINDER_ARGS_EMPTY, this);
2902    
2903                    if (count == null) {
2904                            Session session = null;
2905    
2906                            try {
2907                                    session = openSession();
2908    
2909                                    Query q = session.createQuery(_SQL_COUNT_REPOSITORYENTRY);
2910    
2911                                    count = (Long)q.uniqueResult();
2912    
2913                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2914                                            FINDER_ARGS_EMPTY, count);
2915                            }
2916                            catch (Exception e) {
2917                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
2918                                            FINDER_ARGS_EMPTY);
2919    
2920                                    throw processException(e);
2921                            }
2922                            finally {
2923                                    closeSession(session);
2924                            }
2925                    }
2926    
2927                    return count.intValue();
2928            }
2929    
2930            @Override
2931            protected Set<String> getBadColumnNames() {
2932                    return _badColumnNames;
2933            }
2934    
2935            /**
2936             * Initializes the repository entry persistence.
2937             */
2938            public void afterPropertiesSet() {
2939                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2940                                            com.liferay.portal.util.PropsUtil.get(
2941                                                    "value.object.listener.com.liferay.portal.model.RepositoryEntry")));
2942    
2943                    if (listenerClassNames.length > 0) {
2944                            try {
2945                                    List<ModelListener<RepositoryEntry>> listenersList = new ArrayList<ModelListener<RepositoryEntry>>();
2946    
2947                                    for (String listenerClassName : listenerClassNames) {
2948                                            listenersList.add((ModelListener<RepositoryEntry>)InstanceFactory.newInstance(
2949                                                            getClassLoader(), listenerClassName));
2950                                    }
2951    
2952                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2953                            }
2954                            catch (Exception e) {
2955                                    _log.error(e);
2956                            }
2957                    }
2958            }
2959    
2960            public void destroy() {
2961                    EntityCacheUtil.removeCache(RepositoryEntryImpl.class.getName());
2962                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2963                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2964                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2965            }
2966    
2967            private static final String _SQL_SELECT_REPOSITORYENTRY = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry";
2968            private static final String _SQL_SELECT_REPOSITORYENTRY_WHERE = "SELECT repositoryEntry FROM RepositoryEntry repositoryEntry WHERE ";
2969            private static final String _SQL_COUNT_REPOSITORYENTRY = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry";
2970            private static final String _SQL_COUNT_REPOSITORYENTRY_WHERE = "SELECT COUNT(repositoryEntry) FROM RepositoryEntry repositoryEntry WHERE ";
2971            private static final String _ORDER_BY_ENTITY_ALIAS = "repositoryEntry.";
2972            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No RepositoryEntry exists with the primary key ";
2973            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No RepositoryEntry exists with the key {";
2974            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2975            private static Log _log = LogFactoryUtil.getLog(RepositoryEntryPersistenceImpl.class);
2976            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
2977                                    "uuid"
2978                            });
2979            private static RepositoryEntry _nullRepositoryEntry = new RepositoryEntryImpl() {
2980                            @Override
2981                            public Object clone() {
2982                                    return this;
2983                            }
2984    
2985                            @Override
2986                            public CacheModel<RepositoryEntry> toCacheModel() {
2987                                    return _nullRepositoryEntryCacheModel;
2988                            }
2989                    };
2990    
2991            private static CacheModel<RepositoryEntry> _nullRepositoryEntryCacheModel = new CacheModel<RepositoryEntry>() {
2992                            @Override
2993                            public RepositoryEntry toEntityModel() {
2994                                    return _nullRepositoryEntry;
2995                            }
2996                    };
2997    }