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