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