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