001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.service.persistence.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.orm.EntityCache;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCache;
023    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
024    import com.liferay.portal.kernel.dao.orm.FinderPath;
025    import com.liferay.portal.kernel.dao.orm.Query;
026    import com.liferay.portal.kernel.dao.orm.QueryPos;
027    import com.liferay.portal.kernel.dao.orm.QueryUtil;
028    import com.liferay.portal.kernel.dao.orm.SQLQuery;
029    import com.liferay.portal.kernel.dao.orm.Session;
030    import com.liferay.portal.kernel.log.Log;
031    import com.liferay.portal.kernel.log.LogFactoryUtil;
032    import com.liferay.portal.kernel.util.ArrayUtil;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.SetUtil;
035    import com.liferay.portal.kernel.util.StringBundler;
036    import com.liferay.portal.kernel.util.StringPool;
037    import com.liferay.portal.kernel.util.StringUtil;
038    import com.liferay.portal.kernel.util.Validator;
039    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
040    import com.liferay.portal.model.CacheModel;
041    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
042    import com.liferay.portal.service.ServiceContext;
043    import com.liferay.portal.service.ServiceContextThreadLocal;
044    import com.liferay.portal.service.persistence.CompanyProvider;
045    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046    import com.liferay.portal.service.persistence.impl.TableMapper;
047    import com.liferay.portal.service.persistence.impl.TableMapperFactory;
048    
049    import com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException;
050    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
051    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl;
052    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl;
053    import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
054    import com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence;
055    
056    import java.io.Serializable;
057    
058    import java.util.Arrays;
059    import java.util.Collections;
060    import java.util.Date;
061    import java.util.HashMap;
062    import java.util.HashSet;
063    import java.util.Iterator;
064    import java.util.List;
065    import java.util.Map;
066    import java.util.Set;
067    
068    /**
069     * The persistence implementation for the document library file entry type service.
070     *
071     * <p>
072     * Caching information and settings can be found in <code>portal.properties</code>
073     * </p>
074     *
075     * @author Brian Wing Shun Chan
076     * @see DLFileEntryTypePersistence
077     * @see com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypeUtil
078     * @generated
079     */
080    @ProviderType
081    public class DLFileEntryTypePersistenceImpl extends BasePersistenceImpl<DLFileEntryType>
082            implements DLFileEntryTypePersistence {
083            /*
084             * NOTE FOR DEVELOPERS:
085             *
086             * Never modify or reference this class directly. Always use {@link DLFileEntryTypeUtil} to access the document library file entry type persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
087             */
088            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryTypeImpl.class.getName();
089            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090                    ".List1";
091            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List2";
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
094                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
095                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
096                            "findAll", new String[0]);
097            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
098                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
099                            DLFileEntryTypeImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
101            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
102                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
103                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
104            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
105                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
106                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
107                            "findByUuid",
108                            new String[] {
109                                    String.class.getName(),
110                                    
111                            Integer.class.getName(), Integer.class.getName(),
112                                    OrderByComparator.class.getName()
113                            });
114            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
115                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
116                            DLFileEntryTypeImpl.class,
117                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
118                            new String[] { String.class.getName() },
119                            DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
121                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
123                            new String[] { String.class.getName() });
124    
125            /**
126             * Returns all the document library file entry types where uuid = &#63;.
127             *
128             * @param uuid the uuid
129             * @return the matching document library file entry types
130             */
131            @Override
132            public List<DLFileEntryType> findByUuid(String uuid) {
133                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
134            }
135    
136            /**
137             * Returns a range of all the document library file entry types where uuid = &#63;.
138             *
139             * <p>
140             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
141             * </p>
142             *
143             * @param uuid the uuid
144             * @param start the lower bound of the range of document library file entry types
145             * @param end the upper bound of the range of document library file entry types (not inclusive)
146             * @return the range of matching document library file entry types
147             */
148            @Override
149            public List<DLFileEntryType> findByUuid(String uuid, int start, int end) {
150                    return findByUuid(uuid, start, end, null);
151            }
152    
153            /**
154             * Returns an ordered range of all the document library file entry types where uuid = &#63;.
155             *
156             * <p>
157             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
158             * </p>
159             *
160             * @param uuid the uuid
161             * @param start the lower bound of the range of document library file entry types
162             * @param end the upper bound of the range of document library file entry types (not inclusive)
163             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
164             * @return the ordered range of matching document library file entry types
165             */
166            @Override
167            public List<DLFileEntryType> findByUuid(String uuid, int start, int end,
168                    OrderByComparator<DLFileEntryType> orderByComparator) {
169                    return findByUuid(uuid, start, end, orderByComparator, true);
170            }
171    
172            /**
173             * Returns an ordered range of all the document library file entry types where uuid = &#63;.
174             *
175             * <p>
176             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
177             * </p>
178             *
179             * @param uuid the uuid
180             * @param start the lower bound of the range of document library file entry types
181             * @param end the upper bound of the range of document library file entry types (not inclusive)
182             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
183             * @param retrieveFromCache whether to retrieve from the finder cache
184             * @return the ordered range of matching document library file entry types
185             */
186            @Override
187            public List<DLFileEntryType> findByUuid(String uuid, int start, int end,
188                    OrderByComparator<DLFileEntryType> orderByComparator,
189                    boolean retrieveFromCache) {
190                    boolean pagination = true;
191                    FinderPath finderPath = null;
192                    Object[] finderArgs = null;
193    
194                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
195                                    (orderByComparator == null)) {
196                            pagination = false;
197                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
198                            finderArgs = new Object[] { uuid };
199                    }
200                    else {
201                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
202                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
203                    }
204    
205                    List<DLFileEntryType> list = null;
206    
207                    if (retrieveFromCache) {
208                            list = (List<DLFileEntryType>)finderCache.getResult(finderPath,
209                                            finderArgs, this);
210    
211                            if ((list != null) && !list.isEmpty()) {
212                                    for (DLFileEntryType dlFileEntryType : list) {
213                                            if (!Validator.equals(uuid, dlFileEntryType.getUuid())) {
214                                                    list = null;
215    
216                                                    break;
217                                            }
218                                    }
219                            }
220                    }
221    
222                    if (list == null) {
223                            StringBundler query = null;
224    
225                            if (orderByComparator != null) {
226                                    query = new StringBundler(3 +
227                                                    (orderByComparator.getOrderByFields().length * 3));
228                            }
229                            else {
230                                    query = new StringBundler(3);
231                            }
232    
233                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
234    
235                            boolean bindUuid = false;
236    
237                            if (uuid == null) {
238                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
239                            }
240                            else if (uuid.equals(StringPool.BLANK)) {
241                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
242                            }
243                            else {
244                                    bindUuid = true;
245    
246                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
247                            }
248    
249                            if (orderByComparator != null) {
250                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
251                                            orderByComparator);
252                            }
253                            else
254                             if (pagination) {
255                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
256                            }
257    
258                            String sql = query.toString();
259    
260                            Session session = null;
261    
262                            try {
263                                    session = openSession();
264    
265                                    Query q = session.createQuery(sql);
266    
267                                    QueryPos qPos = QueryPos.getInstance(q);
268    
269                                    if (bindUuid) {
270                                            qPos.add(uuid);
271                                    }
272    
273                                    if (!pagination) {
274                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
275                                                            getDialect(), start, end, false);
276    
277                                            Collections.sort(list);
278    
279                                            list = Collections.unmodifiableList(list);
280                                    }
281                                    else {
282                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
283                                                            getDialect(), start, end);
284                                    }
285    
286                                    cacheResult(list);
287    
288                                    finderCache.putResult(finderPath, finderArgs, list);
289                            }
290                            catch (Exception e) {
291                                    finderCache.removeResult(finderPath, finderArgs);
292    
293                                    throw processException(e);
294                            }
295                            finally {
296                                    closeSession(session);
297                            }
298                    }
299    
300                    return list;
301            }
302    
303            /**
304             * Returns the first document library file entry type in the ordered set where uuid = &#63;.
305             *
306             * @param uuid the uuid
307             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
308             * @return the first matching document library file entry type
309             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
310             */
311            @Override
312            public DLFileEntryType findByUuid_First(String uuid,
313                    OrderByComparator<DLFileEntryType> orderByComparator)
314                    throws NoSuchFileEntryTypeException {
315                    DLFileEntryType dlFileEntryType = fetchByUuid_First(uuid,
316                                    orderByComparator);
317    
318                    if (dlFileEntryType != null) {
319                            return dlFileEntryType;
320                    }
321    
322                    StringBundler msg = new StringBundler(4);
323    
324                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
325    
326                    msg.append("uuid=");
327                    msg.append(uuid);
328    
329                    msg.append(StringPool.CLOSE_CURLY_BRACE);
330    
331                    throw new NoSuchFileEntryTypeException(msg.toString());
332            }
333    
334            /**
335             * Returns the first document library file entry type in the ordered set where uuid = &#63;.
336             *
337             * @param uuid the uuid
338             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
339             * @return the first matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
340             */
341            @Override
342            public DLFileEntryType fetchByUuid_First(String uuid,
343                    OrderByComparator<DLFileEntryType> orderByComparator) {
344                    List<DLFileEntryType> list = findByUuid(uuid, 0, 1, orderByComparator);
345    
346                    if (!list.isEmpty()) {
347                            return list.get(0);
348                    }
349    
350                    return null;
351            }
352    
353            /**
354             * Returns the last document library file entry type in the ordered set where uuid = &#63;.
355             *
356             * @param uuid the uuid
357             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
358             * @return the last matching document library file entry type
359             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
360             */
361            @Override
362            public DLFileEntryType findByUuid_Last(String uuid,
363                    OrderByComparator<DLFileEntryType> orderByComparator)
364                    throws NoSuchFileEntryTypeException {
365                    DLFileEntryType dlFileEntryType = fetchByUuid_Last(uuid,
366                                    orderByComparator);
367    
368                    if (dlFileEntryType != null) {
369                            return dlFileEntryType;
370                    }
371    
372                    StringBundler msg = new StringBundler(4);
373    
374                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
375    
376                    msg.append("uuid=");
377                    msg.append(uuid);
378    
379                    msg.append(StringPool.CLOSE_CURLY_BRACE);
380    
381                    throw new NoSuchFileEntryTypeException(msg.toString());
382            }
383    
384            /**
385             * Returns the last document library file entry type in the ordered set where uuid = &#63;.
386             *
387             * @param uuid the uuid
388             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
389             * @return the last matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
390             */
391            @Override
392            public DLFileEntryType fetchByUuid_Last(String uuid,
393                    OrderByComparator<DLFileEntryType> orderByComparator) {
394                    int count = countByUuid(uuid);
395    
396                    if (count == 0) {
397                            return null;
398                    }
399    
400                    List<DLFileEntryType> list = findByUuid(uuid, count - 1, count,
401                                    orderByComparator);
402    
403                    if (!list.isEmpty()) {
404                            return list.get(0);
405                    }
406    
407                    return null;
408            }
409    
410            /**
411             * Returns the document library file entry types before and after the current document library file entry type in the ordered set where uuid = &#63;.
412             *
413             * @param fileEntryTypeId the primary key of the current document library file entry type
414             * @param uuid the uuid
415             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
416             * @return the previous, current, and next document library file entry type
417             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
418             */
419            @Override
420            public DLFileEntryType[] findByUuid_PrevAndNext(long fileEntryTypeId,
421                    String uuid, OrderByComparator<DLFileEntryType> orderByComparator)
422                    throws NoSuchFileEntryTypeException {
423                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
424    
425                    Session session = null;
426    
427                    try {
428                            session = openSession();
429    
430                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
431    
432                            array[0] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
433                                            orderByComparator, true);
434    
435                            array[1] = dlFileEntryType;
436    
437                            array[2] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
438                                            orderByComparator, false);
439    
440                            return array;
441                    }
442                    catch (Exception e) {
443                            throw processException(e);
444                    }
445                    finally {
446                            closeSession(session);
447                    }
448            }
449    
450            protected DLFileEntryType getByUuid_PrevAndNext(Session session,
451                    DLFileEntryType dlFileEntryType, String uuid,
452                    OrderByComparator<DLFileEntryType> orderByComparator, boolean previous) {
453                    StringBundler query = null;
454    
455                    if (orderByComparator != null) {
456                            query = new StringBundler(6 +
457                                            (orderByComparator.getOrderByFields().length * 6));
458                    }
459                    else {
460                            query = new StringBundler(3);
461                    }
462    
463                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
464    
465                    boolean bindUuid = false;
466    
467                    if (uuid == null) {
468                            query.append(_FINDER_COLUMN_UUID_UUID_1);
469                    }
470                    else if (uuid.equals(StringPool.BLANK)) {
471                            query.append(_FINDER_COLUMN_UUID_UUID_3);
472                    }
473                    else {
474                            bindUuid = true;
475    
476                            query.append(_FINDER_COLUMN_UUID_UUID_2);
477                    }
478    
479                    if (orderByComparator != null) {
480                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
481    
482                            if (orderByConditionFields.length > 0) {
483                                    query.append(WHERE_AND);
484                            }
485    
486                            for (int i = 0; i < orderByConditionFields.length; i++) {
487                                    query.append(_ORDER_BY_ENTITY_ALIAS);
488                                    query.append(orderByConditionFields[i]);
489    
490                                    if ((i + 1) < orderByConditionFields.length) {
491                                            if (orderByComparator.isAscending() ^ previous) {
492                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
493                                            }
494                                            else {
495                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
496                                            }
497                                    }
498                                    else {
499                                            if (orderByComparator.isAscending() ^ previous) {
500                                                    query.append(WHERE_GREATER_THAN);
501                                            }
502                                            else {
503                                                    query.append(WHERE_LESSER_THAN);
504                                            }
505                                    }
506                            }
507    
508                            query.append(ORDER_BY_CLAUSE);
509    
510                            String[] orderByFields = orderByComparator.getOrderByFields();
511    
512                            for (int i = 0; i < orderByFields.length; i++) {
513                                    query.append(_ORDER_BY_ENTITY_ALIAS);
514                                    query.append(orderByFields[i]);
515    
516                                    if ((i + 1) < orderByFields.length) {
517                                            if (orderByComparator.isAscending() ^ previous) {
518                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
519                                            }
520                                            else {
521                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
522                                            }
523                                    }
524                                    else {
525                                            if (orderByComparator.isAscending() ^ previous) {
526                                                    query.append(ORDER_BY_ASC);
527                                            }
528                                            else {
529                                                    query.append(ORDER_BY_DESC);
530                                            }
531                                    }
532                            }
533                    }
534                    else {
535                            query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
536                    }
537    
538                    String sql = query.toString();
539    
540                    Query q = session.createQuery(sql);
541    
542                    q.setFirstResult(0);
543                    q.setMaxResults(2);
544    
545                    QueryPos qPos = QueryPos.getInstance(q);
546    
547                    if (bindUuid) {
548                            qPos.add(uuid);
549                    }
550    
551                    if (orderByComparator != null) {
552                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
553    
554                            for (Object value : values) {
555                                    qPos.add(value);
556                            }
557                    }
558    
559                    List<DLFileEntryType> list = q.list();
560    
561                    if (list.size() == 2) {
562                            return list.get(1);
563                    }
564                    else {
565                            return null;
566                    }
567            }
568    
569            /**
570             * Removes all the document library file entry types where uuid = &#63; from the database.
571             *
572             * @param uuid the uuid
573             */
574            @Override
575            public void removeByUuid(String uuid) {
576                    for (DLFileEntryType dlFileEntryType : findByUuid(uuid,
577                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
578                            remove(dlFileEntryType);
579                    }
580            }
581    
582            /**
583             * Returns the number of document library file entry types where uuid = &#63;.
584             *
585             * @param uuid the uuid
586             * @return the number of matching document library file entry types
587             */
588            @Override
589            public int countByUuid(String uuid) {
590                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;
591    
592                    Object[] finderArgs = new Object[] { uuid };
593    
594                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
595    
596                    if (count == null) {
597                            StringBundler query = new StringBundler(2);
598    
599                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
600    
601                            boolean bindUuid = false;
602    
603                            if (uuid == null) {
604                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
605                            }
606                            else if (uuid.equals(StringPool.BLANK)) {
607                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
608                            }
609                            else {
610                                    bindUuid = true;
611    
612                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
613                            }
614    
615                            String sql = query.toString();
616    
617                            Session session = null;
618    
619                            try {
620                                    session = openSession();
621    
622                                    Query q = session.createQuery(sql);
623    
624                                    QueryPos qPos = QueryPos.getInstance(q);
625    
626                                    if (bindUuid) {
627                                            qPos.add(uuid);
628                                    }
629    
630                                    count = (Long)q.uniqueResult();
631    
632                                    finderCache.putResult(finderPath, finderArgs, count);
633                            }
634                            catch (Exception e) {
635                                    finderCache.removeResult(finderPath, finderArgs);
636    
637                                    throw processException(e);
638                            }
639                            finally {
640                                    closeSession(session);
641                            }
642                    }
643    
644                    return count.intValue();
645            }
646    
647            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryType.uuid IS NULL";
648            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryType.uuid = ?";
649            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = '')";
650            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
651                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
652                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY,
653                            "fetchByUUID_G",
654                            new String[] { String.class.getName(), Long.class.getName() },
655                            DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK |
656                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
657            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
658                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
659                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
660                            new String[] { String.class.getName(), Long.class.getName() });
661    
662            /**
663             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or throws a {@link NoSuchFileEntryTypeException} if it could not be found.
664             *
665             * @param uuid the uuid
666             * @param groupId the group ID
667             * @return the matching document library file entry type
668             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
669             */
670            @Override
671            public DLFileEntryType findByUUID_G(String uuid, long groupId)
672                    throws NoSuchFileEntryTypeException {
673                    DLFileEntryType dlFileEntryType = fetchByUUID_G(uuid, groupId);
674    
675                    if (dlFileEntryType == null) {
676                            StringBundler msg = new StringBundler(6);
677    
678                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679    
680                            msg.append("uuid=");
681                            msg.append(uuid);
682    
683                            msg.append(", groupId=");
684                            msg.append(groupId);
685    
686                            msg.append(StringPool.CLOSE_CURLY_BRACE);
687    
688                            if (_log.isWarnEnabled()) {
689                                    _log.warn(msg.toString());
690                            }
691    
692                            throw new NoSuchFileEntryTypeException(msg.toString());
693                    }
694    
695                    return dlFileEntryType;
696            }
697    
698            /**
699             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
700             *
701             * @param uuid the uuid
702             * @param groupId the group ID
703             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
704             */
705            @Override
706            public DLFileEntryType fetchByUUID_G(String uuid, long groupId) {
707                    return fetchByUUID_G(uuid, groupId, true);
708            }
709    
710            /**
711             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
712             *
713             * @param uuid the uuid
714             * @param groupId the group ID
715             * @param retrieveFromCache whether to retrieve from the finder cache
716             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
717             */
718            @Override
719            public DLFileEntryType fetchByUUID_G(String uuid, long groupId,
720                    boolean retrieveFromCache) {
721                    Object[] finderArgs = new Object[] { uuid, groupId };
722    
723                    Object result = null;
724    
725                    if (retrieveFromCache) {
726                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_UUID_G,
727                                            finderArgs, this);
728                    }
729    
730                    if (result instanceof DLFileEntryType) {
731                            DLFileEntryType dlFileEntryType = (DLFileEntryType)result;
732    
733                            if (!Validator.equals(uuid, dlFileEntryType.getUuid()) ||
734                                            (groupId != dlFileEntryType.getGroupId())) {
735                                    result = null;
736                            }
737                    }
738    
739                    if (result == null) {
740                            StringBundler query = new StringBundler(4);
741    
742                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
743    
744                            boolean bindUuid = false;
745    
746                            if (uuid == null) {
747                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
748                            }
749                            else if (uuid.equals(StringPool.BLANK)) {
750                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
751                            }
752                            else {
753                                    bindUuid = true;
754    
755                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
756                            }
757    
758                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
759    
760                            String sql = query.toString();
761    
762                            Session session = null;
763    
764                            try {
765                                    session = openSession();
766    
767                                    Query q = session.createQuery(sql);
768    
769                                    QueryPos qPos = QueryPos.getInstance(q);
770    
771                                    if (bindUuid) {
772                                            qPos.add(uuid);
773                                    }
774    
775                                    qPos.add(groupId);
776    
777                                    List<DLFileEntryType> list = q.list();
778    
779                                    if (list.isEmpty()) {
780                                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
781                                                    finderArgs, list);
782                                    }
783                                    else {
784                                            DLFileEntryType dlFileEntryType = list.get(0);
785    
786                                            result = dlFileEntryType;
787    
788                                            cacheResult(dlFileEntryType);
789    
790                                            if ((dlFileEntryType.getUuid() == null) ||
791                                                            !dlFileEntryType.getUuid().equals(uuid) ||
792                                                            (dlFileEntryType.getGroupId() != groupId)) {
793                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
794                                                            finderArgs, dlFileEntryType);
795                                            }
796                                    }
797                            }
798                            catch (Exception e) {
799                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, finderArgs);
800    
801                                    throw processException(e);
802                            }
803                            finally {
804                                    closeSession(session);
805                            }
806                    }
807    
808                    if (result instanceof List<?>) {
809                            return null;
810                    }
811                    else {
812                            return (DLFileEntryType)result;
813                    }
814            }
815    
816            /**
817             * Removes the document library file entry type where uuid = &#63; and groupId = &#63; from the database.
818             *
819             * @param uuid the uuid
820             * @param groupId the group ID
821             * @return the document library file entry type that was removed
822             */
823            @Override
824            public DLFileEntryType removeByUUID_G(String uuid, long groupId)
825                    throws NoSuchFileEntryTypeException {
826                    DLFileEntryType dlFileEntryType = findByUUID_G(uuid, groupId);
827    
828                    return remove(dlFileEntryType);
829            }
830    
831            /**
832             * Returns the number of document library file entry types where uuid = &#63; and groupId = &#63;.
833             *
834             * @param uuid the uuid
835             * @param groupId the group ID
836             * @return the number of matching document library file entry types
837             */
838            @Override
839            public int countByUUID_G(String uuid, long groupId) {
840                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_G;
841    
842                    Object[] finderArgs = new Object[] { uuid, groupId };
843    
844                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
845    
846                    if (count == null) {
847                            StringBundler query = new StringBundler(3);
848    
849                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
850    
851                            boolean bindUuid = false;
852    
853                            if (uuid == null) {
854                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
855                            }
856                            else if (uuid.equals(StringPool.BLANK)) {
857                                    query.append(_FINDER_COLUMN_UUID_G_UUID_3);
858                            }
859                            else {
860                                    bindUuid = true;
861    
862                                    query.append(_FINDER_COLUMN_UUID_G_UUID_2);
863                            }
864    
865                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
866    
867                            String sql = query.toString();
868    
869                            Session session = null;
870    
871                            try {
872                                    session = openSession();
873    
874                                    Query q = session.createQuery(sql);
875    
876                                    QueryPos qPos = QueryPos.getInstance(q);
877    
878                                    if (bindUuid) {
879                                            qPos.add(uuid);
880                                    }
881    
882                                    qPos.add(groupId);
883    
884                                    count = (Long)q.uniqueResult();
885    
886                                    finderCache.putResult(finderPath, finderArgs, count);
887                            }
888                            catch (Exception e) {
889                                    finderCache.removeResult(finderPath, finderArgs);
890    
891                                    throw processException(e);
892                            }
893                            finally {
894                                    closeSession(session);
895                            }
896                    }
897    
898                    return count.intValue();
899            }
900    
901            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntryType.uuid IS NULL AND ";
902            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntryType.uuid = ? AND ";
903            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = '') AND ";
904            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntryType.groupId = ?";
905            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
906                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
907                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
908                            "findByUuid_C",
909                            new String[] {
910                                    String.class.getName(), Long.class.getName(),
911                                    
912                            Integer.class.getName(), Integer.class.getName(),
913                                    OrderByComparator.class.getName()
914                            });
915            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C =
916                    new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
917                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
918                            DLFileEntryTypeImpl.class,
919                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
920                            new String[] { String.class.getName(), Long.class.getName() },
921                            DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK |
922                            DLFileEntryTypeModelImpl.COMPANYID_COLUMN_BITMASK);
923            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_C = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
924                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
925                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
926                            new String[] { String.class.getName(), Long.class.getName() });
927    
928            /**
929             * Returns all the document library file entry types where uuid = &#63; and companyId = &#63;.
930             *
931             * @param uuid the uuid
932             * @param companyId the company ID
933             * @return the matching document library file entry types
934             */
935            @Override
936            public List<DLFileEntryType> findByUuid_C(String uuid, long companyId) {
937                    return findByUuid_C(uuid, companyId, QueryUtil.ALL_POS,
938                            QueryUtil.ALL_POS, null);
939            }
940    
941            /**
942             * Returns a range of all the document library file entry types where uuid = &#63; and companyId = &#63;.
943             *
944             * <p>
945             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
946             * </p>
947             *
948             * @param uuid the uuid
949             * @param companyId the company ID
950             * @param start the lower bound of the range of document library file entry types
951             * @param end the upper bound of the range of document library file entry types (not inclusive)
952             * @return the range of matching document library file entry types
953             */
954            @Override
955            public List<DLFileEntryType> findByUuid_C(String uuid, long companyId,
956                    int start, int end) {
957                    return findByUuid_C(uuid, companyId, start, end, null);
958            }
959    
960            /**
961             * Returns an ordered range of all the document library file entry types where uuid = &#63; and companyId = &#63;.
962             *
963             * <p>
964             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
965             * </p>
966             *
967             * @param uuid the uuid
968             * @param companyId the company ID
969             * @param start the lower bound of the range of document library file entry types
970             * @param end the upper bound of the range of document library file entry types (not inclusive)
971             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
972             * @return the ordered range of matching document library file entry types
973             */
974            @Override
975            public List<DLFileEntryType> findByUuid_C(String uuid, long companyId,
976                    int start, int end, OrderByComparator<DLFileEntryType> orderByComparator) {
977                    return findByUuid_C(uuid, companyId, start, end, orderByComparator, true);
978            }
979    
980            /**
981             * Returns an ordered range of all the document library file entry types where uuid = &#63; and companyId = &#63;.
982             *
983             * <p>
984             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
985             * </p>
986             *
987             * @param uuid the uuid
988             * @param companyId the company ID
989             * @param start the lower bound of the range of document library file entry types
990             * @param end the upper bound of the range of document library file entry types (not inclusive)
991             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
992             * @param retrieveFromCache whether to retrieve from the finder cache
993             * @return the ordered range of matching document library file entry types
994             */
995            @Override
996            public List<DLFileEntryType> findByUuid_C(String uuid, long companyId,
997                    int start, int end,
998                    OrderByComparator<DLFileEntryType> orderByComparator,
999                    boolean retrieveFromCache) {
1000                    boolean pagination = true;
1001                    FinderPath finderPath = null;
1002                    Object[] finderArgs = null;
1003    
1004                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1005                                    (orderByComparator == null)) {
1006                            pagination = false;
1007                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C;
1008                            finderArgs = new Object[] { uuid, companyId };
1009                    }
1010                    else {
1011                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID_C;
1012                            finderArgs = new Object[] {
1013                                            uuid, companyId,
1014                                            
1015                                            start, end, orderByComparator
1016                                    };
1017                    }
1018    
1019                    List<DLFileEntryType> list = null;
1020    
1021                    if (retrieveFromCache) {
1022                            list = (List<DLFileEntryType>)finderCache.getResult(finderPath,
1023                                            finderArgs, this);
1024    
1025                            if ((list != null) && !list.isEmpty()) {
1026                                    for (DLFileEntryType dlFileEntryType : list) {
1027                                            if (!Validator.equals(uuid, dlFileEntryType.getUuid()) ||
1028                                                            (companyId != dlFileEntryType.getCompanyId())) {
1029                                                    list = null;
1030    
1031                                                    break;
1032                                            }
1033                                    }
1034                            }
1035                    }
1036    
1037                    if (list == null) {
1038                            StringBundler query = null;
1039    
1040                            if (orderByComparator != null) {
1041                                    query = new StringBundler(4 +
1042                                                    (orderByComparator.getOrderByFields().length * 3));
1043                            }
1044                            else {
1045                                    query = new StringBundler(4);
1046                            }
1047    
1048                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1049    
1050                            boolean bindUuid = false;
1051    
1052                            if (uuid == null) {
1053                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1054                            }
1055                            else if (uuid.equals(StringPool.BLANK)) {
1056                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1057                            }
1058                            else {
1059                                    bindUuid = true;
1060    
1061                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1062                            }
1063    
1064                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1065    
1066                            if (orderByComparator != null) {
1067                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1068                                            orderByComparator);
1069                            }
1070                            else
1071                             if (pagination) {
1072                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
1073                            }
1074    
1075                            String sql = query.toString();
1076    
1077                            Session session = null;
1078    
1079                            try {
1080                                    session = openSession();
1081    
1082                                    Query q = session.createQuery(sql);
1083    
1084                                    QueryPos qPos = QueryPos.getInstance(q);
1085    
1086                                    if (bindUuid) {
1087                                            qPos.add(uuid);
1088                                    }
1089    
1090                                    qPos.add(companyId);
1091    
1092                                    if (!pagination) {
1093                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
1094                                                            getDialect(), start, end, false);
1095    
1096                                            Collections.sort(list);
1097    
1098                                            list = Collections.unmodifiableList(list);
1099                                    }
1100                                    else {
1101                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
1102                                                            getDialect(), start, end);
1103                                    }
1104    
1105                                    cacheResult(list);
1106    
1107                                    finderCache.putResult(finderPath, finderArgs, list);
1108                            }
1109                            catch (Exception e) {
1110                                    finderCache.removeResult(finderPath, finderArgs);
1111    
1112                                    throw processException(e);
1113                            }
1114                            finally {
1115                                    closeSession(session);
1116                            }
1117                    }
1118    
1119                    return list;
1120            }
1121    
1122            /**
1123             * Returns the first document library file entry type in the ordered set where uuid = &#63; and companyId = &#63;.
1124             *
1125             * @param uuid the uuid
1126             * @param companyId the company ID
1127             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1128             * @return the first matching document library file entry type
1129             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1130             */
1131            @Override
1132            public DLFileEntryType findByUuid_C_First(String uuid, long companyId,
1133                    OrderByComparator<DLFileEntryType> orderByComparator)
1134                    throws NoSuchFileEntryTypeException {
1135                    DLFileEntryType dlFileEntryType = fetchByUuid_C_First(uuid, companyId,
1136                                    orderByComparator);
1137    
1138                    if (dlFileEntryType != null) {
1139                            return dlFileEntryType;
1140                    }
1141    
1142                    StringBundler msg = new StringBundler(6);
1143    
1144                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1145    
1146                    msg.append("uuid=");
1147                    msg.append(uuid);
1148    
1149                    msg.append(", companyId=");
1150                    msg.append(companyId);
1151    
1152                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1153    
1154                    throw new NoSuchFileEntryTypeException(msg.toString());
1155            }
1156    
1157            /**
1158             * Returns the first document library file entry type in the ordered set where uuid = &#63; and companyId = &#63;.
1159             *
1160             * @param uuid the uuid
1161             * @param companyId the company ID
1162             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1163             * @return the first matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1164             */
1165            @Override
1166            public DLFileEntryType fetchByUuid_C_First(String uuid, long companyId,
1167                    OrderByComparator<DLFileEntryType> orderByComparator) {
1168                    List<DLFileEntryType> list = findByUuid_C(uuid, companyId, 0, 1,
1169                                    orderByComparator);
1170    
1171                    if (!list.isEmpty()) {
1172                            return list.get(0);
1173                    }
1174    
1175                    return null;
1176            }
1177    
1178            /**
1179             * Returns the last document library file entry type in the ordered set where uuid = &#63; and companyId = &#63;.
1180             *
1181             * @param uuid the uuid
1182             * @param companyId the company ID
1183             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1184             * @return the last matching document library file entry type
1185             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1186             */
1187            @Override
1188            public DLFileEntryType findByUuid_C_Last(String uuid, long companyId,
1189                    OrderByComparator<DLFileEntryType> orderByComparator)
1190                    throws NoSuchFileEntryTypeException {
1191                    DLFileEntryType dlFileEntryType = fetchByUuid_C_Last(uuid, companyId,
1192                                    orderByComparator);
1193    
1194                    if (dlFileEntryType != null) {
1195                            return dlFileEntryType;
1196                    }
1197    
1198                    StringBundler msg = new StringBundler(6);
1199    
1200                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1201    
1202                    msg.append("uuid=");
1203                    msg.append(uuid);
1204    
1205                    msg.append(", companyId=");
1206                    msg.append(companyId);
1207    
1208                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1209    
1210                    throw new NoSuchFileEntryTypeException(msg.toString());
1211            }
1212    
1213            /**
1214             * Returns the last document library file entry type in the ordered set where uuid = &#63; and companyId = &#63;.
1215             *
1216             * @param uuid the uuid
1217             * @param companyId the company ID
1218             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1219             * @return the last matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1220             */
1221            @Override
1222            public DLFileEntryType fetchByUuid_C_Last(String uuid, long companyId,
1223                    OrderByComparator<DLFileEntryType> orderByComparator) {
1224                    int count = countByUuid_C(uuid, companyId);
1225    
1226                    if (count == 0) {
1227                            return null;
1228                    }
1229    
1230                    List<DLFileEntryType> list = findByUuid_C(uuid, companyId, count - 1,
1231                                    count, orderByComparator);
1232    
1233                    if (!list.isEmpty()) {
1234                            return list.get(0);
1235                    }
1236    
1237                    return null;
1238            }
1239    
1240            /**
1241             * Returns the document library file entry types before and after the current document library file entry type in the ordered set where uuid = &#63; and companyId = &#63;.
1242             *
1243             * @param fileEntryTypeId the primary key of the current document library file entry type
1244             * @param uuid the uuid
1245             * @param companyId the company ID
1246             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1247             * @return the previous, current, and next document library file entry type
1248             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
1249             */
1250            @Override
1251            public DLFileEntryType[] findByUuid_C_PrevAndNext(long fileEntryTypeId,
1252                    String uuid, long companyId,
1253                    OrderByComparator<DLFileEntryType> orderByComparator)
1254                    throws NoSuchFileEntryTypeException {
1255                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1256    
1257                    Session session = null;
1258    
1259                    try {
1260                            session = openSession();
1261    
1262                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1263    
1264                            array[0] = getByUuid_C_PrevAndNext(session, dlFileEntryType, uuid,
1265                                            companyId, orderByComparator, true);
1266    
1267                            array[1] = dlFileEntryType;
1268    
1269                            array[2] = getByUuid_C_PrevAndNext(session, dlFileEntryType, uuid,
1270                                            companyId, orderByComparator, false);
1271    
1272                            return array;
1273                    }
1274                    catch (Exception e) {
1275                            throw processException(e);
1276                    }
1277                    finally {
1278                            closeSession(session);
1279                    }
1280            }
1281    
1282            protected DLFileEntryType getByUuid_C_PrevAndNext(Session session,
1283                    DLFileEntryType dlFileEntryType, String uuid, long companyId,
1284                    OrderByComparator<DLFileEntryType> orderByComparator, boolean previous) {
1285                    StringBundler query = null;
1286    
1287                    if (orderByComparator != null) {
1288                            query = new StringBundler(6 +
1289                                            (orderByComparator.getOrderByFields().length * 6));
1290                    }
1291                    else {
1292                            query = new StringBundler(3);
1293                    }
1294    
1295                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1296    
1297                    boolean bindUuid = false;
1298    
1299                    if (uuid == null) {
1300                            query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1301                    }
1302                    else if (uuid.equals(StringPool.BLANK)) {
1303                            query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1304                    }
1305                    else {
1306                            bindUuid = true;
1307    
1308                            query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1309                    }
1310    
1311                    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1312    
1313                    if (orderByComparator != null) {
1314                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1315    
1316                            if (orderByConditionFields.length > 0) {
1317                                    query.append(WHERE_AND);
1318                            }
1319    
1320                            for (int i = 0; i < orderByConditionFields.length; i++) {
1321                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1322                                    query.append(orderByConditionFields[i]);
1323    
1324                                    if ((i + 1) < orderByConditionFields.length) {
1325                                            if (orderByComparator.isAscending() ^ previous) {
1326                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1327                                            }
1328                                            else {
1329                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1330                                            }
1331                                    }
1332                                    else {
1333                                            if (orderByComparator.isAscending() ^ previous) {
1334                                                    query.append(WHERE_GREATER_THAN);
1335                                            }
1336                                            else {
1337                                                    query.append(WHERE_LESSER_THAN);
1338                                            }
1339                                    }
1340                            }
1341    
1342                            query.append(ORDER_BY_CLAUSE);
1343    
1344                            String[] orderByFields = orderByComparator.getOrderByFields();
1345    
1346                            for (int i = 0; i < orderByFields.length; i++) {
1347                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1348                                    query.append(orderByFields[i]);
1349    
1350                                    if ((i + 1) < orderByFields.length) {
1351                                            if (orderByComparator.isAscending() ^ previous) {
1352                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1353                                            }
1354                                            else {
1355                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1356                                            }
1357                                    }
1358                                    else {
1359                                            if (orderByComparator.isAscending() ^ previous) {
1360                                                    query.append(ORDER_BY_ASC);
1361                                            }
1362                                            else {
1363                                                    query.append(ORDER_BY_DESC);
1364                                            }
1365                                    }
1366                            }
1367                    }
1368                    else {
1369                            query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
1370                    }
1371    
1372                    String sql = query.toString();
1373    
1374                    Query q = session.createQuery(sql);
1375    
1376                    q.setFirstResult(0);
1377                    q.setMaxResults(2);
1378    
1379                    QueryPos qPos = QueryPos.getInstance(q);
1380    
1381                    if (bindUuid) {
1382                            qPos.add(uuid);
1383                    }
1384    
1385                    qPos.add(companyId);
1386    
1387                    if (orderByComparator != null) {
1388                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1389    
1390                            for (Object value : values) {
1391                                    qPos.add(value);
1392                            }
1393                    }
1394    
1395                    List<DLFileEntryType> list = q.list();
1396    
1397                    if (list.size() == 2) {
1398                            return list.get(1);
1399                    }
1400                    else {
1401                            return null;
1402                    }
1403            }
1404    
1405            /**
1406             * Removes all the document library file entry types where uuid = &#63; and companyId = &#63; from the database.
1407             *
1408             * @param uuid the uuid
1409             * @param companyId the company ID
1410             */
1411            @Override
1412            public void removeByUuid_C(String uuid, long companyId) {
1413                    for (DLFileEntryType dlFileEntryType : findByUuid_C(uuid, companyId,
1414                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
1415                            remove(dlFileEntryType);
1416                    }
1417            }
1418    
1419            /**
1420             * Returns the number of document library file entry types where uuid = &#63; and companyId = &#63;.
1421             *
1422             * @param uuid the uuid
1423             * @param companyId the company ID
1424             * @return the number of matching document library file entry types
1425             */
1426            @Override
1427            public int countByUuid_C(String uuid, long companyId) {
1428                    FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID_C;
1429    
1430                    Object[] finderArgs = new Object[] { uuid, companyId };
1431    
1432                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
1433    
1434                    if (count == null) {
1435                            StringBundler query = new StringBundler(3);
1436    
1437                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
1438    
1439                            boolean bindUuid = false;
1440    
1441                            if (uuid == null) {
1442                                    query.append(_FINDER_COLUMN_UUID_C_UUID_1);
1443                            }
1444                            else if (uuid.equals(StringPool.BLANK)) {
1445                                    query.append(_FINDER_COLUMN_UUID_C_UUID_3);
1446                            }
1447                            else {
1448                                    bindUuid = true;
1449    
1450                                    query.append(_FINDER_COLUMN_UUID_C_UUID_2);
1451                            }
1452    
1453                            query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
1454    
1455                            String sql = query.toString();
1456    
1457                            Session session = null;
1458    
1459                            try {
1460                                    session = openSession();
1461    
1462                                    Query q = session.createQuery(sql);
1463    
1464                                    QueryPos qPos = QueryPos.getInstance(q);
1465    
1466                                    if (bindUuid) {
1467                                            qPos.add(uuid);
1468                                    }
1469    
1470                                    qPos.add(companyId);
1471    
1472                                    count = (Long)q.uniqueResult();
1473    
1474                                    finderCache.putResult(finderPath, finderArgs, count);
1475                            }
1476                            catch (Exception e) {
1477                                    finderCache.removeResult(finderPath, finderArgs);
1478    
1479                                    throw processException(e);
1480                            }
1481                            finally {
1482                                    closeSession(session);
1483                            }
1484                    }
1485    
1486                    return count.intValue();
1487            }
1488    
1489            private static final String _FINDER_COLUMN_UUID_C_UUID_1 = "dlFileEntryType.uuid IS NULL AND ";
1490            private static final String _FINDER_COLUMN_UUID_C_UUID_2 = "dlFileEntryType.uuid = ? AND ";
1491            private static final String _FINDER_COLUMN_UUID_C_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = '') AND ";
1492            private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 = "dlFileEntryType.companyId = ?";
1493            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
1494                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
1495                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
1496                            "findByGroupId",
1497                            new String[] {
1498                                    Long.class.getName(),
1499                                    
1500                            Integer.class.getName(), Integer.class.getName(),
1501                                    OrderByComparator.class.getName()
1502                            });
1503            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
1504                    new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
1505                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
1506                            DLFileEntryTypeImpl.class,
1507                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
1508                            new String[] { Long.class.getName() },
1509                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
1510            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
1511                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1512                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
1513                            new String[] { Long.class.getName() });
1514            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
1515                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
1516                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
1517                            new String[] { Long.class.getName() });
1518    
1519            /**
1520             * Returns all the document library file entry types where groupId = &#63;.
1521             *
1522             * @param groupId the group ID
1523             * @return the matching document library file entry types
1524             */
1525            @Override
1526            public List<DLFileEntryType> findByGroupId(long groupId) {
1527                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1528            }
1529    
1530            /**
1531             * Returns a range of all the document library file entry types where groupId = &#63;.
1532             *
1533             * <p>
1534             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
1535             * </p>
1536             *
1537             * @param groupId the group ID
1538             * @param start the lower bound of the range of document library file entry types
1539             * @param end the upper bound of the range of document library file entry types (not inclusive)
1540             * @return the range of matching document library file entry types
1541             */
1542            @Override
1543            public List<DLFileEntryType> findByGroupId(long groupId, int start, int end) {
1544                    return findByGroupId(groupId, start, end, null);
1545            }
1546    
1547            /**
1548             * Returns an ordered range of all the document library file entry types where groupId = &#63;.
1549             *
1550             * <p>
1551             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
1552             * </p>
1553             *
1554             * @param groupId the group ID
1555             * @param start the lower bound of the range of document library file entry types
1556             * @param end the upper bound of the range of document library file entry types (not inclusive)
1557             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1558             * @return the ordered range of matching document library file entry types
1559             */
1560            @Override
1561            public List<DLFileEntryType> findByGroupId(long groupId, int start,
1562                    int end, OrderByComparator<DLFileEntryType> orderByComparator) {
1563                    return findByGroupId(groupId, start, end, orderByComparator, true);
1564            }
1565    
1566            /**
1567             * Returns an ordered range of all the document library file entry types where groupId = &#63;.
1568             *
1569             * <p>
1570             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
1571             * </p>
1572             *
1573             * @param groupId the group ID
1574             * @param start the lower bound of the range of document library file entry types
1575             * @param end the upper bound of the range of document library file entry types (not inclusive)
1576             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1577             * @param retrieveFromCache whether to retrieve from the finder cache
1578             * @return the ordered range of matching document library file entry types
1579             */
1580            @Override
1581            public List<DLFileEntryType> findByGroupId(long groupId, int start,
1582                    int end, OrderByComparator<DLFileEntryType> orderByComparator,
1583                    boolean retrieveFromCache) {
1584                    boolean pagination = true;
1585                    FinderPath finderPath = null;
1586                    Object[] finderArgs = null;
1587    
1588                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1589                                    (orderByComparator == null)) {
1590                            pagination = false;
1591                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1592                            finderArgs = new Object[] { groupId };
1593                    }
1594                    else {
1595                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1596                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1597                    }
1598    
1599                    List<DLFileEntryType> list = null;
1600    
1601                    if (retrieveFromCache) {
1602                            list = (List<DLFileEntryType>)finderCache.getResult(finderPath,
1603                                            finderArgs, this);
1604    
1605                            if ((list != null) && !list.isEmpty()) {
1606                                    for (DLFileEntryType dlFileEntryType : list) {
1607                                            if ((groupId != dlFileEntryType.getGroupId())) {
1608                                                    list = null;
1609    
1610                                                    break;
1611                                            }
1612                                    }
1613                            }
1614                    }
1615    
1616                    if (list == null) {
1617                            StringBundler query = null;
1618    
1619                            if (orderByComparator != null) {
1620                                    query = new StringBundler(3 +
1621                                                    (orderByComparator.getOrderByFields().length * 3));
1622                            }
1623                            else {
1624                                    query = new StringBundler(3);
1625                            }
1626    
1627                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1628    
1629                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1630    
1631                            if (orderByComparator != null) {
1632                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1633                                            orderByComparator);
1634                            }
1635                            else
1636                             if (pagination) {
1637                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
1638                            }
1639    
1640                            String sql = query.toString();
1641    
1642                            Session session = null;
1643    
1644                            try {
1645                                    session = openSession();
1646    
1647                                    Query q = session.createQuery(sql);
1648    
1649                                    QueryPos qPos = QueryPos.getInstance(q);
1650    
1651                                    qPos.add(groupId);
1652    
1653                                    if (!pagination) {
1654                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
1655                                                            getDialect(), start, end, false);
1656    
1657                                            Collections.sort(list);
1658    
1659                                            list = Collections.unmodifiableList(list);
1660                                    }
1661                                    else {
1662                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
1663                                                            getDialect(), start, end);
1664                                    }
1665    
1666                                    cacheResult(list);
1667    
1668                                    finderCache.putResult(finderPath, finderArgs, list);
1669                            }
1670                            catch (Exception e) {
1671                                    finderCache.removeResult(finderPath, finderArgs);
1672    
1673                                    throw processException(e);
1674                            }
1675                            finally {
1676                                    closeSession(session);
1677                            }
1678                    }
1679    
1680                    return list;
1681            }
1682    
1683            /**
1684             * Returns the first document library file entry type in the ordered set where groupId = &#63;.
1685             *
1686             * @param groupId the group ID
1687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1688             * @return the first matching document library file entry type
1689             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1690             */
1691            @Override
1692            public DLFileEntryType findByGroupId_First(long groupId,
1693                    OrderByComparator<DLFileEntryType> orderByComparator)
1694                    throws NoSuchFileEntryTypeException {
1695                    DLFileEntryType dlFileEntryType = fetchByGroupId_First(groupId,
1696                                    orderByComparator);
1697    
1698                    if (dlFileEntryType != null) {
1699                            return dlFileEntryType;
1700                    }
1701    
1702                    StringBundler msg = new StringBundler(4);
1703    
1704                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1705    
1706                    msg.append("groupId=");
1707                    msg.append(groupId);
1708    
1709                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1710    
1711                    throw new NoSuchFileEntryTypeException(msg.toString());
1712            }
1713    
1714            /**
1715             * Returns the first document library file entry type in the ordered set where groupId = &#63;.
1716             *
1717             * @param groupId the group ID
1718             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1719             * @return the first matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1720             */
1721            @Override
1722            public DLFileEntryType fetchByGroupId_First(long groupId,
1723                    OrderByComparator<DLFileEntryType> orderByComparator) {
1724                    List<DLFileEntryType> list = findByGroupId(groupId, 0, 1,
1725                                    orderByComparator);
1726    
1727                    if (!list.isEmpty()) {
1728                            return list.get(0);
1729                    }
1730    
1731                    return null;
1732            }
1733    
1734            /**
1735             * Returns the last document library file entry type in the ordered set where groupId = &#63;.
1736             *
1737             * @param groupId the group ID
1738             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1739             * @return the last matching document library file entry type
1740             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1741             */
1742            @Override
1743            public DLFileEntryType findByGroupId_Last(long groupId,
1744                    OrderByComparator<DLFileEntryType> orderByComparator)
1745                    throws NoSuchFileEntryTypeException {
1746                    DLFileEntryType dlFileEntryType = fetchByGroupId_Last(groupId,
1747                                    orderByComparator);
1748    
1749                    if (dlFileEntryType != null) {
1750                            return dlFileEntryType;
1751                    }
1752    
1753                    StringBundler msg = new StringBundler(4);
1754    
1755                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1756    
1757                    msg.append("groupId=");
1758                    msg.append(groupId);
1759    
1760                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1761    
1762                    throw new NoSuchFileEntryTypeException(msg.toString());
1763            }
1764    
1765            /**
1766             * Returns the last document library file entry type in the ordered set where groupId = &#63;.
1767             *
1768             * @param groupId the group ID
1769             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1770             * @return the last matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1771             */
1772            @Override
1773            public DLFileEntryType fetchByGroupId_Last(long groupId,
1774                    OrderByComparator<DLFileEntryType> orderByComparator) {
1775                    int count = countByGroupId(groupId);
1776    
1777                    if (count == 0) {
1778                            return null;
1779                    }
1780    
1781                    List<DLFileEntryType> list = findByGroupId(groupId, count - 1, count,
1782                                    orderByComparator);
1783    
1784                    if (!list.isEmpty()) {
1785                            return list.get(0);
1786                    }
1787    
1788                    return null;
1789            }
1790    
1791            /**
1792             * Returns the document library file entry types before and after the current document library file entry type in the ordered set where groupId = &#63;.
1793             *
1794             * @param fileEntryTypeId the primary key of the current document library file entry type
1795             * @param groupId the group ID
1796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1797             * @return the previous, current, and next document library file entry type
1798             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
1799             */
1800            @Override
1801            public DLFileEntryType[] findByGroupId_PrevAndNext(long fileEntryTypeId,
1802                    long groupId, OrderByComparator<DLFileEntryType> orderByComparator)
1803                    throws NoSuchFileEntryTypeException {
1804                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1805    
1806                    Session session = null;
1807    
1808                    try {
1809                            session = openSession();
1810    
1811                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1812    
1813                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1814                                            groupId, orderByComparator, true);
1815    
1816                            array[1] = dlFileEntryType;
1817    
1818                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1819                                            groupId, orderByComparator, false);
1820    
1821                            return array;
1822                    }
1823                    catch (Exception e) {
1824                            throw processException(e);
1825                    }
1826                    finally {
1827                            closeSession(session);
1828                    }
1829            }
1830    
1831            protected DLFileEntryType getByGroupId_PrevAndNext(Session session,
1832                    DLFileEntryType dlFileEntryType, long groupId,
1833                    OrderByComparator<DLFileEntryType> orderByComparator, boolean previous) {
1834                    StringBundler query = null;
1835    
1836                    if (orderByComparator != null) {
1837                            query = new StringBundler(6 +
1838                                            (orderByComparator.getOrderByFields().length * 6));
1839                    }
1840                    else {
1841                            query = new StringBundler(3);
1842                    }
1843    
1844                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1845    
1846                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1847    
1848                    if (orderByComparator != null) {
1849                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1850    
1851                            if (orderByConditionFields.length > 0) {
1852                                    query.append(WHERE_AND);
1853                            }
1854    
1855                            for (int i = 0; i < orderByConditionFields.length; i++) {
1856                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1857                                    query.append(orderByConditionFields[i]);
1858    
1859                                    if ((i + 1) < orderByConditionFields.length) {
1860                                            if (orderByComparator.isAscending() ^ previous) {
1861                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1862                                            }
1863                                            else {
1864                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1865                                            }
1866                                    }
1867                                    else {
1868                                            if (orderByComparator.isAscending() ^ previous) {
1869                                                    query.append(WHERE_GREATER_THAN);
1870                                            }
1871                                            else {
1872                                                    query.append(WHERE_LESSER_THAN);
1873                                            }
1874                                    }
1875                            }
1876    
1877                            query.append(ORDER_BY_CLAUSE);
1878    
1879                            String[] orderByFields = orderByComparator.getOrderByFields();
1880    
1881                            for (int i = 0; i < orderByFields.length; i++) {
1882                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1883                                    query.append(orderByFields[i]);
1884    
1885                                    if ((i + 1) < orderByFields.length) {
1886                                            if (orderByComparator.isAscending() ^ previous) {
1887                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1888                                            }
1889                                            else {
1890                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1891                                            }
1892                                    }
1893                                    else {
1894                                            if (orderByComparator.isAscending() ^ previous) {
1895                                                    query.append(ORDER_BY_ASC);
1896                                            }
1897                                            else {
1898                                                    query.append(ORDER_BY_DESC);
1899                                            }
1900                                    }
1901                            }
1902                    }
1903                    else {
1904                            query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
1905                    }
1906    
1907                    String sql = query.toString();
1908    
1909                    Query q = session.createQuery(sql);
1910    
1911                    q.setFirstResult(0);
1912                    q.setMaxResults(2);
1913    
1914                    QueryPos qPos = QueryPos.getInstance(q);
1915    
1916                    qPos.add(groupId);
1917    
1918                    if (orderByComparator != null) {
1919                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1920    
1921                            for (Object value : values) {
1922                                    qPos.add(value);
1923                            }
1924                    }
1925    
1926                    List<DLFileEntryType> list = q.list();
1927    
1928                    if (list.size() == 2) {
1929                            return list.get(1);
1930                    }
1931                    else {
1932                            return null;
1933                    }
1934            }
1935    
1936            /**
1937             * Returns all the document library file entry types that the user has permission to view where groupId = &#63;.
1938             *
1939             * @param groupId the group ID
1940             * @return the matching document library file entry types that the user has permission to view
1941             */
1942            @Override
1943            public List<DLFileEntryType> filterFindByGroupId(long groupId) {
1944                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1945                            QueryUtil.ALL_POS, null);
1946            }
1947    
1948            /**
1949             * Returns a range of all the document library file entry types that the user has permission to view where groupId = &#63;.
1950             *
1951             * <p>
1952             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
1953             * </p>
1954             *
1955             * @param groupId the group ID
1956             * @param start the lower bound of the range of document library file entry types
1957             * @param end the upper bound of the range of document library file entry types (not inclusive)
1958             * @return the range of matching document library file entry types that the user has permission to view
1959             */
1960            @Override
1961            public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1962                    int end) {
1963                    return filterFindByGroupId(groupId, start, end, null);
1964            }
1965    
1966            /**
1967             * Returns an ordered range of all the document library file entry types that the user has permissions to view where groupId = &#63;.
1968             *
1969             * <p>
1970             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
1971             * </p>
1972             *
1973             * @param groupId the group ID
1974             * @param start the lower bound of the range of document library file entry types
1975             * @param end the upper bound of the range of document library file entry types (not inclusive)
1976             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1977             * @return the ordered range of matching document library file entry types that the user has permission to view
1978             */
1979            @Override
1980            public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1981                    int end, OrderByComparator<DLFileEntryType> orderByComparator) {
1982                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1983                            return findByGroupId(groupId, start, end, orderByComparator);
1984                    }
1985    
1986                    StringBundler query = null;
1987    
1988                    if (orderByComparator != null) {
1989                            query = new StringBundler(3 +
1990                                            (orderByComparator.getOrderByFields().length * 3));
1991                    }
1992                    else {
1993                            query = new StringBundler(3);
1994                    }
1995    
1996                    if (getDB().isSupportsInlineDistinct()) {
1997                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1998                    }
1999                    else {
2000                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
2001                    }
2002    
2003                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2004    
2005                    if (!getDB().isSupportsInlineDistinct()) {
2006                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2007                    }
2008    
2009                    if (orderByComparator != null) {
2010                            if (getDB().isSupportsInlineDistinct()) {
2011                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2012                                            orderByComparator, true);
2013                            }
2014                            else {
2015                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2016                                            orderByComparator, true);
2017                            }
2018                    }
2019                    else {
2020                            if (getDB().isSupportsInlineDistinct()) {
2021                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
2022                            }
2023                            else {
2024                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_SQL);
2025                            }
2026                    }
2027    
2028                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2029                                    DLFileEntryType.class.getName(),
2030                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2031    
2032                    Session session = null;
2033    
2034                    try {
2035                            session = openSession();
2036    
2037                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2038    
2039                            if (getDB().isSupportsInlineDistinct()) {
2040                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2041                            }
2042                            else {
2043                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2044                            }
2045    
2046                            QueryPos qPos = QueryPos.getInstance(q);
2047    
2048                            qPos.add(groupId);
2049    
2050                            return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
2051                                    start, end);
2052                    }
2053                    catch (Exception e) {
2054                            throw processException(e);
2055                    }
2056                    finally {
2057                            closeSession(session);
2058                    }
2059            }
2060    
2061            /**
2062             * Returns the document library file entry types before and after the current document library file entry type in the ordered set of document library file entry types that the user has permission to view where groupId = &#63;.
2063             *
2064             * @param fileEntryTypeId the primary key of the current document library file entry type
2065             * @param groupId the group ID
2066             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2067             * @return the previous, current, and next document library file entry type
2068             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
2069             */
2070            @Override
2071            public DLFileEntryType[] filterFindByGroupId_PrevAndNext(
2072                    long fileEntryTypeId, long groupId,
2073                    OrderByComparator<DLFileEntryType> orderByComparator)
2074                    throws NoSuchFileEntryTypeException {
2075                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2076                            return findByGroupId_PrevAndNext(fileEntryTypeId, groupId,
2077                                    orderByComparator);
2078                    }
2079    
2080                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
2081    
2082                    Session session = null;
2083    
2084                    try {
2085                            session = openSession();
2086    
2087                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
2088    
2089                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
2090                                            groupId, orderByComparator, true);
2091    
2092                            array[1] = dlFileEntryType;
2093    
2094                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
2095                                            groupId, orderByComparator, false);
2096    
2097                            return array;
2098                    }
2099                    catch (Exception e) {
2100                            throw processException(e);
2101                    }
2102                    finally {
2103                            closeSession(session);
2104                    }
2105            }
2106    
2107            protected DLFileEntryType filterGetByGroupId_PrevAndNext(Session session,
2108                    DLFileEntryType dlFileEntryType, long groupId,
2109                    OrderByComparator<DLFileEntryType> orderByComparator, boolean previous) {
2110                    StringBundler query = null;
2111    
2112                    if (orderByComparator != null) {
2113                            query = new StringBundler(6 +
2114                                            (orderByComparator.getOrderByFields().length * 6));
2115                    }
2116                    else {
2117                            query = new StringBundler(3);
2118                    }
2119    
2120                    if (getDB().isSupportsInlineDistinct()) {
2121                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2122                    }
2123                    else {
2124                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
2125                    }
2126    
2127                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2128    
2129                    if (!getDB().isSupportsInlineDistinct()) {
2130                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2131                    }
2132    
2133                    if (orderByComparator != null) {
2134                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2135    
2136                            if (orderByConditionFields.length > 0) {
2137                                    query.append(WHERE_AND);
2138                            }
2139    
2140                            for (int i = 0; i < orderByConditionFields.length; i++) {
2141                                    if (getDB().isSupportsInlineDistinct()) {
2142                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2143                                    }
2144                                    else {
2145                                            query.append(_ORDER_BY_ENTITY_TABLE);
2146                                    }
2147    
2148                                    query.append(orderByConditionFields[i]);
2149    
2150                                    if ((i + 1) < orderByConditionFields.length) {
2151                                            if (orderByComparator.isAscending() ^ previous) {
2152                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2153                                            }
2154                                            else {
2155                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2156                                            }
2157                                    }
2158                                    else {
2159                                            if (orderByComparator.isAscending() ^ previous) {
2160                                                    query.append(WHERE_GREATER_THAN);
2161                                            }
2162                                            else {
2163                                                    query.append(WHERE_LESSER_THAN);
2164                                            }
2165                                    }
2166                            }
2167    
2168                            query.append(ORDER_BY_CLAUSE);
2169    
2170                            String[] orderByFields = orderByComparator.getOrderByFields();
2171    
2172                            for (int i = 0; i < orderByFields.length; i++) {
2173                                    if (getDB().isSupportsInlineDistinct()) {
2174                                            query.append(_ORDER_BY_ENTITY_ALIAS);
2175                                    }
2176                                    else {
2177                                            query.append(_ORDER_BY_ENTITY_TABLE);
2178                                    }
2179    
2180                                    query.append(orderByFields[i]);
2181    
2182                                    if ((i + 1) < orderByFields.length) {
2183                                            if (orderByComparator.isAscending() ^ previous) {
2184                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2185                                            }
2186                                            else {
2187                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2188                                            }
2189                                    }
2190                                    else {
2191                                            if (orderByComparator.isAscending() ^ previous) {
2192                                                    query.append(ORDER_BY_ASC);
2193                                            }
2194                                            else {
2195                                                    query.append(ORDER_BY_DESC);
2196                                            }
2197                                    }
2198                            }
2199                    }
2200                    else {
2201                            if (getDB().isSupportsInlineDistinct()) {
2202                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
2203                            }
2204                            else {
2205                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_SQL);
2206                            }
2207                    }
2208    
2209                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2210                                    DLFileEntryType.class.getName(),
2211                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2212    
2213                    SQLQuery q = session.createSynchronizedSQLQuery(sql);
2214    
2215                    q.setFirstResult(0);
2216                    q.setMaxResults(2);
2217    
2218                    if (getDB().isSupportsInlineDistinct()) {
2219                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2220                    }
2221                    else {
2222                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2223                    }
2224    
2225                    QueryPos qPos = QueryPos.getInstance(q);
2226    
2227                    qPos.add(groupId);
2228    
2229                    if (orderByComparator != null) {
2230                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
2231    
2232                            for (Object value : values) {
2233                                    qPos.add(value);
2234                            }
2235                    }
2236    
2237                    List<DLFileEntryType> list = q.list();
2238    
2239                    if (list.size() == 2) {
2240                            return list.get(1);
2241                    }
2242                    else {
2243                            return null;
2244                    }
2245            }
2246    
2247            /**
2248             * Returns all the document library file entry types that the user has permission to view where groupId = any &#63;.
2249             *
2250             * @param groupIds the group IDs
2251             * @return the matching document library file entry types that the user has permission to view
2252             */
2253            @Override
2254            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds) {
2255                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2256                            QueryUtil.ALL_POS, null);
2257            }
2258    
2259            /**
2260             * Returns a range of all the document library file entry types that the user has permission to view where groupId = any &#63;.
2261             *
2262             * <p>
2263             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2264             * </p>
2265             *
2266             * @param groupIds the group IDs
2267             * @param start the lower bound of the range of document library file entry types
2268             * @param end the upper bound of the range of document library file entry types (not inclusive)
2269             * @return the range of matching document library file entry types that the user has permission to view
2270             */
2271            @Override
2272            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
2273                    int start, int end) {
2274                    return filterFindByGroupId(groupIds, start, end, null);
2275            }
2276    
2277            /**
2278             * Returns an ordered range of all the document library file entry types that the user has permission to view where groupId = any &#63;.
2279             *
2280             * <p>
2281             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2282             * </p>
2283             *
2284             * @param groupIds the group IDs
2285             * @param start the lower bound of the range of document library file entry types
2286             * @param end the upper bound of the range of document library file entry types (not inclusive)
2287             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2288             * @return the ordered range of matching document library file entry types that the user has permission to view
2289             */
2290            @Override
2291            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
2292                    int start, int end, OrderByComparator<DLFileEntryType> orderByComparator) {
2293                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2294                            return findByGroupId(groupIds, start, end, orderByComparator);
2295                    }
2296    
2297                    if (groupIds == null) {
2298                            groupIds = new long[0];
2299                    }
2300                    else if (groupIds.length > 1) {
2301                            groupIds = ArrayUtil.unique(groupIds);
2302    
2303                            Arrays.sort(groupIds);
2304                    }
2305    
2306                    StringBundler query = new StringBundler();
2307    
2308                    if (getDB().isSupportsInlineDistinct()) {
2309                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2310                    }
2311                    else {
2312                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
2313                    }
2314    
2315                    if (groupIds.length > 0) {
2316                            query.append(StringPool.OPEN_PARENTHESIS);
2317    
2318                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2319    
2320                            query.append(StringUtil.merge(groupIds));
2321    
2322                            query.append(StringPool.CLOSE_PARENTHESIS);
2323    
2324                            query.append(StringPool.CLOSE_PARENTHESIS);
2325                    }
2326    
2327                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2328                            query.index() - 1);
2329    
2330                    if (!getDB().isSupportsInlineDistinct()) {
2331                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2332                    }
2333    
2334                    if (orderByComparator != null) {
2335                            if (getDB().isSupportsInlineDistinct()) {
2336                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2337                                            orderByComparator, true);
2338                            }
2339                            else {
2340                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2341                                            orderByComparator, true);
2342                            }
2343                    }
2344                    else {
2345                            if (getDB().isSupportsInlineDistinct()) {
2346                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
2347                            }
2348                            else {
2349                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_SQL);
2350                            }
2351                    }
2352    
2353                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2354                                    DLFileEntryType.class.getName(),
2355                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2356    
2357                    Session session = null;
2358    
2359                    try {
2360                            session = openSession();
2361    
2362                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2363    
2364                            if (getDB().isSupportsInlineDistinct()) {
2365                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2366                            }
2367                            else {
2368                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2369                            }
2370    
2371                            return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
2372                                    start, end);
2373                    }
2374                    catch (Exception e) {
2375                            throw processException(e);
2376                    }
2377                    finally {
2378                            closeSession(session);
2379                    }
2380            }
2381    
2382            /**
2383             * Returns all the document library file entry types where groupId = any &#63;.
2384             *
2385             * <p>
2386             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2387             * </p>
2388             *
2389             * @param groupIds the group IDs
2390             * @return the matching document library file entry types
2391             */
2392            @Override
2393            public List<DLFileEntryType> findByGroupId(long[] groupIds) {
2394                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
2395                            null);
2396            }
2397    
2398            /**
2399             * Returns a range of all the document library file entry types where groupId = any &#63;.
2400             *
2401             * <p>
2402             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2403             * </p>
2404             *
2405             * @param groupIds the group IDs
2406             * @param start the lower bound of the range of document library file entry types
2407             * @param end the upper bound of the range of document library file entry types (not inclusive)
2408             * @return the range of matching document library file entry types
2409             */
2410            @Override
2411            public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
2412                    int end) {
2413                    return findByGroupId(groupIds, start, end, null);
2414            }
2415    
2416            /**
2417             * Returns an ordered range of all the document library file entry types where groupId = any &#63;.
2418             *
2419             * <p>
2420             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2421             * </p>
2422             *
2423             * @param groupIds the group IDs
2424             * @param start the lower bound of the range of document library file entry types
2425             * @param end the upper bound of the range of document library file entry types (not inclusive)
2426             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2427             * @return the ordered range of matching document library file entry types
2428             */
2429            @Override
2430            public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
2431                    int end, OrderByComparator<DLFileEntryType> orderByComparator) {
2432                    return findByGroupId(groupIds, start, end, orderByComparator, true);
2433            }
2434    
2435            /**
2436             * Returns an ordered range of all the document library file entry types where groupId = &#63;, optionally using the finder cache.
2437             *
2438             * <p>
2439             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
2440             * </p>
2441             *
2442             * @param groupId the group ID
2443             * @param start the lower bound of the range of document library file entry types
2444             * @param end the upper bound of the range of document library file entry types (not inclusive)
2445             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2446             * @param retrieveFromCache whether to retrieve from the finder cache
2447             * @return the ordered range of matching document library file entry types
2448             */
2449            @Override
2450            public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
2451                    int end, OrderByComparator<DLFileEntryType> orderByComparator,
2452                    boolean retrieveFromCache) {
2453                    if (groupIds == null) {
2454                            groupIds = new long[0];
2455                    }
2456                    else if (groupIds.length > 1) {
2457                            groupIds = ArrayUtil.unique(groupIds);
2458    
2459                            Arrays.sort(groupIds);
2460                    }
2461    
2462                    if (groupIds.length == 1) {
2463                            return findByGroupId(groupIds[0], start, end, orderByComparator);
2464                    }
2465    
2466                    boolean pagination = true;
2467                    Object[] finderArgs = null;
2468    
2469                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2470                                    (orderByComparator == null)) {
2471                            pagination = false;
2472                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
2473                    }
2474                    else {
2475                            finderArgs = new Object[] {
2476                                            StringUtil.merge(groupIds),
2477                                            
2478                                            start, end, orderByComparator
2479                                    };
2480                    }
2481    
2482                    List<DLFileEntryType> list = null;
2483    
2484                    if (retrieveFromCache) {
2485                            list = (List<DLFileEntryType>)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2486                                            finderArgs, this);
2487    
2488                            if ((list != null) && !list.isEmpty()) {
2489                                    for (DLFileEntryType dlFileEntryType : list) {
2490                                            if (!ArrayUtil.contains(groupIds,
2491                                                                    dlFileEntryType.getGroupId())) {
2492                                                    list = null;
2493    
2494                                                    break;
2495                                            }
2496                                    }
2497                            }
2498                    }
2499    
2500                    if (list == null) {
2501                            StringBundler query = new StringBundler();
2502    
2503                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2504    
2505                            if (groupIds.length > 0) {
2506                                    query.append(StringPool.OPEN_PARENTHESIS);
2507    
2508                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2509    
2510                                    query.append(StringUtil.merge(groupIds));
2511    
2512                                    query.append(StringPool.CLOSE_PARENTHESIS);
2513    
2514                                    query.append(StringPool.CLOSE_PARENTHESIS);
2515                            }
2516    
2517                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2518                                                    1)), query.index() - 1);
2519    
2520                            if (orderByComparator != null) {
2521                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2522                                            orderByComparator);
2523                            }
2524                            else
2525                             if (pagination) {
2526                                    query.append(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
2527                            }
2528    
2529                            String sql = query.toString();
2530    
2531                            Session session = null;
2532    
2533                            try {
2534                                    session = openSession();
2535    
2536                                    Query q = session.createQuery(sql);
2537    
2538                                    if (!pagination) {
2539                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
2540                                                            getDialect(), start, end, false);
2541    
2542                                            Collections.sort(list);
2543    
2544                                            list = Collections.unmodifiableList(list);
2545                                    }
2546                                    else {
2547                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
2548                                                            getDialect(), start, end);
2549                                    }
2550    
2551                                    cacheResult(list);
2552    
2553                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2554                                            finderArgs, list);
2555                            }
2556                            catch (Exception e) {
2557                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID,
2558                                            finderArgs);
2559    
2560                                    throw processException(e);
2561                            }
2562                            finally {
2563                                    closeSession(session);
2564                            }
2565                    }
2566    
2567                    return list;
2568            }
2569    
2570            /**
2571             * Removes all the document library file entry types where groupId = &#63; from the database.
2572             *
2573             * @param groupId the group ID
2574             */
2575            @Override
2576            public void removeByGroupId(long groupId) {
2577                    for (DLFileEntryType dlFileEntryType : findByGroupId(groupId,
2578                                    QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
2579                            remove(dlFileEntryType);
2580                    }
2581            }
2582    
2583            /**
2584             * Returns the number of document library file entry types where groupId = &#63;.
2585             *
2586             * @param groupId the group ID
2587             * @return the number of matching document library file entry types
2588             */
2589            @Override
2590            public int countByGroupId(long groupId) {
2591                    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
2592    
2593                    Object[] finderArgs = new Object[] { groupId };
2594    
2595                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
2596    
2597                    if (count == null) {
2598                            StringBundler query = new StringBundler(2);
2599    
2600                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2601    
2602                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2603    
2604                            String sql = query.toString();
2605    
2606                            Session session = null;
2607    
2608                            try {
2609                                    session = openSession();
2610    
2611                                    Query q = session.createQuery(sql);
2612    
2613                                    QueryPos qPos = QueryPos.getInstance(q);
2614    
2615                                    qPos.add(groupId);
2616    
2617                                    count = (Long)q.uniqueResult();
2618    
2619                                    finderCache.putResult(finderPath, finderArgs, count);
2620                            }
2621                            catch (Exception e) {
2622                                    finderCache.removeResult(finderPath, finderArgs);
2623    
2624                                    throw processException(e);
2625                            }
2626                            finally {
2627                                    closeSession(session);
2628                            }
2629                    }
2630    
2631                    return count.intValue();
2632            }
2633    
2634            /**
2635             * Returns the number of document library file entry types where groupId = any &#63;.
2636             *
2637             * @param groupIds the group IDs
2638             * @return the number of matching document library file entry types
2639             */
2640            @Override
2641            public int countByGroupId(long[] groupIds) {
2642                    if (groupIds == null) {
2643                            groupIds = new long[0];
2644                    }
2645                    else if (groupIds.length > 1) {
2646                            groupIds = ArrayUtil.unique(groupIds);
2647    
2648                            Arrays.sort(groupIds);
2649                    }
2650    
2651                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2652    
2653                    Long count = (Long)finderCache.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2654                                    finderArgs, this);
2655    
2656                    if (count == null) {
2657                            StringBundler query = new StringBundler();
2658    
2659                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2660    
2661                            if (groupIds.length > 0) {
2662                                    query.append(StringPool.OPEN_PARENTHESIS);
2663    
2664                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2665    
2666                                    query.append(StringUtil.merge(groupIds));
2667    
2668                                    query.append(StringPool.CLOSE_PARENTHESIS);
2669    
2670                                    query.append(StringPool.CLOSE_PARENTHESIS);
2671                            }
2672    
2673                            query.setStringAt(removeConjunction(query.stringAt(query.index() -
2674                                                    1)), query.index() - 1);
2675    
2676                            String sql = query.toString();
2677    
2678                            Session session = null;
2679    
2680                            try {
2681                                    session = openSession();
2682    
2683                                    Query q = session.createQuery(sql);
2684    
2685                                    count = (Long)q.uniqueResult();
2686    
2687                                    finderCache.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2688                                            finderArgs, count);
2689                            }
2690                            catch (Exception e) {
2691                                    finderCache.removeResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2692                                            finderArgs);
2693    
2694                                    throw processException(e);
2695                            }
2696                            finally {
2697                                    closeSession(session);
2698                            }
2699                    }
2700    
2701                    return count.intValue();
2702            }
2703    
2704            /**
2705             * Returns the number of document library file entry types that the user has permission to view where groupId = &#63;.
2706             *
2707             * @param groupId the group ID
2708             * @return the number of matching document library file entry types that the user has permission to view
2709             */
2710            @Override
2711            public int filterCountByGroupId(long groupId) {
2712                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2713                            return countByGroupId(groupId);
2714                    }
2715    
2716                    StringBundler query = new StringBundler(2);
2717    
2718                    query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2719    
2720                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2721    
2722                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2723                                    DLFileEntryType.class.getName(),
2724                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2725    
2726                    Session session = null;
2727    
2728                    try {
2729                            session = openSession();
2730    
2731                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2732    
2733                            q.addScalar(COUNT_COLUMN_NAME,
2734                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2735    
2736                            QueryPos qPos = QueryPos.getInstance(q);
2737    
2738                            qPos.add(groupId);
2739    
2740                            Long count = (Long)q.uniqueResult();
2741    
2742                            return count.intValue();
2743                    }
2744                    catch (Exception e) {
2745                            throw processException(e);
2746                    }
2747                    finally {
2748                            closeSession(session);
2749                    }
2750            }
2751    
2752            /**
2753             * Returns the number of document library file entry types that the user has permission to view where groupId = any &#63;.
2754             *
2755             * @param groupIds the group IDs
2756             * @return the number of matching document library file entry types that the user has permission to view
2757             */
2758            @Override
2759            public int filterCountByGroupId(long[] groupIds) {
2760                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2761                            return countByGroupId(groupIds);
2762                    }
2763    
2764                    if (groupIds == null) {
2765                            groupIds = new long[0];
2766                    }
2767                    else if (groupIds.length > 1) {
2768                            groupIds = ArrayUtil.unique(groupIds);
2769    
2770                            Arrays.sort(groupIds);
2771                    }
2772    
2773                    StringBundler query = new StringBundler();
2774    
2775                    query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2776    
2777                    if (groupIds.length > 0) {
2778                            query.append(StringPool.OPEN_PARENTHESIS);
2779    
2780                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_7);
2781    
2782                            query.append(StringUtil.merge(groupIds));
2783    
2784                            query.append(StringPool.CLOSE_PARENTHESIS);
2785    
2786                            query.append(StringPool.CLOSE_PARENTHESIS);
2787                    }
2788    
2789                    query.setStringAt(removeConjunction(query.stringAt(query.index() - 1)),
2790                            query.index() - 1);
2791    
2792                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2793                                    DLFileEntryType.class.getName(),
2794                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2795    
2796                    Session session = null;
2797    
2798                    try {
2799                            session = openSession();
2800    
2801                            SQLQuery q = session.createSynchronizedSQLQuery(sql);
2802    
2803                            q.addScalar(COUNT_COLUMN_NAME,
2804                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2805    
2806                            Long count = (Long)q.uniqueResult();
2807    
2808                            return count.intValue();
2809                    }
2810                    catch (Exception e) {
2811                            throw processException(e);
2812                    }
2813                    finally {
2814                            closeSession(session);
2815                    }
2816            }
2817    
2818            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntryType.groupId = ?";
2819            private static final String _FINDER_COLUMN_GROUPID_GROUPID_7 = "dlFileEntryType.groupId IN (";
2820            public static final FinderPath FINDER_PATH_FETCH_BY_G_F = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
2821                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
2822                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_F",
2823                            new String[] { Long.class.getName(), String.class.getName() },
2824                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK |
2825                            DLFileEntryTypeModelImpl.FILEENTRYTYPEKEY_COLUMN_BITMASK);
2826            public static final FinderPath FINDER_PATH_COUNT_BY_G_F = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
2827                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
2828                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_F",
2829                            new String[] { Long.class.getName(), String.class.getName() });
2830    
2831            /**
2832             * Returns the document library file entry type where groupId = &#63; and fileEntryTypeKey = &#63; or throws a {@link NoSuchFileEntryTypeException} if it could not be found.
2833             *
2834             * @param groupId the group ID
2835             * @param fileEntryTypeKey the file entry type key
2836             * @return the matching document library file entry type
2837             * @throws NoSuchFileEntryTypeException if a matching document library file entry type could not be found
2838             */
2839            @Override
2840            public DLFileEntryType findByG_F(long groupId, String fileEntryTypeKey)
2841                    throws NoSuchFileEntryTypeException {
2842                    DLFileEntryType dlFileEntryType = fetchByG_F(groupId, fileEntryTypeKey);
2843    
2844                    if (dlFileEntryType == null) {
2845                            StringBundler msg = new StringBundler(6);
2846    
2847                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2848    
2849                            msg.append("groupId=");
2850                            msg.append(groupId);
2851    
2852                            msg.append(", fileEntryTypeKey=");
2853                            msg.append(fileEntryTypeKey);
2854    
2855                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2856    
2857                            if (_log.isWarnEnabled()) {
2858                                    _log.warn(msg.toString());
2859                            }
2860    
2861                            throw new NoSuchFileEntryTypeException(msg.toString());
2862                    }
2863    
2864                    return dlFileEntryType;
2865            }
2866    
2867            /**
2868             * Returns the document library file entry type where groupId = &#63; and fileEntryTypeKey = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2869             *
2870             * @param groupId the group ID
2871             * @param fileEntryTypeKey the file entry type key
2872             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
2873             */
2874            @Override
2875            public DLFileEntryType fetchByG_F(long groupId, String fileEntryTypeKey) {
2876                    return fetchByG_F(groupId, fileEntryTypeKey, true);
2877            }
2878    
2879            /**
2880             * Returns the document library file entry type where groupId = &#63; and fileEntryTypeKey = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2881             *
2882             * @param groupId the group ID
2883             * @param fileEntryTypeKey the file entry type key
2884             * @param retrieveFromCache whether to retrieve from the finder cache
2885             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
2886             */
2887            @Override
2888            public DLFileEntryType fetchByG_F(long groupId, String fileEntryTypeKey,
2889                    boolean retrieveFromCache) {
2890                    Object[] finderArgs = new Object[] { groupId, fileEntryTypeKey };
2891    
2892                    Object result = null;
2893    
2894                    if (retrieveFromCache) {
2895                            result = finderCache.getResult(FINDER_PATH_FETCH_BY_G_F,
2896                                            finderArgs, this);
2897                    }
2898    
2899                    if (result instanceof DLFileEntryType) {
2900                            DLFileEntryType dlFileEntryType = (DLFileEntryType)result;
2901    
2902                            if ((groupId != dlFileEntryType.getGroupId()) ||
2903                                            !Validator.equals(fileEntryTypeKey,
2904                                                    dlFileEntryType.getFileEntryTypeKey())) {
2905                                    result = null;
2906                            }
2907                    }
2908    
2909                    if (result == null) {
2910                            StringBundler query = new StringBundler(4);
2911    
2912                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2913    
2914                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
2915    
2916                            boolean bindFileEntryTypeKey = false;
2917    
2918                            if (fileEntryTypeKey == null) {
2919                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_1);
2920                            }
2921                            else if (fileEntryTypeKey.equals(StringPool.BLANK)) {
2922                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_3);
2923                            }
2924                            else {
2925                                    bindFileEntryTypeKey = true;
2926    
2927                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_2);
2928                            }
2929    
2930                            String sql = query.toString();
2931    
2932                            Session session = null;
2933    
2934                            try {
2935                                    session = openSession();
2936    
2937                                    Query q = session.createQuery(sql);
2938    
2939                                    QueryPos qPos = QueryPos.getInstance(q);
2940    
2941                                    qPos.add(groupId);
2942    
2943                                    if (bindFileEntryTypeKey) {
2944                                            qPos.add(fileEntryTypeKey);
2945                                    }
2946    
2947                                    List<DLFileEntryType> list = q.list();
2948    
2949                                    if (list.isEmpty()) {
2950                                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F, finderArgs,
2951                                                    list);
2952                                    }
2953                                    else {
2954                                            DLFileEntryType dlFileEntryType = list.get(0);
2955    
2956                                            result = dlFileEntryType;
2957    
2958                                            cacheResult(dlFileEntryType);
2959    
2960                                            if ((dlFileEntryType.getGroupId() != groupId) ||
2961                                                            (dlFileEntryType.getFileEntryTypeKey() == null) ||
2962                                                            !dlFileEntryType.getFileEntryTypeKey()
2963                                                                                                    .equals(fileEntryTypeKey)) {
2964                                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F,
2965                                                            finderArgs, dlFileEntryType);
2966                                            }
2967                                    }
2968                            }
2969                            catch (Exception e) {
2970                                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F, finderArgs);
2971    
2972                                    throw processException(e);
2973                            }
2974                            finally {
2975                                    closeSession(session);
2976                            }
2977                    }
2978    
2979                    if (result instanceof List<?>) {
2980                            return null;
2981                    }
2982                    else {
2983                            return (DLFileEntryType)result;
2984                    }
2985            }
2986    
2987            /**
2988             * Removes the document library file entry type where groupId = &#63; and fileEntryTypeKey = &#63; from the database.
2989             *
2990             * @param groupId the group ID
2991             * @param fileEntryTypeKey the file entry type key
2992             * @return the document library file entry type that was removed
2993             */
2994            @Override
2995            public DLFileEntryType removeByG_F(long groupId, String fileEntryTypeKey)
2996                    throws NoSuchFileEntryTypeException {
2997                    DLFileEntryType dlFileEntryType = findByG_F(groupId, fileEntryTypeKey);
2998    
2999                    return remove(dlFileEntryType);
3000            }
3001    
3002            /**
3003             * Returns the number of document library file entry types where groupId = &#63; and fileEntryTypeKey = &#63;.
3004             *
3005             * @param groupId the group ID
3006             * @param fileEntryTypeKey the file entry type key
3007             * @return the number of matching document library file entry types
3008             */
3009            @Override
3010            public int countByG_F(long groupId, String fileEntryTypeKey) {
3011                    FinderPath finderPath = FINDER_PATH_COUNT_BY_G_F;
3012    
3013                    Object[] finderArgs = new Object[] { groupId, fileEntryTypeKey };
3014    
3015                    Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
3016    
3017                    if (count == null) {
3018                            StringBundler query = new StringBundler(3);
3019    
3020                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
3021    
3022                            query.append(_FINDER_COLUMN_G_F_GROUPID_2);
3023    
3024                            boolean bindFileEntryTypeKey = false;
3025    
3026                            if (fileEntryTypeKey == null) {
3027                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_1);
3028                            }
3029                            else if (fileEntryTypeKey.equals(StringPool.BLANK)) {
3030                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_3);
3031                            }
3032                            else {
3033                                    bindFileEntryTypeKey = true;
3034    
3035                                    query.append(_FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_2);
3036                            }
3037    
3038                            String sql = query.toString();
3039    
3040                            Session session = null;
3041    
3042                            try {
3043                                    session = openSession();
3044    
3045                                    Query q = session.createQuery(sql);
3046    
3047                                    QueryPos qPos = QueryPos.getInstance(q);
3048    
3049                                    qPos.add(groupId);
3050    
3051                                    if (bindFileEntryTypeKey) {
3052                                            qPos.add(fileEntryTypeKey);
3053                                    }
3054    
3055                                    count = (Long)q.uniqueResult();
3056    
3057                                    finderCache.putResult(finderPath, finderArgs, count);
3058                            }
3059                            catch (Exception e) {
3060                                    finderCache.removeResult(finderPath, finderArgs);
3061    
3062                                    throw processException(e);
3063                            }
3064                            finally {
3065                                    closeSession(session);
3066                            }
3067                    }
3068    
3069                    return count.intValue();
3070            }
3071    
3072            private static final String _FINDER_COLUMN_G_F_GROUPID_2 = "dlFileEntryType.groupId = ? AND ";
3073            private static final String _FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_1 = "dlFileEntryType.fileEntryTypeKey IS NULL";
3074            private static final String _FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_2 = "dlFileEntryType.fileEntryTypeKey = ?";
3075            private static final String _FINDER_COLUMN_G_F_FILEENTRYTYPEKEY_3 = "(dlFileEntryType.fileEntryTypeKey IS NULL OR dlFileEntryType.fileEntryTypeKey = '')";
3076    
3077            public DLFileEntryTypePersistenceImpl() {
3078                    setModelClass(DLFileEntryType.class);
3079            }
3080    
3081            /**
3082             * Caches the document library file entry type in the entity cache if it is enabled.
3083             *
3084             * @param dlFileEntryType the document library file entry type
3085             */
3086            @Override
3087            public void cacheResult(DLFileEntryType dlFileEntryType) {
3088                    entityCache.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3089                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
3090                            dlFileEntryType);
3091    
3092                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
3093                            new Object[] { dlFileEntryType.getUuid(), dlFileEntryType.getGroupId() },
3094                            dlFileEntryType);
3095    
3096                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F,
3097                            new Object[] {
3098                                    dlFileEntryType.getGroupId(),
3099                                    dlFileEntryType.getFileEntryTypeKey()
3100                            }, dlFileEntryType);
3101    
3102                    dlFileEntryType.resetOriginalValues();
3103            }
3104    
3105            /**
3106             * Caches the document library file entry types in the entity cache if it is enabled.
3107             *
3108             * @param dlFileEntryTypes the document library file entry types
3109             */
3110            @Override
3111            public void cacheResult(List<DLFileEntryType> dlFileEntryTypes) {
3112                    for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
3113                            if (entityCache.getResult(
3114                                                    DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3115                                                    DLFileEntryTypeImpl.class,
3116                                                    dlFileEntryType.getPrimaryKey()) == null) {
3117                                    cacheResult(dlFileEntryType);
3118                            }
3119                            else {
3120                                    dlFileEntryType.resetOriginalValues();
3121                            }
3122                    }
3123            }
3124    
3125            /**
3126             * Clears the cache for all document library file entry types.
3127             *
3128             * <p>
3129             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3130             * </p>
3131             */
3132            @Override
3133            public void clearCache() {
3134                    entityCache.clearCache(DLFileEntryTypeImpl.class);
3135    
3136                    finderCache.clearCache(FINDER_CLASS_NAME_ENTITY);
3137                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3138                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3139            }
3140    
3141            /**
3142             * Clears the cache for the document library file entry type.
3143             *
3144             * <p>
3145             * The {@link EntityCache} and {@link FinderCache} are both cleared by this method.
3146             * </p>
3147             */
3148            @Override
3149            public void clearCache(DLFileEntryType dlFileEntryType) {
3150                    entityCache.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3151                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
3152    
3153                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3154                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3155    
3156                    clearUniqueFindersCache((DLFileEntryTypeModelImpl)dlFileEntryType);
3157            }
3158    
3159            @Override
3160            public void clearCache(List<DLFileEntryType> dlFileEntryTypes) {
3161                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3162                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3163    
3164                    for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
3165                            entityCache.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3166                                    DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
3167    
3168                            clearUniqueFindersCache((DLFileEntryTypeModelImpl)dlFileEntryType);
3169                    }
3170            }
3171    
3172            protected void cacheUniqueFindersCache(
3173                    DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl, boolean isNew) {
3174                    if (isNew) {
3175                            Object[] args = new Object[] {
3176                                            dlFileEntryTypeModelImpl.getUuid(),
3177                                            dlFileEntryTypeModelImpl.getGroupId()
3178                                    };
3179    
3180                            finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3181                                    Long.valueOf(1));
3182                            finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3183                                    dlFileEntryTypeModelImpl);
3184    
3185                            args = new Object[] {
3186                                            dlFileEntryTypeModelImpl.getGroupId(),
3187                                            dlFileEntryTypeModelImpl.getFileEntryTypeKey()
3188                                    };
3189    
3190                            finderCache.putResult(FINDER_PATH_COUNT_BY_G_F, args,
3191                                    Long.valueOf(1));
3192                            finderCache.putResult(FINDER_PATH_FETCH_BY_G_F, args,
3193                                    dlFileEntryTypeModelImpl);
3194                    }
3195                    else {
3196                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3197                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3198                                    Object[] args = new Object[] {
3199                                                    dlFileEntryTypeModelImpl.getUuid(),
3200                                                    dlFileEntryTypeModelImpl.getGroupId()
3201                                            };
3202    
3203                                    finderCache.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
3204                                            Long.valueOf(1));
3205                                    finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
3206                                            dlFileEntryTypeModelImpl);
3207                            }
3208    
3209                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3210                                            FINDER_PATH_FETCH_BY_G_F.getColumnBitmask()) != 0) {
3211                                    Object[] args = new Object[] {
3212                                                    dlFileEntryTypeModelImpl.getGroupId(),
3213                                                    dlFileEntryTypeModelImpl.getFileEntryTypeKey()
3214                                            };
3215    
3216                                    finderCache.putResult(FINDER_PATH_COUNT_BY_G_F, args,
3217                                            Long.valueOf(1));
3218                                    finderCache.putResult(FINDER_PATH_FETCH_BY_G_F, args,
3219                                            dlFileEntryTypeModelImpl);
3220                            }
3221                    }
3222            }
3223    
3224            protected void clearUniqueFindersCache(
3225                    DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl) {
3226                    Object[] args = new Object[] {
3227                                    dlFileEntryTypeModelImpl.getUuid(),
3228                                    dlFileEntryTypeModelImpl.getGroupId()
3229                            };
3230    
3231                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3232                    finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3233    
3234                    if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3235                                    FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
3236                            args = new Object[] {
3237                                            dlFileEntryTypeModelImpl.getOriginalUuid(),
3238                                            dlFileEntryTypeModelImpl.getOriginalGroupId()
3239                                    };
3240    
3241                            finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
3242                            finderCache.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
3243                    }
3244    
3245                    args = new Object[] {
3246                                    dlFileEntryTypeModelImpl.getGroupId(),
3247                                    dlFileEntryTypeModelImpl.getFileEntryTypeKey()
3248                            };
3249    
3250                    finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
3251                    finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F, args);
3252    
3253                    if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3254                                    FINDER_PATH_FETCH_BY_G_F.getColumnBitmask()) != 0) {
3255                            args = new Object[] {
3256                                            dlFileEntryTypeModelImpl.getOriginalGroupId(),
3257                                            dlFileEntryTypeModelImpl.getOriginalFileEntryTypeKey()
3258                                    };
3259    
3260                            finderCache.removeResult(FINDER_PATH_COUNT_BY_G_F, args);
3261                            finderCache.removeResult(FINDER_PATH_FETCH_BY_G_F, args);
3262                    }
3263            }
3264    
3265            /**
3266             * Creates a new document library file entry type with the primary key. Does not add the document library file entry type to the database.
3267             *
3268             * @param fileEntryTypeId the primary key for the new document library file entry type
3269             * @return the new document library file entry type
3270             */
3271            @Override
3272            public DLFileEntryType create(long fileEntryTypeId) {
3273                    DLFileEntryType dlFileEntryType = new DLFileEntryTypeImpl();
3274    
3275                    dlFileEntryType.setNew(true);
3276                    dlFileEntryType.setPrimaryKey(fileEntryTypeId);
3277    
3278                    String uuid = PortalUUIDUtil.generate();
3279    
3280                    dlFileEntryType.setUuid(uuid);
3281    
3282                    return dlFileEntryType;
3283            }
3284    
3285            /**
3286             * Removes the document library file entry type with the primary key from the database. Also notifies the appropriate model listeners.
3287             *
3288             * @param fileEntryTypeId the primary key of the document library file entry type
3289             * @return the document library file entry type that was removed
3290             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
3291             */
3292            @Override
3293            public DLFileEntryType remove(long fileEntryTypeId)
3294                    throws NoSuchFileEntryTypeException {
3295                    return remove((Serializable)fileEntryTypeId);
3296            }
3297    
3298            /**
3299             * Removes the document library file entry type with the primary key from the database. Also notifies the appropriate model listeners.
3300             *
3301             * @param primaryKey the primary key of the document library file entry type
3302             * @return the document library file entry type that was removed
3303             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
3304             */
3305            @Override
3306            public DLFileEntryType remove(Serializable primaryKey)
3307                    throws NoSuchFileEntryTypeException {
3308                    Session session = null;
3309    
3310                    try {
3311                            session = openSession();
3312    
3313                            DLFileEntryType dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
3314                                            primaryKey);
3315    
3316                            if (dlFileEntryType == null) {
3317                                    if (_log.isWarnEnabled()) {
3318                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3319                                    }
3320    
3321                                    throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3322                                            primaryKey);
3323                            }
3324    
3325                            return remove(dlFileEntryType);
3326                    }
3327                    catch (NoSuchFileEntryTypeException nsee) {
3328                            throw nsee;
3329                    }
3330                    catch (Exception e) {
3331                            throw processException(e);
3332                    }
3333                    finally {
3334                            closeSession(session);
3335                    }
3336            }
3337    
3338            @Override
3339            protected DLFileEntryType removeImpl(DLFileEntryType dlFileEntryType) {
3340                    dlFileEntryType = toUnwrappedModel(dlFileEntryType);
3341    
3342                    dlFileEntryTypeToDLFolderTableMapper.deleteLeftPrimaryKeyTableMappings(0,
3343                            dlFileEntryType.getPrimaryKey());
3344    
3345                    Session session = null;
3346    
3347                    try {
3348                            session = openSession();
3349    
3350                            if (!session.contains(dlFileEntryType)) {
3351                                    dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
3352                                                    dlFileEntryType.getPrimaryKeyObj());
3353                            }
3354    
3355                            if (dlFileEntryType != null) {
3356                                    session.delete(dlFileEntryType);
3357                            }
3358                    }
3359                    catch (Exception e) {
3360                            throw processException(e);
3361                    }
3362                    finally {
3363                            closeSession(session);
3364                    }
3365    
3366                    if (dlFileEntryType != null) {
3367                            clearCache(dlFileEntryType);
3368                    }
3369    
3370                    return dlFileEntryType;
3371            }
3372    
3373            @Override
3374            public DLFileEntryType updateImpl(DLFileEntryType dlFileEntryType) {
3375                    dlFileEntryType = toUnwrappedModel(dlFileEntryType);
3376    
3377                    boolean isNew = dlFileEntryType.isNew();
3378    
3379                    DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = (DLFileEntryTypeModelImpl)dlFileEntryType;
3380    
3381                    if (Validator.isNull(dlFileEntryType.getUuid())) {
3382                            String uuid = PortalUUIDUtil.generate();
3383    
3384                            dlFileEntryType.setUuid(uuid);
3385                    }
3386    
3387                    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
3388    
3389                    Date now = new Date();
3390    
3391                    if (isNew && (dlFileEntryType.getCreateDate() == null)) {
3392                            if (serviceContext == null) {
3393                                    dlFileEntryType.setCreateDate(now);
3394                            }
3395                            else {
3396                                    dlFileEntryType.setCreateDate(serviceContext.getCreateDate(now));
3397                            }
3398                    }
3399    
3400                    if (!dlFileEntryTypeModelImpl.hasSetModifiedDate()) {
3401                            if (serviceContext == null) {
3402                                    dlFileEntryType.setModifiedDate(now);
3403                            }
3404                            else {
3405                                    dlFileEntryType.setModifiedDate(serviceContext.getModifiedDate(
3406                                                    now));
3407                            }
3408                    }
3409    
3410                    Session session = null;
3411    
3412                    try {
3413                            session = openSession();
3414    
3415                            if (dlFileEntryType.isNew()) {
3416                                    session.save(dlFileEntryType);
3417    
3418                                    dlFileEntryType.setNew(false);
3419                            }
3420                            else {
3421                                    dlFileEntryType = (DLFileEntryType)session.merge(dlFileEntryType);
3422                            }
3423                    }
3424                    catch (Exception e) {
3425                            throw processException(e);
3426                    }
3427                    finally {
3428                            closeSession(session);
3429                    }
3430    
3431                    finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3432    
3433                    if (isNew || !DLFileEntryTypeModelImpl.COLUMN_BITMASK_ENABLED) {
3434                            finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3435                    }
3436    
3437                    else {
3438                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3439                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
3440                                    Object[] args = new Object[] {
3441                                                    dlFileEntryTypeModelImpl.getOriginalUuid()
3442                                            };
3443    
3444                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3445                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3446                                            args);
3447    
3448                                    args = new Object[] { dlFileEntryTypeModelImpl.getUuid() };
3449    
3450                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
3451                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
3452                                            args);
3453                            }
3454    
3455                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3456                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C.getColumnBitmask()) != 0) {
3457                                    Object[] args = new Object[] {
3458                                                    dlFileEntryTypeModelImpl.getOriginalUuid(),
3459                                                    dlFileEntryTypeModelImpl.getOriginalCompanyId()
3460                                            };
3461    
3462                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3463                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3464                                            args);
3465    
3466                                    args = new Object[] {
3467                                                    dlFileEntryTypeModelImpl.getUuid(),
3468                                                    dlFileEntryTypeModelImpl.getCompanyId()
3469                                            };
3470    
3471                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_UUID_C, args);
3472                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID_C,
3473                                            args);
3474                            }
3475    
3476                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
3477                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
3478                                    Object[] args = new Object[] {
3479                                                    dlFileEntryTypeModelImpl.getOriginalGroupId()
3480                                            };
3481    
3482                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3483                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3484                                            args);
3485    
3486                                    args = new Object[] { dlFileEntryTypeModelImpl.getGroupId() };
3487    
3488                                    finderCache.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
3489                                    finderCache.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
3490                                            args);
3491                            }
3492                    }
3493    
3494                    entityCache.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3495                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
3496                            dlFileEntryType, false);
3497    
3498                    clearUniqueFindersCache(dlFileEntryTypeModelImpl);
3499                    cacheUniqueFindersCache(dlFileEntryTypeModelImpl, isNew);
3500    
3501                    dlFileEntryType.resetOriginalValues();
3502    
3503                    return dlFileEntryType;
3504            }
3505    
3506            protected DLFileEntryType toUnwrappedModel(DLFileEntryType dlFileEntryType) {
3507                    if (dlFileEntryType instanceof DLFileEntryTypeImpl) {
3508                            return dlFileEntryType;
3509                    }
3510    
3511                    DLFileEntryTypeImpl dlFileEntryTypeImpl = new DLFileEntryTypeImpl();
3512    
3513                    dlFileEntryTypeImpl.setNew(dlFileEntryType.isNew());
3514                    dlFileEntryTypeImpl.setPrimaryKey(dlFileEntryType.getPrimaryKey());
3515    
3516                    dlFileEntryTypeImpl.setUuid(dlFileEntryType.getUuid());
3517                    dlFileEntryTypeImpl.setFileEntryTypeId(dlFileEntryType.getFileEntryTypeId());
3518                    dlFileEntryTypeImpl.setGroupId(dlFileEntryType.getGroupId());
3519                    dlFileEntryTypeImpl.setCompanyId(dlFileEntryType.getCompanyId());
3520                    dlFileEntryTypeImpl.setUserId(dlFileEntryType.getUserId());
3521                    dlFileEntryTypeImpl.setUserName(dlFileEntryType.getUserName());
3522                    dlFileEntryTypeImpl.setCreateDate(dlFileEntryType.getCreateDate());
3523                    dlFileEntryTypeImpl.setModifiedDate(dlFileEntryType.getModifiedDate());
3524                    dlFileEntryTypeImpl.setFileEntryTypeKey(dlFileEntryType.getFileEntryTypeKey());
3525                    dlFileEntryTypeImpl.setName(dlFileEntryType.getName());
3526                    dlFileEntryTypeImpl.setDescription(dlFileEntryType.getDescription());
3527                    dlFileEntryTypeImpl.setLastPublishDate(dlFileEntryType.getLastPublishDate());
3528    
3529                    return dlFileEntryTypeImpl;
3530            }
3531    
3532            /**
3533             * Returns the document library file entry type with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3534             *
3535             * @param primaryKey the primary key of the document library file entry type
3536             * @return the document library file entry type
3537             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
3538             */
3539            @Override
3540            public DLFileEntryType findByPrimaryKey(Serializable primaryKey)
3541                    throws NoSuchFileEntryTypeException {
3542                    DLFileEntryType dlFileEntryType = fetchByPrimaryKey(primaryKey);
3543    
3544                    if (dlFileEntryType == null) {
3545                            if (_log.isWarnEnabled()) {
3546                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3547                            }
3548    
3549                            throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3550                                    primaryKey);
3551                    }
3552    
3553                    return dlFileEntryType;
3554            }
3555    
3556            /**
3557             * Returns the document library file entry type with the primary key or throws a {@link NoSuchFileEntryTypeException} if it could not be found.
3558             *
3559             * @param fileEntryTypeId the primary key of the document library file entry type
3560             * @return the document library file entry type
3561             * @throws NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
3562             */
3563            @Override
3564            public DLFileEntryType findByPrimaryKey(long fileEntryTypeId)
3565                    throws NoSuchFileEntryTypeException {
3566                    return findByPrimaryKey((Serializable)fileEntryTypeId);
3567            }
3568    
3569            /**
3570             * Returns the document library file entry type with the primary key or returns <code>null</code> if it could not be found.
3571             *
3572             * @param primaryKey the primary key of the document library file entry type
3573             * @return the document library file entry type, or <code>null</code> if a document library file entry type with the primary key could not be found
3574             */
3575            @Override
3576            public DLFileEntryType fetchByPrimaryKey(Serializable primaryKey) {
3577                    DLFileEntryType dlFileEntryType = (DLFileEntryType)entityCache.getResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3578                                    DLFileEntryTypeImpl.class, primaryKey);
3579    
3580                    if (dlFileEntryType == _nullDLFileEntryType) {
3581                            return null;
3582                    }
3583    
3584                    if (dlFileEntryType == null) {
3585                            Session session = null;
3586    
3587                            try {
3588                                    session = openSession();
3589    
3590                                    dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
3591                                                    primaryKey);
3592    
3593                                    if (dlFileEntryType != null) {
3594                                            cacheResult(dlFileEntryType);
3595                                    }
3596                                    else {
3597                                            entityCache.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3598                                                    DLFileEntryTypeImpl.class, primaryKey,
3599                                                    _nullDLFileEntryType);
3600                                    }
3601                            }
3602                            catch (Exception e) {
3603                                    entityCache.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3604                                            DLFileEntryTypeImpl.class, primaryKey);
3605    
3606                                    throw processException(e);
3607                            }
3608                            finally {
3609                                    closeSession(session);
3610                            }
3611                    }
3612    
3613                    return dlFileEntryType;
3614            }
3615    
3616            /**
3617             * Returns the document library file entry type with the primary key or returns <code>null</code> if it could not be found.
3618             *
3619             * @param fileEntryTypeId the primary key of the document library file entry type
3620             * @return the document library file entry type, or <code>null</code> if a document library file entry type with the primary key could not be found
3621             */
3622            @Override
3623            public DLFileEntryType fetchByPrimaryKey(long fileEntryTypeId) {
3624                    return fetchByPrimaryKey((Serializable)fileEntryTypeId);
3625            }
3626    
3627            @Override
3628            public Map<Serializable, DLFileEntryType> fetchByPrimaryKeys(
3629                    Set<Serializable> primaryKeys) {
3630                    if (primaryKeys.isEmpty()) {
3631                            return Collections.emptyMap();
3632                    }
3633    
3634                    Map<Serializable, DLFileEntryType> map = new HashMap<Serializable, DLFileEntryType>();
3635    
3636                    if (primaryKeys.size() == 1) {
3637                            Iterator<Serializable> iterator = primaryKeys.iterator();
3638    
3639                            Serializable primaryKey = iterator.next();
3640    
3641                            DLFileEntryType dlFileEntryType = fetchByPrimaryKey(primaryKey);
3642    
3643                            if (dlFileEntryType != null) {
3644                                    map.put(primaryKey, dlFileEntryType);
3645                            }
3646    
3647                            return map;
3648                    }
3649    
3650                    Set<Serializable> uncachedPrimaryKeys = null;
3651    
3652                    for (Serializable primaryKey : primaryKeys) {
3653                            DLFileEntryType dlFileEntryType = (DLFileEntryType)entityCache.getResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3654                                            DLFileEntryTypeImpl.class, primaryKey);
3655    
3656                            if (dlFileEntryType == null) {
3657                                    if (uncachedPrimaryKeys == null) {
3658                                            uncachedPrimaryKeys = new HashSet<Serializable>();
3659                                    }
3660    
3661                                    uncachedPrimaryKeys.add(primaryKey);
3662                            }
3663                            else {
3664                                    map.put(primaryKey, dlFileEntryType);
3665                            }
3666                    }
3667    
3668                    if (uncachedPrimaryKeys == null) {
3669                            return map;
3670                    }
3671    
3672                    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) +
3673                                    1);
3674    
3675                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE_PKS_IN);
3676    
3677                    for (Serializable primaryKey : uncachedPrimaryKeys) {
3678                            query.append(String.valueOf(primaryKey));
3679    
3680                            query.append(StringPool.COMMA);
3681                    }
3682    
3683                    query.setIndex(query.index() - 1);
3684    
3685                    query.append(StringPool.CLOSE_PARENTHESIS);
3686    
3687                    String sql = query.toString();
3688    
3689                    Session session = null;
3690    
3691                    try {
3692                            session = openSession();
3693    
3694                            Query q = session.createQuery(sql);
3695    
3696                            for (DLFileEntryType dlFileEntryType : (List<DLFileEntryType>)q.list()) {
3697                                    map.put(dlFileEntryType.getPrimaryKeyObj(), dlFileEntryType);
3698    
3699                                    cacheResult(dlFileEntryType);
3700    
3701                                    uncachedPrimaryKeys.remove(dlFileEntryType.getPrimaryKeyObj());
3702                            }
3703    
3704                            for (Serializable primaryKey : uncachedPrimaryKeys) {
3705                                    entityCache.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
3706                                            DLFileEntryTypeImpl.class, primaryKey, _nullDLFileEntryType);
3707                            }
3708                    }
3709                    catch (Exception e) {
3710                            throw processException(e);
3711                    }
3712                    finally {
3713                            closeSession(session);
3714                    }
3715    
3716                    return map;
3717            }
3718    
3719            /**
3720             * Returns all the document library file entry types.
3721             *
3722             * @return the document library file entry types
3723             */
3724            @Override
3725            public List<DLFileEntryType> findAll() {
3726                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3727            }
3728    
3729            /**
3730             * Returns a range of all the document library file entry types.
3731             *
3732             * <p>
3733             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
3734             * </p>
3735             *
3736             * @param start the lower bound of the range of document library file entry types
3737             * @param end the upper bound of the range of document library file entry types (not inclusive)
3738             * @return the range of document library file entry types
3739             */
3740            @Override
3741            public List<DLFileEntryType> findAll(int start, int end) {
3742                    return findAll(start, end, null);
3743            }
3744    
3745            /**
3746             * Returns an ordered range of all the document library file entry types.
3747             *
3748             * <p>
3749             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
3750             * </p>
3751             *
3752             * @param start the lower bound of the range of document library file entry types
3753             * @param end the upper bound of the range of document library file entry types (not inclusive)
3754             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3755             * @return the ordered range of document library file entry types
3756             */
3757            @Override
3758            public List<DLFileEntryType> findAll(int start, int end,
3759                    OrderByComparator<DLFileEntryType> orderByComparator) {
3760                    return findAll(start, end, orderByComparator, true);
3761            }
3762    
3763            /**
3764             * Returns an ordered range of all the document library file entry types.
3765             *
3766             * <p>
3767             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
3768             * </p>
3769             *
3770             * @param start the lower bound of the range of document library file entry types
3771             * @param end the upper bound of the range of document library file entry types (not inclusive)
3772             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3773             * @param retrieveFromCache whether to retrieve from the finder cache
3774             * @return the ordered range of document library file entry types
3775             */
3776            @Override
3777            public List<DLFileEntryType> findAll(int start, int end,
3778                    OrderByComparator<DLFileEntryType> orderByComparator,
3779                    boolean retrieveFromCache) {
3780                    boolean pagination = true;
3781                    FinderPath finderPath = null;
3782                    Object[] finderArgs = null;
3783    
3784                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3785                                    (orderByComparator == null)) {
3786                            pagination = false;
3787                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3788                            finderArgs = FINDER_ARGS_EMPTY;
3789                    }
3790                    else {
3791                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3792                            finderArgs = new Object[] { start, end, orderByComparator };
3793                    }
3794    
3795                    List<DLFileEntryType> list = null;
3796    
3797                    if (retrieveFromCache) {
3798                            list = (List<DLFileEntryType>)finderCache.getResult(finderPath,
3799                                            finderArgs, this);
3800                    }
3801    
3802                    if (list == null) {
3803                            StringBundler query = null;
3804                            String sql = null;
3805    
3806                            if (orderByComparator != null) {
3807                                    query = new StringBundler(2 +
3808                                                    (orderByComparator.getOrderByFields().length * 3));
3809    
3810                                    query.append(_SQL_SELECT_DLFILEENTRYTYPE);
3811    
3812                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3813                                            orderByComparator);
3814    
3815                                    sql = query.toString();
3816                            }
3817                            else {
3818                                    sql = _SQL_SELECT_DLFILEENTRYTYPE;
3819    
3820                                    if (pagination) {
3821                                            sql = sql.concat(DLFileEntryTypeModelImpl.ORDER_BY_JPQL);
3822                                    }
3823                            }
3824    
3825                            Session session = null;
3826    
3827                            try {
3828                                    session = openSession();
3829    
3830                                    Query q = session.createQuery(sql);
3831    
3832                                    if (!pagination) {
3833                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
3834                                                            getDialect(), start, end, false);
3835    
3836                                            Collections.sort(list);
3837    
3838                                            list = Collections.unmodifiableList(list);
3839                                    }
3840                                    else {
3841                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
3842                                                            getDialect(), start, end);
3843                                    }
3844    
3845                                    cacheResult(list);
3846    
3847                                    finderCache.putResult(finderPath, finderArgs, list);
3848                            }
3849                            catch (Exception e) {
3850                                    finderCache.removeResult(finderPath, finderArgs);
3851    
3852                                    throw processException(e);
3853                            }
3854                            finally {
3855                                    closeSession(session);
3856                            }
3857                    }
3858    
3859                    return list;
3860            }
3861    
3862            /**
3863             * Removes all the document library file entry types from the database.
3864             *
3865             */
3866            @Override
3867            public void removeAll() {
3868                    for (DLFileEntryType dlFileEntryType : findAll()) {
3869                            remove(dlFileEntryType);
3870                    }
3871            }
3872    
3873            /**
3874             * Returns the number of document library file entry types.
3875             *
3876             * @return the number of document library file entry types
3877             */
3878            @Override
3879            public int countAll() {
3880                    Long count = (Long)finderCache.getResult(FINDER_PATH_COUNT_ALL,
3881                                    FINDER_ARGS_EMPTY, this);
3882    
3883                    if (count == null) {
3884                            Session session = null;
3885    
3886                            try {
3887                                    session = openSession();
3888    
3889                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYTYPE);
3890    
3891                                    count = (Long)q.uniqueResult();
3892    
3893                                    finderCache.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY,
3894                                            count);
3895                            }
3896                            catch (Exception e) {
3897                                    finderCache.removeResult(FINDER_PATH_COUNT_ALL,
3898                                            FINDER_ARGS_EMPTY);
3899    
3900                                    throw processException(e);
3901                            }
3902                            finally {
3903                                    closeSession(session);
3904                            }
3905                    }
3906    
3907                    return count.intValue();
3908            }
3909    
3910            /**
3911             * Returns the primaryKeys of document library folders associated with the document library file entry type.
3912             *
3913             * @param pk the primary key of the document library file entry type
3914             * @return long[] of the primaryKeys of document library folders associated with the document library file entry type
3915             */
3916            @Override
3917            public long[] getDLFolderPrimaryKeys(long pk) {
3918                    long[] pks = dlFileEntryTypeToDLFolderTableMapper.getRightPrimaryKeys(0,
3919                                    pk);
3920    
3921                    return pks.clone();
3922            }
3923    
3924            /**
3925             * Returns all the document library folders associated with the document library file entry type.
3926             *
3927             * @param pk the primary key of the document library file entry type
3928             * @return the document library folders associated with the document library file entry type
3929             */
3930            @Override
3931            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3932                    long pk) {
3933                    return getDLFolders(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3934            }
3935    
3936            /**
3937             * Returns a range of all the document library folders associated with the document library file entry type.
3938             *
3939             * <p>
3940             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
3941             * </p>
3942             *
3943             * @param pk the primary key of the document library file entry type
3944             * @param start the lower bound of the range of document library file entry types
3945             * @param end the upper bound of the range of document library file entry types (not inclusive)
3946             * @return the range of document library folders associated with the document library file entry type
3947             */
3948            @Override
3949            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3950                    long pk, int start, int end) {
3951                    return getDLFolders(pk, start, end, null);
3952            }
3953    
3954            /**
3955             * Returns an ordered range of all the document library folders associated with the document library file entry type.
3956             *
3957             * <p>
3958             * 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 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 QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link DLFileEntryTypeModelImpl}. 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.
3959             * </p>
3960             *
3961             * @param pk the primary key of the document library file entry type
3962             * @param start the lower bound of the range of document library file entry types
3963             * @param end the upper bound of the range of document library file entry types (not inclusive)
3964             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3965             * @return the ordered range of document library folders associated with the document library file entry type
3966             */
3967            @Override
3968            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3969                    long pk, int start, int end,
3970                    OrderByComparator<com.liferay.portlet.documentlibrary.model.DLFolder> orderByComparator) {
3971                    return dlFileEntryTypeToDLFolderTableMapper.getRightBaseModels(0, pk,
3972                            start, end, orderByComparator);
3973            }
3974    
3975            /**
3976             * Returns the number of document library folders associated with the document library file entry type.
3977             *
3978             * @param pk the primary key of the document library file entry type
3979             * @return the number of document library folders associated with the document library file entry type
3980             */
3981            @Override
3982            public int getDLFoldersSize(long pk) {
3983                    long[] pks = dlFileEntryTypeToDLFolderTableMapper.getRightPrimaryKeys(0,
3984                                    pk);
3985    
3986                    return pks.length;
3987            }
3988    
3989            /**
3990             * Returns <code>true</code> if the document library folder is associated with the document library file entry type.
3991             *
3992             * @param pk the primary key of the document library file entry type
3993             * @param dlFolderPK the primary key of the document library folder
3994             * @return <code>true</code> if the document library folder is associated with the document library file entry type; <code>false</code> otherwise
3995             */
3996            @Override
3997            public boolean containsDLFolder(long pk, long dlFolderPK) {
3998                    return dlFileEntryTypeToDLFolderTableMapper.containsTableMapping(0, pk,
3999                            dlFolderPK);
4000            }
4001    
4002            /**
4003             * Returns <code>true</code> if the document library file entry type has any document library folders associated with it.
4004             *
4005             * @param pk the primary key of the document library file entry type to check for associations with document library folders
4006             * @return <code>true</code> if the document library file entry type has any document library folders associated with it; <code>false</code> otherwise
4007             */
4008            @Override
4009            public boolean containsDLFolders(long pk) {
4010                    if (getDLFoldersSize(pk) > 0) {
4011                            return true;
4012                    }
4013                    else {
4014                            return false;
4015                    }
4016            }
4017    
4018            /**
4019             * Adds an association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4020             *
4021             * @param pk the primary key of the document library file entry type
4022             * @param dlFolderPK the primary key of the document library folder
4023             */
4024            @Override
4025            public void addDLFolder(long pk, long dlFolderPK) {
4026                    dlFileEntryTypeToDLFolderTableMapper.addTableMapping(0, pk, dlFolderPK);
4027            }
4028    
4029            /**
4030             * Adds an association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4031             *
4032             * @param pk the primary key of the document library file entry type
4033             * @param dlFolder the document library folder
4034             */
4035            @Override
4036            public void addDLFolder(long pk,
4037                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder) {
4038                    dlFileEntryTypeToDLFolderTableMapper.addTableMapping(0, pk,
4039                            dlFolder.getPrimaryKey());
4040            }
4041    
4042            /**
4043             * Adds an association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4044             *
4045             * @param pk the primary key of the document library file entry type
4046             * @param dlFolderPKs the primary keys of the document library folders
4047             */
4048            @Override
4049            public void addDLFolders(long pk, long[] dlFolderPKs) {
4050                    for (long dlFolderPK : dlFolderPKs) {
4051                            dlFileEntryTypeToDLFolderTableMapper.addTableMapping(0, pk,
4052                                    dlFolderPK);
4053                    }
4054            }
4055    
4056            /**
4057             * Adds an association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4058             *
4059             * @param pk the primary key of the document library file entry type
4060             * @param dlFolders the document library folders
4061             */
4062            @Override
4063            public void addDLFolders(long pk,
4064                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders) {
4065                    for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4066                            dlFileEntryTypeToDLFolderTableMapper.addTableMapping(0, pk,
4067                                    dlFolder.getPrimaryKey());
4068                    }
4069            }
4070    
4071            /**
4072             * Clears all associations between the document library file entry type and its document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4073             *
4074             * @param pk the primary key of the document library file entry type to clear the associated document library folders from
4075             */
4076            @Override
4077            public void clearDLFolders(long pk) {
4078                    dlFileEntryTypeToDLFolderTableMapper.deleteLeftPrimaryKeyTableMappings(0,
4079                            pk);
4080            }
4081    
4082            /**
4083             * Removes the association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4084             *
4085             * @param pk the primary key of the document library file entry type
4086             * @param dlFolderPK the primary key of the document library folder
4087             */
4088            @Override
4089            public void removeDLFolder(long pk, long dlFolderPK) {
4090                    dlFileEntryTypeToDLFolderTableMapper.deleteTableMapping(0, pk,
4091                            dlFolderPK);
4092            }
4093    
4094            /**
4095             * Removes the association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4096             *
4097             * @param pk the primary key of the document library file entry type
4098             * @param dlFolder the document library folder
4099             */
4100            @Override
4101            public void removeDLFolder(long pk,
4102                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder) {
4103                    dlFileEntryTypeToDLFolderTableMapper.deleteTableMapping(0, pk,
4104                            dlFolder.getPrimaryKey());
4105            }
4106    
4107            /**
4108             * Removes the association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4109             *
4110             * @param pk the primary key of the document library file entry type
4111             * @param dlFolderPKs the primary keys of the document library folders
4112             */
4113            @Override
4114            public void removeDLFolders(long pk, long[] dlFolderPKs) {
4115                    for (long dlFolderPK : dlFolderPKs) {
4116                            dlFileEntryTypeToDLFolderTableMapper.deleteTableMapping(0, pk,
4117                                    dlFolderPK);
4118                    }
4119            }
4120    
4121            /**
4122             * Removes the association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4123             *
4124             * @param pk the primary key of the document library file entry type
4125             * @param dlFolders the document library folders
4126             */
4127            @Override
4128            public void removeDLFolders(long pk,
4129                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders) {
4130                    for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4131                            dlFileEntryTypeToDLFolderTableMapper.deleteTableMapping(0, pk,
4132                                    dlFolder.getPrimaryKey());
4133                    }
4134            }
4135    
4136            /**
4137             * Sets the document library folders associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4138             *
4139             * @param pk the primary key of the document library file entry type
4140             * @param dlFolderPKs the primary keys of the document library folders to be associated with the document library file entry type
4141             */
4142            @Override
4143            public void setDLFolders(long pk, long[] dlFolderPKs) {
4144                    Set<Long> newDLFolderPKsSet = SetUtil.fromArray(dlFolderPKs);
4145                    Set<Long> oldDLFolderPKsSet = SetUtil.fromArray(dlFileEntryTypeToDLFolderTableMapper.getRightPrimaryKeys(
4146                                            0, pk));
4147    
4148                    Set<Long> removeDLFolderPKsSet = new HashSet<Long>(oldDLFolderPKsSet);
4149    
4150                    removeDLFolderPKsSet.removeAll(newDLFolderPKsSet);
4151    
4152                    for (long removeDLFolderPK : removeDLFolderPKsSet) {
4153                            dlFileEntryTypeToDLFolderTableMapper.deleteTableMapping(0, pk,
4154                                    removeDLFolderPK);
4155                    }
4156    
4157                    newDLFolderPKsSet.removeAll(oldDLFolderPKsSet);
4158    
4159                    for (long newDLFolderPK : newDLFolderPKsSet) {
4160                            dlFileEntryTypeToDLFolderTableMapper.addTableMapping(0, pk,
4161                                    newDLFolderPK);
4162                    }
4163            }
4164    
4165            /**
4166             * Sets the document library folders associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
4167             *
4168             * @param pk the primary key of the document library file entry type
4169             * @param dlFolders the document library folders to be associated with the document library file entry type
4170             */
4171            @Override
4172            public void setDLFolders(long pk,
4173                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders) {
4174                    try {
4175                            long[] dlFolderPKs = new long[dlFolders.size()];
4176    
4177                            for (int i = 0; i < dlFolders.size(); i++) {
4178                                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder = dlFolders.get(i);
4179    
4180                                    dlFolderPKs[i] = dlFolder.getPrimaryKey();
4181                            }
4182    
4183                            setDLFolders(pk, dlFolderPKs);
4184                    }
4185                    catch (Exception e) {
4186                            throw processException(e);
4187                    }
4188            }
4189    
4190            @Override
4191            public Set<String> getBadColumnNames() {
4192                    return _badColumnNames;
4193            }
4194    
4195            @Override
4196            protected Map<String, Integer> getTableColumnsMap() {
4197                    return DLFileEntryTypeModelImpl.TABLE_COLUMNS_MAP;
4198            }
4199    
4200            /**
4201             * Initializes the document library file entry type persistence.
4202             */
4203            public void afterPropertiesSet() {
4204                    dlFileEntryTypeToDLFolderTableMapper = TableMapperFactory.getTableMapper("DLFileEntryTypes_DLFolders",
4205                                    "companyId", "fileEntryTypeId", "folderId", this,
4206                                    dlFolderPersistence);
4207            }
4208    
4209            public void destroy() {
4210                    entityCache.removeCache(DLFileEntryTypeImpl.class.getName());
4211                    finderCache.removeCache(FINDER_CLASS_NAME_ENTITY);
4212                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
4213                    finderCache.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4214    
4215                    TableMapperFactory.removeTableMapper("DLFileEntryTypes_DLFolders");
4216            }
4217    
4218            @BeanReference(type = CompanyProvider.class)
4219            protected CompanyProvider companyProvider;
4220            protected EntityCache entityCache = EntityCacheUtil.getEntityCache();
4221            protected FinderCache finderCache = FinderCacheUtil.getFinderCache();
4222            @BeanReference(type = DLFolderPersistence.class)
4223            protected DLFolderPersistence dlFolderPersistence;
4224            protected TableMapper<DLFileEntryType, com.liferay.portlet.documentlibrary.model.DLFolder> dlFileEntryTypeToDLFolderTableMapper;
4225            private static final String _SQL_SELECT_DLFILEENTRYTYPE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType";
4226            private static final String _SQL_SELECT_DLFILEENTRYTYPE_WHERE_PKS_IN = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType WHERE fileEntryTypeId IN (";
4227            private static final String _SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType WHERE ";
4228            private static final String _SQL_COUNT_DLFILEENTRYTYPE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType";
4229            private static final String _SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType WHERE ";
4230            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntryType.fileEntryTypeId";
4231            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT DISTINCT {dlFileEntryType.*} FROM DLFileEntryType dlFileEntryType WHERE ";
4232            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4233                    "SELECT {DLFileEntryType.*} FROM (SELECT DISTINCT dlFileEntryType.fileEntryTypeId FROM DLFileEntryType dlFileEntryType WHERE ";
4234            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4235                    ") TEMP_TABLE INNER JOIN DLFileEntryType ON TEMP_TABLE.fileEntryTypeId = DLFileEntryType.fileEntryTypeId";
4236            private static final String _FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(DISTINCT dlFileEntryType.fileEntryTypeId) AS COUNT_VALUE FROM DLFileEntryType dlFileEntryType WHERE ";
4237            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntryType";
4238            private static final String _FILTER_ENTITY_TABLE = "DLFileEntryType";
4239            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryType.";
4240            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntryType.";
4241            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryType exists with the primary key ";
4242            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryType exists with the key {";
4243            private static final Log _log = LogFactoryUtil.getLog(DLFileEntryTypePersistenceImpl.class);
4244            private static final Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
4245                                    "uuid"
4246                            });
4247            private static final DLFileEntryType _nullDLFileEntryType = new DLFileEntryTypeImpl() {
4248                            @Override
4249                            public Object clone() {
4250                                    return this;
4251                            }
4252    
4253                            @Override
4254                            public CacheModel<DLFileEntryType> toCacheModel() {
4255                                    return _nullDLFileEntryTypeCacheModel;
4256                            }
4257                    };
4258    
4259            private static final CacheModel<DLFileEntryType> _nullDLFileEntryTypeCacheModel =
4260                    new CacheModel<DLFileEntryType>() {
4261                            @Override
4262                            public DLFileEntryType toEntityModel() {
4263                                    return _nullDLFileEntryType;
4264                            }
4265                    };
4266    }