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