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