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