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