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