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