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