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