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