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