1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.documentlibrary.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.annotation.BeanReference;
27  import com.liferay.portal.kernel.cache.CacheRegistry;
28  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31  import com.liferay.portal.kernel.dao.orm.FinderPath;
32  import com.liferay.portal.kernel.dao.orm.Query;
33  import com.liferay.portal.kernel.dao.orm.QueryPos;
34  import com.liferay.portal.kernel.dao.orm.QueryUtil;
35  import com.liferay.portal.kernel.dao.orm.Session;
36  import com.liferay.portal.kernel.log.Log;
37  import com.liferay.portal.kernel.log.LogFactoryUtil;
38  import com.liferay.portal.kernel.util.GetterUtil;
39  import com.liferay.portal.kernel.util.OrderByComparator;
40  import com.liferay.portal.kernel.util.StringPool;
41  import com.liferay.portal.kernel.util.StringUtil;
42  import com.liferay.portal.kernel.util.Validator;
43  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44  import com.liferay.portal.model.ModelListener;
45  import com.liferay.portal.service.persistence.BatchSessionUtil;
46  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47  
48  import com.liferay.portlet.documentlibrary.NoSuchFileEntryException;
49  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
50  import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl;
51  import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryModelImpl;
52  
53  import java.util.ArrayList;
54  import java.util.Collections;
55  import java.util.List;
56  
57  /**
58   * <a href="DLFileEntryPersistenceImpl.java.html"><b><i>View Source</i></b></a>
59   *
60   * <p>
61   * ServiceBuilder generated this class. Modifications in this class will be
62   * overwritten the next time is generated.
63   * </p>
64   *
65   * @author    Brian Wing Shun Chan
66   * @see       DLFileEntryPersistence
67   * @see       DLFileEntryUtil
68   * @generated
69   */
70  public class DLFileEntryPersistenceImpl extends BasePersistenceImpl
71      implements DLFileEntryPersistence {
72      public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryImpl.class.getName();
73      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74          ".List";
75      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
76              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77              "findByUuid", new String[] { String.class.getName() });
78      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
79              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80              "findByUuid",
81              new String[] {
82                  String.class.getName(),
83                  
84              "java.lang.Integer", "java.lang.Integer",
85                  "com.liferay.portal.kernel.util.OrderByComparator"
86              });
87      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
88              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89              "countByUuid", new String[] { String.class.getName() });
90      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
91              DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
92              FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
93              new String[] { String.class.getName(), Long.class.getName() });
94      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
95              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96              "countByUUID_G",
97              new String[] { String.class.getName(), Long.class.getName() });
98      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
99              DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100             "findByGroupId", new String[] { Long.class.getName() });
101     public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
102             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103             "findByGroupId",
104             new String[] {
105                 Long.class.getName(),
106                 
107             "java.lang.Integer", "java.lang.Integer",
108                 "com.liferay.portal.kernel.util.OrderByComparator"
109             });
110     public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
111             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112             "countByGroupId", new String[] { Long.class.getName() });
113     public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
114             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115             "findByCompanyId", new String[] { Long.class.getName() });
116     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
117             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118             "findByCompanyId",
119             new String[] {
120                 Long.class.getName(),
121                 
122             "java.lang.Integer", "java.lang.Integer",
123                 "com.liferay.portal.kernel.util.OrderByComparator"
124             });
125     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
126             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127             "countByCompanyId", new String[] { Long.class.getName() });
128     public static final FinderPath FINDER_PATH_FIND_BY_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
129             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130             "findByFolderId", new String[] { Long.class.getName() });
131     public static final FinderPath FINDER_PATH_FIND_BY_OBC_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
132             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
133             "findByFolderId",
134             new String[] {
135                 Long.class.getName(),
136                 
137             "java.lang.Integer", "java.lang.Integer",
138                 "com.liferay.portal.kernel.util.OrderByComparator"
139             });
140     public static final FinderPath FINDER_PATH_COUNT_BY_FOLDERID = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
141             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
142             "countByFolderId", new String[] { Long.class.getName() });
143     public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
144             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
145             "findByG_U",
146             new String[] { Long.class.getName(), Long.class.getName() });
147     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
148             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149             "findByG_U",
150             new String[] {
151                 Long.class.getName(), Long.class.getName(),
152                 
153             "java.lang.Integer", "java.lang.Integer",
154                 "com.liferay.portal.kernel.util.OrderByComparator"
155             });
156     public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
157             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
158             "countByG_U",
159             new String[] { Long.class.getName(), Long.class.getName() });
160     public static final FinderPath FINDER_PATH_FETCH_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
161             DLFileEntryModelImpl.FINDER_CACHE_ENABLED,
162             FINDER_CLASS_NAME_ENTITY, "fetchByF_N",
163             new String[] { Long.class.getName(), String.class.getName() });
164     public static final FinderPath FINDER_PATH_COUNT_BY_F_N = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
165             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
166             "countByF_N",
167             new String[] { Long.class.getName(), String.class.getName() });
168     public static final FinderPath FINDER_PATH_FIND_BY_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
169             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
170             "findByF_T",
171             new String[] { Long.class.getName(), String.class.getName() });
172     public static final FinderPath FINDER_PATH_FIND_BY_OBC_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
173             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
174             "findByF_T",
175             new String[] {
176                 Long.class.getName(), String.class.getName(),
177                 
178             "java.lang.Integer", "java.lang.Integer",
179                 "com.liferay.portal.kernel.util.OrderByComparator"
180             });
181     public static final FinderPath FINDER_PATH_COUNT_BY_F_T = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
182             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
183             "countByF_T",
184             new String[] { Long.class.getName(), String.class.getName() });
185     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
186             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
187             "findAll", new String[0]);
188     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
189             DLFileEntryModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
190             "countAll", new String[0]);
191 
192     public void cacheResult(DLFileEntry dlFileEntry) {
193         EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
194             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
195 
196         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
197             new Object[] {
198                 dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
199             }, dlFileEntry);
200 
201         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
202             new Object[] {
203                 new Long(dlFileEntry.getFolderId()),
204                 
205             dlFileEntry.getName()
206             }, dlFileEntry);
207     }
208 
209     public void cacheResult(List<DLFileEntry> dlFileEntries) {
210         for (DLFileEntry dlFileEntry : dlFileEntries) {
211             if (EntityCacheUtil.getResult(
212                         DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
213                         DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), this) == null) {
214                 cacheResult(dlFileEntry);
215             }
216         }
217     }
218 
219     public void clearCache() {
220         CacheRegistry.clear(DLFileEntryImpl.class.getName());
221         EntityCacheUtil.clearCache(DLFileEntryImpl.class.getName());
222         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
223         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
224     }
225 
226     public DLFileEntry create(long fileEntryId) {
227         DLFileEntry dlFileEntry = new DLFileEntryImpl();
228 
229         dlFileEntry.setNew(true);
230         dlFileEntry.setPrimaryKey(fileEntryId);
231 
232         String uuid = PortalUUIDUtil.generate();
233 
234         dlFileEntry.setUuid(uuid);
235 
236         return dlFileEntry;
237     }
238 
239     public DLFileEntry remove(long fileEntryId)
240         throws NoSuchFileEntryException, SystemException {
241         Session session = null;
242 
243         try {
244             session = openSession();
245 
246             DLFileEntry dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
247                     new Long(fileEntryId));
248 
249             if (dlFileEntry == null) {
250                 if (_log.isWarnEnabled()) {
251                     _log.warn("No DLFileEntry exists with the primary key " +
252                         fileEntryId);
253                 }
254 
255                 throw new NoSuchFileEntryException(
256                     "No DLFileEntry exists with the primary key " +
257                     fileEntryId);
258             }
259 
260             return remove(dlFileEntry);
261         }
262         catch (NoSuchFileEntryException nsee) {
263             throw nsee;
264         }
265         catch (Exception e) {
266             throw processException(e);
267         }
268         finally {
269             closeSession(session);
270         }
271     }
272 
273     public DLFileEntry remove(DLFileEntry dlFileEntry)
274         throws SystemException {
275         for (ModelListener<DLFileEntry> listener : listeners) {
276             listener.onBeforeRemove(dlFileEntry);
277         }
278 
279         dlFileEntry = removeImpl(dlFileEntry);
280 
281         for (ModelListener<DLFileEntry> listener : listeners) {
282             listener.onAfterRemove(dlFileEntry);
283         }
284 
285         return dlFileEntry;
286     }
287 
288     protected DLFileEntry removeImpl(DLFileEntry dlFileEntry)
289         throws SystemException {
290         Session session = null;
291 
292         try {
293             session = openSession();
294 
295             if (dlFileEntry.isCachedModel() || BatchSessionUtil.isEnabled()) {
296                 Object staleObject = session.get(DLFileEntryImpl.class,
297                         dlFileEntry.getPrimaryKeyObj());
298 
299                 if (staleObject != null) {
300                     session.evict(staleObject);
301                 }
302             }
303 
304             session.delete(dlFileEntry);
305 
306             session.flush();
307         }
308         catch (Exception e) {
309             throw processException(e);
310         }
311         finally {
312             closeSession(session);
313         }
314 
315         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
316 
317         DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
318 
319         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
320             new Object[] {
321                 dlFileEntryModelImpl.getOriginalUuid(),
322                 new Long(dlFileEntryModelImpl.getOriginalGroupId())
323             });
324 
325         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_N,
326             new Object[] {
327                 new Long(dlFileEntryModelImpl.getOriginalFolderId()),
328                 
329             dlFileEntryModelImpl.getOriginalName()
330             });
331 
332         EntityCacheUtil.removeResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
333             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey());
334 
335         return dlFileEntry;
336     }
337 
338     /**
339      * @deprecated Use {@link #update(DLFileEntry, boolean merge)}.
340      */
341     public DLFileEntry update(DLFileEntry dlFileEntry)
342         throws SystemException {
343         if (_log.isWarnEnabled()) {
344             _log.warn(
345                 "Using the deprecated update(DLFileEntry dlFileEntry) method. Use update(DLFileEntry dlFileEntry, boolean merge) instead.");
346         }
347 
348         return update(dlFileEntry, false);
349     }
350 
351     /**
352      * Add, update, or merge, the entity. This method also calls the model
353      * listeners to trigger the proper events associated with adding, deleting,
354      * or updating an entity.
355      *
356      * @param  dlFileEntry the entity to add, update, or merge
357      * @param  merge boolean value for whether to merge the entity. The default
358      *         value is false. Setting merge to true is more expensive and
359      *         should only be true when dlFileEntry is transient. See
360      *         LEP-5473 for a detailed discussion of this method.
361      * @return the entity that was added, updated, or merged
362      */
363     public DLFileEntry update(DLFileEntry dlFileEntry, boolean merge)
364         throws SystemException {
365         boolean isNew = dlFileEntry.isNew();
366 
367         for (ModelListener<DLFileEntry> listener : listeners) {
368             if (isNew) {
369                 listener.onBeforeCreate(dlFileEntry);
370             }
371             else {
372                 listener.onBeforeUpdate(dlFileEntry);
373             }
374         }
375 
376         dlFileEntry = updateImpl(dlFileEntry, merge);
377 
378         for (ModelListener<DLFileEntry> listener : listeners) {
379             if (isNew) {
380                 listener.onAfterCreate(dlFileEntry);
381             }
382             else {
383                 listener.onAfterUpdate(dlFileEntry);
384             }
385         }
386 
387         return dlFileEntry;
388     }
389 
390     public DLFileEntry updateImpl(
391         com.liferay.portlet.documentlibrary.model.DLFileEntry dlFileEntry,
392         boolean merge) throws SystemException {
393         boolean isNew = dlFileEntry.isNew();
394 
395         DLFileEntryModelImpl dlFileEntryModelImpl = (DLFileEntryModelImpl)dlFileEntry;
396 
397         if (Validator.isNull(dlFileEntry.getUuid())) {
398             String uuid = PortalUUIDUtil.generate();
399 
400             dlFileEntry.setUuid(uuid);
401         }
402 
403         Session session = null;
404 
405         try {
406             session = openSession();
407 
408             BatchSessionUtil.update(session, dlFileEntry, merge);
409 
410             dlFileEntry.setNew(false);
411         }
412         catch (Exception e) {
413             throw processException(e);
414         }
415         finally {
416             closeSession(session);
417         }
418 
419         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
420 
421         EntityCacheUtil.putResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
422             DLFileEntryImpl.class, dlFileEntry.getPrimaryKey(), dlFileEntry);
423 
424         if (!isNew &&
425                 (!Validator.equals(dlFileEntry.getUuid(),
426                     dlFileEntryModelImpl.getOriginalUuid()) ||
427                 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
428             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
429                 new Object[] {
430                     dlFileEntryModelImpl.getOriginalUuid(),
431                     new Long(dlFileEntryModelImpl.getOriginalGroupId())
432                 });
433         }
434 
435         if (isNew ||
436                 (!Validator.equals(dlFileEntry.getUuid(),
437                     dlFileEntryModelImpl.getOriginalUuid()) ||
438                 (dlFileEntry.getGroupId() != dlFileEntryModelImpl.getOriginalGroupId()))) {
439             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
440                 new Object[] {
441                     dlFileEntry.getUuid(), new Long(dlFileEntry.getGroupId())
442                 }, dlFileEntry);
443         }
444 
445         if (!isNew &&
446                 ((dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
447                 !Validator.equals(dlFileEntry.getName(),
448                     dlFileEntryModelImpl.getOriginalName()))) {
449             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_F_N,
450                 new Object[] {
451                     new Long(dlFileEntryModelImpl.getOriginalFolderId()),
452                     
453                 dlFileEntryModelImpl.getOriginalName()
454                 });
455         }
456 
457         if (isNew ||
458                 ((dlFileEntry.getFolderId() != dlFileEntryModelImpl.getOriginalFolderId()) ||
459                 !Validator.equals(dlFileEntry.getName(),
460                     dlFileEntryModelImpl.getOriginalName()))) {
461             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
462                 new Object[] {
463                     new Long(dlFileEntry.getFolderId()),
464                     
465                 dlFileEntry.getName()
466                 }, dlFileEntry);
467         }
468 
469         return dlFileEntry;
470     }
471 
472     public DLFileEntry findByPrimaryKey(long fileEntryId)
473         throws NoSuchFileEntryException, SystemException {
474         DLFileEntry dlFileEntry = fetchByPrimaryKey(fileEntryId);
475 
476         if (dlFileEntry == null) {
477             if (_log.isWarnEnabled()) {
478                 _log.warn("No DLFileEntry exists with the primary key " +
479                     fileEntryId);
480             }
481 
482             throw new NoSuchFileEntryException(
483                 "No DLFileEntry exists with the primary key " + fileEntryId);
484         }
485 
486         return dlFileEntry;
487     }
488 
489     public DLFileEntry fetchByPrimaryKey(long fileEntryId)
490         throws SystemException {
491         DLFileEntry dlFileEntry = (DLFileEntry)EntityCacheUtil.getResult(DLFileEntryModelImpl.ENTITY_CACHE_ENABLED,
492                 DLFileEntryImpl.class, fileEntryId, this);
493 
494         if (dlFileEntry == null) {
495             Session session = null;
496 
497             try {
498                 session = openSession();
499 
500                 dlFileEntry = (DLFileEntry)session.get(DLFileEntryImpl.class,
501                         new Long(fileEntryId));
502             }
503             catch (Exception e) {
504                 throw processException(e);
505             }
506             finally {
507                 if (dlFileEntry != null) {
508                     cacheResult(dlFileEntry);
509                 }
510 
511                 closeSession(session);
512             }
513         }
514 
515         return dlFileEntry;
516     }
517 
518     public List<DLFileEntry> findByUuid(String uuid) throws SystemException {
519         Object[] finderArgs = new Object[] { uuid };
520 
521         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
522                 finderArgs, this);
523 
524         if (list == null) {
525             Session session = null;
526 
527             try {
528                 session = openSession();
529 
530                 StringBuilder query = new StringBuilder();
531 
532                 query.append(
533                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
534 
535                 if (uuid == null) {
536                     query.append("dlFileEntry.uuid IS NULL");
537                 }
538                 else {
539                     query.append("dlFileEntry.uuid = ?");
540                 }
541 
542                 query.append(" ");
543 
544                 query.append("ORDER BY ");
545 
546                 query.append("dlFileEntry.folderId ASC, ");
547                 query.append("dlFileEntry.name ASC");
548 
549                 Query q = session.createQuery(query.toString());
550 
551                 QueryPos qPos = QueryPos.getInstance(q);
552 
553                 if (uuid != null) {
554                     qPos.add(uuid);
555                 }
556 
557                 list = q.list();
558             }
559             catch (Exception e) {
560                 throw processException(e);
561             }
562             finally {
563                 if (list == null) {
564                     list = new ArrayList<DLFileEntry>();
565                 }
566 
567                 cacheResult(list);
568 
569                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
570                     list);
571 
572                 closeSession(session);
573             }
574         }
575 
576         return list;
577     }
578 
579     public List<DLFileEntry> findByUuid(String uuid, int start, int end)
580         throws SystemException {
581         return findByUuid(uuid, start, end, null);
582     }
583 
584     public List<DLFileEntry> findByUuid(String uuid, int start, int end,
585         OrderByComparator obc) throws SystemException {
586         Object[] finderArgs = new Object[] {
587                 uuid,
588                 
589                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
590             };
591 
592         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
593                 finderArgs, this);
594 
595         if (list == null) {
596             Session session = null;
597 
598             try {
599                 session = openSession();
600 
601                 StringBuilder query = new StringBuilder();
602 
603                 query.append(
604                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
605 
606                 if (uuid == null) {
607                     query.append("dlFileEntry.uuid IS NULL");
608                 }
609                 else {
610                     query.append("dlFileEntry.uuid = ?");
611                 }
612 
613                 query.append(" ");
614 
615                 if (obc != null) {
616                     query.append("ORDER BY ");
617 
618                     String[] orderByFields = obc.getOrderByFields();
619 
620                     for (int i = 0; i < orderByFields.length; i++) {
621                         query.append("dlFileEntry.");
622                         query.append(orderByFields[i]);
623 
624                         if (obc.isAscending()) {
625                             query.append(" ASC");
626                         }
627                         else {
628                             query.append(" DESC");
629                         }
630 
631                         if ((i + 1) < orderByFields.length) {
632                             query.append(", ");
633                         }
634                     }
635                 }
636 
637                 else {
638                     query.append("ORDER BY ");
639 
640                     query.append("dlFileEntry.folderId ASC, ");
641                     query.append("dlFileEntry.name ASC");
642                 }
643 
644                 Query q = session.createQuery(query.toString());
645 
646                 QueryPos qPos = QueryPos.getInstance(q);
647 
648                 if (uuid != null) {
649                     qPos.add(uuid);
650                 }
651 
652                 list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
653                         start, end);
654             }
655             catch (Exception e) {
656                 throw processException(e);
657             }
658             finally {
659                 if (list == null) {
660                     list = new ArrayList<DLFileEntry>();
661                 }
662 
663                 cacheResult(list);
664 
665                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
666                     finderArgs, list);
667 
668                 closeSession(session);
669             }
670         }
671 
672         return list;
673     }
674 
675     public DLFileEntry findByUuid_First(String uuid, OrderByComparator obc)
676         throws NoSuchFileEntryException, SystemException {
677         List<DLFileEntry> list = findByUuid(uuid, 0, 1, obc);
678 
679         if (list.isEmpty()) {
680             StringBuilder msg = new StringBuilder();
681 
682             msg.append("No DLFileEntry exists with the key {");
683 
684             msg.append("uuid=" + uuid);
685 
686             msg.append(StringPool.CLOSE_CURLY_BRACE);
687 
688             throw new NoSuchFileEntryException(msg.toString());
689         }
690         else {
691             return list.get(0);
692         }
693     }
694 
695     public DLFileEntry findByUuid_Last(String uuid, OrderByComparator obc)
696         throws NoSuchFileEntryException, SystemException {
697         int count = countByUuid(uuid);
698 
699         List<DLFileEntry> list = findByUuid(uuid, count - 1, count, obc);
700 
701         if (list.isEmpty()) {
702             StringBuilder msg = new StringBuilder();
703 
704             msg.append("No DLFileEntry exists with the key {");
705 
706             msg.append("uuid=" + uuid);
707 
708             msg.append(StringPool.CLOSE_CURLY_BRACE);
709 
710             throw new NoSuchFileEntryException(msg.toString());
711         }
712         else {
713             return list.get(0);
714         }
715     }
716 
717     public DLFileEntry[] findByUuid_PrevAndNext(long fileEntryId, String uuid,
718         OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
719         DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
720 
721         int count = countByUuid(uuid);
722 
723         Session session = null;
724 
725         try {
726             session = openSession();
727 
728             StringBuilder query = new StringBuilder();
729 
730             query.append(
731                 "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
732 
733             if (uuid == null) {
734                 query.append("dlFileEntry.uuid IS NULL");
735             }
736             else {
737                 query.append("dlFileEntry.uuid = ?");
738             }
739 
740             query.append(" ");
741 
742             if (obc != null) {
743                 query.append("ORDER BY ");
744 
745                 String[] orderByFields = obc.getOrderByFields();
746 
747                 for (int i = 0; i < orderByFields.length; i++) {
748                     query.append("dlFileEntry.");
749                     query.append(orderByFields[i]);
750 
751                     if (obc.isAscending()) {
752                         query.append(" ASC");
753                     }
754                     else {
755                         query.append(" DESC");
756                     }
757 
758                     if ((i + 1) < orderByFields.length) {
759                         query.append(", ");
760                     }
761                 }
762             }
763 
764             else {
765                 query.append("ORDER BY ");
766 
767                 query.append("dlFileEntry.folderId ASC, ");
768                 query.append("dlFileEntry.name ASC");
769             }
770 
771             Query q = session.createQuery(query.toString());
772 
773             QueryPos qPos = QueryPos.getInstance(q);
774 
775             if (uuid != null) {
776                 qPos.add(uuid);
777             }
778 
779             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
780                     dlFileEntry);
781 
782             DLFileEntry[] array = new DLFileEntryImpl[3];
783 
784             array[0] = (DLFileEntry)objArray[0];
785             array[1] = (DLFileEntry)objArray[1];
786             array[2] = (DLFileEntry)objArray[2];
787 
788             return array;
789         }
790         catch (Exception e) {
791             throw processException(e);
792         }
793         finally {
794             closeSession(session);
795         }
796     }
797 
798     public DLFileEntry findByUUID_G(String uuid, long groupId)
799         throws NoSuchFileEntryException, SystemException {
800         DLFileEntry dlFileEntry = fetchByUUID_G(uuid, groupId);
801 
802         if (dlFileEntry == null) {
803             StringBuilder msg = new StringBuilder();
804 
805             msg.append("No DLFileEntry exists with the key {");
806 
807             msg.append("uuid=" + uuid);
808 
809             msg.append(", ");
810             msg.append("groupId=" + groupId);
811 
812             msg.append(StringPool.CLOSE_CURLY_BRACE);
813 
814             if (_log.isWarnEnabled()) {
815                 _log.warn(msg.toString());
816             }
817 
818             throw new NoSuchFileEntryException(msg.toString());
819         }
820 
821         return dlFileEntry;
822     }
823 
824     public DLFileEntry fetchByUUID_G(String uuid, long groupId)
825         throws SystemException {
826         return fetchByUUID_G(uuid, groupId, true);
827     }
828 
829     public DLFileEntry fetchByUUID_G(String uuid, long groupId,
830         boolean retrieveFromCache) throws SystemException {
831         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
832 
833         Object result = null;
834 
835         if (retrieveFromCache) {
836             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
837                     finderArgs, this);
838         }
839 
840         if (result == null) {
841             Session session = null;
842 
843             try {
844                 session = openSession();
845 
846                 StringBuilder query = new StringBuilder();
847 
848                 query.append(
849                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
850 
851                 if (uuid == null) {
852                     query.append("dlFileEntry.uuid IS NULL");
853                 }
854                 else {
855                     query.append("dlFileEntry.uuid = ?");
856                 }
857 
858                 query.append(" AND ");
859 
860                 query.append("dlFileEntry.groupId = ?");
861 
862                 query.append(" ");
863 
864                 query.append("ORDER BY ");
865 
866                 query.append("dlFileEntry.folderId ASC, ");
867                 query.append("dlFileEntry.name ASC");
868 
869                 Query q = session.createQuery(query.toString());
870 
871                 QueryPos qPos = QueryPos.getInstance(q);
872 
873                 if (uuid != null) {
874                     qPos.add(uuid);
875                 }
876 
877                 qPos.add(groupId);
878 
879                 List<DLFileEntry> list = q.list();
880 
881                 result = list;
882 
883                 DLFileEntry dlFileEntry = null;
884 
885                 if (list.isEmpty()) {
886                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
887                         finderArgs, list);
888                 }
889                 else {
890                     dlFileEntry = list.get(0);
891 
892                     cacheResult(dlFileEntry);
893 
894                     if ((dlFileEntry.getUuid() == null) ||
895                             !dlFileEntry.getUuid().equals(uuid) ||
896                             (dlFileEntry.getGroupId() != groupId)) {
897                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
898                             finderArgs, dlFileEntry);
899                     }
900                 }
901 
902                 return dlFileEntry;
903             }
904             catch (Exception e) {
905                 throw processException(e);
906             }
907             finally {
908                 if (result == null) {
909                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
910                         finderArgs, new ArrayList<DLFileEntry>());
911                 }
912 
913                 closeSession(session);
914             }
915         }
916         else {
917             if (result instanceof List<?>) {
918                 return null;
919             }
920             else {
921                 return (DLFileEntry)result;
922             }
923         }
924     }
925 
926     public List<DLFileEntry> findByGroupId(long groupId)
927         throws SystemException {
928         Object[] finderArgs = new Object[] { new Long(groupId) };
929 
930         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
931                 finderArgs, this);
932 
933         if (list == null) {
934             Session session = null;
935 
936             try {
937                 session = openSession();
938 
939                 StringBuilder query = new StringBuilder();
940 
941                 query.append(
942                     "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
943 
944                 query.append("dlFileEntry.groupId = ?");
945 
946                 query.append(" ");
947 
948                 query.append("ORDER BY ");
949 
950                 query.append("dlFileEntry.folderId ASC, ");
951                 query.append("dlFileEntry.name ASC");
952 
953                 Query q = session.createQuery(query.toString());
954 
955                 QueryPos qPos = QueryPos.getInstance(q);
956 
957                 qPos.add(groupId);
958 
959                 list = q.list();
960             }
961             catch (Exception e) {
962                 throw processException(e);
963             }
964             finally {
965                 if (list == null) {
966                     list = new ArrayList<DLFileEntry>();
967                 }
968 
969                 cacheResult(list);
970 
971                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
972                     finderArgs, list);
973 
974                 closeSession(session);
975             }
976         }
977 
978         return list;
979     }
980 
981     public List<DLFileEntry> findByGroupId(long groupId, int start, int end)
982         throws SystemException {
983         return findByGroupId(groupId, start, end, null);
984     }
985 
986     public List<DLFileEntry> findByGroupId(long groupId, int start, int end,
987         OrderByComparator obc) throws SystemException {
988         Object[] finderArgs = new Object[] {
989                 new Long(groupId),
990                 
991                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
992             };
993 
994         List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
995                 finderArgs, this);
996 
997         if (list == null) {
998             Session session = null;
999 
1000            try {
1001                session = openSession();
1002
1003                StringBuilder query = new StringBuilder();
1004
1005                query.append(
1006                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1007
1008                query.append("dlFileEntry.groupId = ?");
1009
1010                query.append(" ");
1011
1012                if (obc != null) {
1013                    query.append("ORDER BY ");
1014
1015                    String[] orderByFields = obc.getOrderByFields();
1016
1017                    for (int i = 0; i < orderByFields.length; i++) {
1018                        query.append("dlFileEntry.");
1019                        query.append(orderByFields[i]);
1020
1021                        if (obc.isAscending()) {
1022                            query.append(" ASC");
1023                        }
1024                        else {
1025                            query.append(" DESC");
1026                        }
1027
1028                        if ((i + 1) < orderByFields.length) {
1029                            query.append(", ");
1030                        }
1031                    }
1032                }
1033
1034                else {
1035                    query.append("ORDER BY ");
1036
1037                    query.append("dlFileEntry.folderId ASC, ");
1038                    query.append("dlFileEntry.name ASC");
1039                }
1040
1041                Query q = session.createQuery(query.toString());
1042
1043                QueryPos qPos = QueryPos.getInstance(q);
1044
1045                qPos.add(groupId);
1046
1047                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1048                        start, end);
1049            }
1050            catch (Exception e) {
1051                throw processException(e);
1052            }
1053            finally {
1054                if (list == null) {
1055                    list = new ArrayList<DLFileEntry>();
1056                }
1057
1058                cacheResult(list);
1059
1060                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1061                    finderArgs, list);
1062
1063                closeSession(session);
1064            }
1065        }
1066
1067        return list;
1068    }
1069
1070    public DLFileEntry findByGroupId_First(long groupId, OrderByComparator obc)
1071        throws NoSuchFileEntryException, SystemException {
1072        List<DLFileEntry> list = findByGroupId(groupId, 0, 1, obc);
1073
1074        if (list.isEmpty()) {
1075            StringBuilder msg = new StringBuilder();
1076
1077            msg.append("No DLFileEntry exists with the key {");
1078
1079            msg.append("groupId=" + groupId);
1080
1081            msg.append(StringPool.CLOSE_CURLY_BRACE);
1082
1083            throw new NoSuchFileEntryException(msg.toString());
1084        }
1085        else {
1086            return list.get(0);
1087        }
1088    }
1089
1090    public DLFileEntry findByGroupId_Last(long groupId, OrderByComparator obc)
1091        throws NoSuchFileEntryException, SystemException {
1092        int count = countByGroupId(groupId);
1093
1094        List<DLFileEntry> list = findByGroupId(groupId, count - 1, count, obc);
1095
1096        if (list.isEmpty()) {
1097            StringBuilder msg = new StringBuilder();
1098
1099            msg.append("No DLFileEntry exists with the key {");
1100
1101            msg.append("groupId=" + groupId);
1102
1103            msg.append(StringPool.CLOSE_CURLY_BRACE);
1104
1105            throw new NoSuchFileEntryException(msg.toString());
1106        }
1107        else {
1108            return list.get(0);
1109        }
1110    }
1111
1112    public DLFileEntry[] findByGroupId_PrevAndNext(long fileEntryId,
1113        long groupId, OrderByComparator obc)
1114        throws NoSuchFileEntryException, SystemException {
1115        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1116
1117        int count = countByGroupId(groupId);
1118
1119        Session session = null;
1120
1121        try {
1122            session = openSession();
1123
1124            StringBuilder query = new StringBuilder();
1125
1126            query.append(
1127                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1128
1129            query.append("dlFileEntry.groupId = ?");
1130
1131            query.append(" ");
1132
1133            if (obc != null) {
1134                query.append("ORDER BY ");
1135
1136                String[] orderByFields = obc.getOrderByFields();
1137
1138                for (int i = 0; i < orderByFields.length; i++) {
1139                    query.append("dlFileEntry.");
1140                    query.append(orderByFields[i]);
1141
1142                    if (obc.isAscending()) {
1143                        query.append(" ASC");
1144                    }
1145                    else {
1146                        query.append(" DESC");
1147                    }
1148
1149                    if ((i + 1) < orderByFields.length) {
1150                        query.append(", ");
1151                    }
1152                }
1153            }
1154
1155            else {
1156                query.append("ORDER BY ");
1157
1158                query.append("dlFileEntry.folderId ASC, ");
1159                query.append("dlFileEntry.name ASC");
1160            }
1161
1162            Query q = session.createQuery(query.toString());
1163
1164            QueryPos qPos = QueryPos.getInstance(q);
1165
1166            qPos.add(groupId);
1167
1168            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1169                    dlFileEntry);
1170
1171            DLFileEntry[] array = new DLFileEntryImpl[3];
1172
1173            array[0] = (DLFileEntry)objArray[0];
1174            array[1] = (DLFileEntry)objArray[1];
1175            array[2] = (DLFileEntry)objArray[2];
1176
1177            return array;
1178        }
1179        catch (Exception e) {
1180            throw processException(e);
1181        }
1182        finally {
1183            closeSession(session);
1184        }
1185    }
1186
1187    public List<DLFileEntry> findByCompanyId(long companyId)
1188        throws SystemException {
1189        Object[] finderArgs = new Object[] { new Long(companyId) };
1190
1191        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1192                finderArgs, this);
1193
1194        if (list == null) {
1195            Session session = null;
1196
1197            try {
1198                session = openSession();
1199
1200                StringBuilder query = new StringBuilder();
1201
1202                query.append(
1203                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1204
1205                query.append("dlFileEntry.companyId = ?");
1206
1207                query.append(" ");
1208
1209                query.append("ORDER BY ");
1210
1211                query.append("dlFileEntry.folderId ASC, ");
1212                query.append("dlFileEntry.name ASC");
1213
1214                Query q = session.createQuery(query.toString());
1215
1216                QueryPos qPos = QueryPos.getInstance(q);
1217
1218                qPos.add(companyId);
1219
1220                list = q.list();
1221            }
1222            catch (Exception e) {
1223                throw processException(e);
1224            }
1225            finally {
1226                if (list == null) {
1227                    list = new ArrayList<DLFileEntry>();
1228                }
1229
1230                cacheResult(list);
1231
1232                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1233                    finderArgs, list);
1234
1235                closeSession(session);
1236            }
1237        }
1238
1239        return list;
1240    }
1241
1242    public List<DLFileEntry> findByCompanyId(long companyId, int start, int end)
1243        throws SystemException {
1244        return findByCompanyId(companyId, start, end, null);
1245    }
1246
1247    public List<DLFileEntry> findByCompanyId(long companyId, int start,
1248        int end, OrderByComparator obc) throws SystemException {
1249        Object[] finderArgs = new Object[] {
1250                new Long(companyId),
1251                
1252                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1253            };
1254
1255        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1256                finderArgs, this);
1257
1258        if (list == null) {
1259            Session session = null;
1260
1261            try {
1262                session = openSession();
1263
1264                StringBuilder query = new StringBuilder();
1265
1266                query.append(
1267                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1268
1269                query.append("dlFileEntry.companyId = ?");
1270
1271                query.append(" ");
1272
1273                if (obc != null) {
1274                    query.append("ORDER BY ");
1275
1276                    String[] orderByFields = obc.getOrderByFields();
1277
1278                    for (int i = 0; i < orderByFields.length; i++) {
1279                        query.append("dlFileEntry.");
1280                        query.append(orderByFields[i]);
1281
1282                        if (obc.isAscending()) {
1283                            query.append(" ASC");
1284                        }
1285                        else {
1286                            query.append(" DESC");
1287                        }
1288
1289                        if ((i + 1) < orderByFields.length) {
1290                            query.append(", ");
1291                        }
1292                    }
1293                }
1294
1295                else {
1296                    query.append("ORDER BY ");
1297
1298                    query.append("dlFileEntry.folderId ASC, ");
1299                    query.append("dlFileEntry.name ASC");
1300                }
1301
1302                Query q = session.createQuery(query.toString());
1303
1304                QueryPos qPos = QueryPos.getInstance(q);
1305
1306                qPos.add(companyId);
1307
1308                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1309                        start, end);
1310            }
1311            catch (Exception e) {
1312                throw processException(e);
1313            }
1314            finally {
1315                if (list == null) {
1316                    list = new ArrayList<DLFileEntry>();
1317                }
1318
1319                cacheResult(list);
1320
1321                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1322                    finderArgs, list);
1323
1324                closeSession(session);
1325            }
1326        }
1327
1328        return list;
1329    }
1330
1331    public DLFileEntry findByCompanyId_First(long companyId,
1332        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1333        List<DLFileEntry> list = findByCompanyId(companyId, 0, 1, obc);
1334
1335        if (list.isEmpty()) {
1336            StringBuilder msg = new StringBuilder();
1337
1338            msg.append("No DLFileEntry exists with the key {");
1339
1340            msg.append("companyId=" + companyId);
1341
1342            msg.append(StringPool.CLOSE_CURLY_BRACE);
1343
1344            throw new NoSuchFileEntryException(msg.toString());
1345        }
1346        else {
1347            return list.get(0);
1348        }
1349    }
1350
1351    public DLFileEntry findByCompanyId_Last(long companyId,
1352        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1353        int count = countByCompanyId(companyId);
1354
1355        List<DLFileEntry> list = findByCompanyId(companyId, count - 1, count,
1356                obc);
1357
1358        if (list.isEmpty()) {
1359            StringBuilder msg = new StringBuilder();
1360
1361            msg.append("No DLFileEntry exists with the key {");
1362
1363            msg.append("companyId=" + companyId);
1364
1365            msg.append(StringPool.CLOSE_CURLY_BRACE);
1366
1367            throw new NoSuchFileEntryException(msg.toString());
1368        }
1369        else {
1370            return list.get(0);
1371        }
1372    }
1373
1374    public DLFileEntry[] findByCompanyId_PrevAndNext(long fileEntryId,
1375        long companyId, OrderByComparator obc)
1376        throws NoSuchFileEntryException, SystemException {
1377        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1378
1379        int count = countByCompanyId(companyId);
1380
1381        Session session = null;
1382
1383        try {
1384            session = openSession();
1385
1386            StringBuilder query = new StringBuilder();
1387
1388            query.append(
1389                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1390
1391            query.append("dlFileEntry.companyId = ?");
1392
1393            query.append(" ");
1394
1395            if (obc != null) {
1396                query.append("ORDER BY ");
1397
1398                String[] orderByFields = obc.getOrderByFields();
1399
1400                for (int i = 0; i < orderByFields.length; i++) {
1401                    query.append("dlFileEntry.");
1402                    query.append(orderByFields[i]);
1403
1404                    if (obc.isAscending()) {
1405                        query.append(" ASC");
1406                    }
1407                    else {
1408                        query.append(" DESC");
1409                    }
1410
1411                    if ((i + 1) < orderByFields.length) {
1412                        query.append(", ");
1413                    }
1414                }
1415            }
1416
1417            else {
1418                query.append("ORDER BY ");
1419
1420                query.append("dlFileEntry.folderId ASC, ");
1421                query.append("dlFileEntry.name ASC");
1422            }
1423
1424            Query q = session.createQuery(query.toString());
1425
1426            QueryPos qPos = QueryPos.getInstance(q);
1427
1428            qPos.add(companyId);
1429
1430            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1431                    dlFileEntry);
1432
1433            DLFileEntry[] array = new DLFileEntryImpl[3];
1434
1435            array[0] = (DLFileEntry)objArray[0];
1436            array[1] = (DLFileEntry)objArray[1];
1437            array[2] = (DLFileEntry)objArray[2];
1438
1439            return array;
1440        }
1441        catch (Exception e) {
1442            throw processException(e);
1443        }
1444        finally {
1445            closeSession(session);
1446        }
1447    }
1448
1449    public List<DLFileEntry> findByFolderId(long folderId)
1450        throws SystemException {
1451        Object[] finderArgs = new Object[] { new Long(folderId) };
1452
1453        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FOLDERID,
1454                finderArgs, this);
1455
1456        if (list == null) {
1457            Session session = null;
1458
1459            try {
1460                session = openSession();
1461
1462                StringBuilder query = new StringBuilder();
1463
1464                query.append(
1465                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1466
1467                query.append("dlFileEntry.folderId = ?");
1468
1469                query.append(" ");
1470
1471                query.append("ORDER BY ");
1472
1473                query.append("dlFileEntry.folderId ASC, ");
1474                query.append("dlFileEntry.name ASC");
1475
1476                Query q = session.createQuery(query.toString());
1477
1478                QueryPos qPos = QueryPos.getInstance(q);
1479
1480                qPos.add(folderId);
1481
1482                list = q.list();
1483            }
1484            catch (Exception e) {
1485                throw processException(e);
1486            }
1487            finally {
1488                if (list == null) {
1489                    list = new ArrayList<DLFileEntry>();
1490                }
1491
1492                cacheResult(list);
1493
1494                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FOLDERID,
1495                    finderArgs, list);
1496
1497                closeSession(session);
1498            }
1499        }
1500
1501        return list;
1502    }
1503
1504    public List<DLFileEntry> findByFolderId(long folderId, int start, int end)
1505        throws SystemException {
1506        return findByFolderId(folderId, start, end, null);
1507    }
1508
1509    public List<DLFileEntry> findByFolderId(long folderId, int start, int end,
1510        OrderByComparator obc) throws SystemException {
1511        Object[] finderArgs = new Object[] {
1512                new Long(folderId),
1513                
1514                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1515            };
1516
1517        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1518                finderArgs, this);
1519
1520        if (list == null) {
1521            Session session = null;
1522
1523            try {
1524                session = openSession();
1525
1526                StringBuilder query = new StringBuilder();
1527
1528                query.append(
1529                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1530
1531                query.append("dlFileEntry.folderId = ?");
1532
1533                query.append(" ");
1534
1535                if (obc != null) {
1536                    query.append("ORDER BY ");
1537
1538                    String[] orderByFields = obc.getOrderByFields();
1539
1540                    for (int i = 0; i < orderByFields.length; i++) {
1541                        query.append("dlFileEntry.");
1542                        query.append(orderByFields[i]);
1543
1544                        if (obc.isAscending()) {
1545                            query.append(" ASC");
1546                        }
1547                        else {
1548                            query.append(" DESC");
1549                        }
1550
1551                        if ((i + 1) < orderByFields.length) {
1552                            query.append(", ");
1553                        }
1554                    }
1555                }
1556
1557                else {
1558                    query.append("ORDER BY ");
1559
1560                    query.append("dlFileEntry.folderId ASC, ");
1561                    query.append("dlFileEntry.name ASC");
1562                }
1563
1564                Query q = session.createQuery(query.toString());
1565
1566                QueryPos qPos = QueryPos.getInstance(q);
1567
1568                qPos.add(folderId);
1569
1570                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1571                        start, end);
1572            }
1573            catch (Exception e) {
1574                throw processException(e);
1575            }
1576            finally {
1577                if (list == null) {
1578                    list = new ArrayList<DLFileEntry>();
1579                }
1580
1581                cacheResult(list);
1582
1583                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FOLDERID,
1584                    finderArgs, list);
1585
1586                closeSession(session);
1587            }
1588        }
1589
1590        return list;
1591    }
1592
1593    public DLFileEntry findByFolderId_First(long folderId, OrderByComparator obc)
1594        throws NoSuchFileEntryException, SystemException {
1595        List<DLFileEntry> list = findByFolderId(folderId, 0, 1, obc);
1596
1597        if (list.isEmpty()) {
1598            StringBuilder msg = new StringBuilder();
1599
1600            msg.append("No DLFileEntry exists with the key {");
1601
1602            msg.append("folderId=" + folderId);
1603
1604            msg.append(StringPool.CLOSE_CURLY_BRACE);
1605
1606            throw new NoSuchFileEntryException(msg.toString());
1607        }
1608        else {
1609            return list.get(0);
1610        }
1611    }
1612
1613    public DLFileEntry findByFolderId_Last(long folderId, OrderByComparator obc)
1614        throws NoSuchFileEntryException, SystemException {
1615        int count = countByFolderId(folderId);
1616
1617        List<DLFileEntry> list = findByFolderId(folderId, count - 1, count, obc);
1618
1619        if (list.isEmpty()) {
1620            StringBuilder msg = new StringBuilder();
1621
1622            msg.append("No DLFileEntry exists with the key {");
1623
1624            msg.append("folderId=" + folderId);
1625
1626            msg.append(StringPool.CLOSE_CURLY_BRACE);
1627
1628            throw new NoSuchFileEntryException(msg.toString());
1629        }
1630        else {
1631            return list.get(0);
1632        }
1633    }
1634
1635    public DLFileEntry[] findByFolderId_PrevAndNext(long fileEntryId,
1636        long folderId, OrderByComparator obc)
1637        throws NoSuchFileEntryException, SystemException {
1638        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1639
1640        int count = countByFolderId(folderId);
1641
1642        Session session = null;
1643
1644        try {
1645            session = openSession();
1646
1647            StringBuilder query = new StringBuilder();
1648
1649            query.append(
1650                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1651
1652            query.append("dlFileEntry.folderId = ?");
1653
1654            query.append(" ");
1655
1656            if (obc != null) {
1657                query.append("ORDER BY ");
1658
1659                String[] orderByFields = obc.getOrderByFields();
1660
1661                for (int i = 0; i < orderByFields.length; i++) {
1662                    query.append("dlFileEntry.");
1663                    query.append(orderByFields[i]);
1664
1665                    if (obc.isAscending()) {
1666                        query.append(" ASC");
1667                    }
1668                    else {
1669                        query.append(" DESC");
1670                    }
1671
1672                    if ((i + 1) < orderByFields.length) {
1673                        query.append(", ");
1674                    }
1675                }
1676            }
1677
1678            else {
1679                query.append("ORDER BY ");
1680
1681                query.append("dlFileEntry.folderId ASC, ");
1682                query.append("dlFileEntry.name ASC");
1683            }
1684
1685            Query q = session.createQuery(query.toString());
1686
1687            QueryPos qPos = QueryPos.getInstance(q);
1688
1689            qPos.add(folderId);
1690
1691            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1692                    dlFileEntry);
1693
1694            DLFileEntry[] array = new DLFileEntryImpl[3];
1695
1696            array[0] = (DLFileEntry)objArray[0];
1697            array[1] = (DLFileEntry)objArray[1];
1698            array[2] = (DLFileEntry)objArray[2];
1699
1700            return array;
1701        }
1702        catch (Exception e) {
1703            throw processException(e);
1704        }
1705        finally {
1706            closeSession(session);
1707        }
1708    }
1709
1710    public List<DLFileEntry> findByG_U(long groupId, long userId)
1711        throws SystemException {
1712        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1713
1714        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
1715                finderArgs, this);
1716
1717        if (list == null) {
1718            Session session = null;
1719
1720            try {
1721                session = openSession();
1722
1723                StringBuilder query = new StringBuilder();
1724
1725                query.append(
1726                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1727
1728                query.append("dlFileEntry.groupId = ?");
1729
1730                query.append(" AND ");
1731
1732                query.append("dlFileEntry.userId = ?");
1733
1734                query.append(" ");
1735
1736                query.append("ORDER BY ");
1737
1738                query.append("dlFileEntry.folderId ASC, ");
1739                query.append("dlFileEntry.name ASC");
1740
1741                Query q = session.createQuery(query.toString());
1742
1743                QueryPos qPos = QueryPos.getInstance(q);
1744
1745                qPos.add(groupId);
1746
1747                qPos.add(userId);
1748
1749                list = q.list();
1750            }
1751            catch (Exception e) {
1752                throw processException(e);
1753            }
1754            finally {
1755                if (list == null) {
1756                    list = new ArrayList<DLFileEntry>();
1757                }
1758
1759                cacheResult(list);
1760
1761                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1762                    list);
1763
1764                closeSession(session);
1765            }
1766        }
1767
1768        return list;
1769    }
1770
1771    public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
1772        int end) throws SystemException {
1773        return findByG_U(groupId, userId, start, end, null);
1774    }
1775
1776    public List<DLFileEntry> findByG_U(long groupId, long userId, int start,
1777        int end, OrderByComparator obc) throws SystemException {
1778        Object[] finderArgs = new Object[] {
1779                new Long(groupId), new Long(userId),
1780                
1781                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1782            };
1783
1784        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_U,
1785                finderArgs, this);
1786
1787        if (list == null) {
1788            Session session = null;
1789
1790            try {
1791                session = openSession();
1792
1793                StringBuilder query = new StringBuilder();
1794
1795                query.append(
1796                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1797
1798                query.append("dlFileEntry.groupId = ?");
1799
1800                query.append(" AND ");
1801
1802                query.append("dlFileEntry.userId = ?");
1803
1804                query.append(" ");
1805
1806                if (obc != null) {
1807                    query.append("ORDER BY ");
1808
1809                    String[] orderByFields = obc.getOrderByFields();
1810
1811                    for (int i = 0; i < orderByFields.length; i++) {
1812                        query.append("dlFileEntry.");
1813                        query.append(orderByFields[i]);
1814
1815                        if (obc.isAscending()) {
1816                            query.append(" ASC");
1817                        }
1818                        else {
1819                            query.append(" DESC");
1820                        }
1821
1822                        if ((i + 1) < orderByFields.length) {
1823                            query.append(", ");
1824                        }
1825                    }
1826                }
1827
1828                else {
1829                    query.append("ORDER BY ");
1830
1831                    query.append("dlFileEntry.folderId ASC, ");
1832                    query.append("dlFileEntry.name ASC");
1833                }
1834
1835                Query q = session.createQuery(query.toString());
1836
1837                QueryPos qPos = QueryPos.getInstance(q);
1838
1839                qPos.add(groupId);
1840
1841                qPos.add(userId);
1842
1843                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
1844                        start, end);
1845            }
1846            catch (Exception e) {
1847                throw processException(e);
1848            }
1849            finally {
1850                if (list == null) {
1851                    list = new ArrayList<DLFileEntry>();
1852                }
1853
1854                cacheResult(list);
1855
1856                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_U,
1857                    finderArgs, list);
1858
1859                closeSession(session);
1860            }
1861        }
1862
1863        return list;
1864    }
1865
1866    public DLFileEntry findByG_U_First(long groupId, long userId,
1867        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1868        List<DLFileEntry> list = findByG_U(groupId, userId, 0, 1, obc);
1869
1870        if (list.isEmpty()) {
1871            StringBuilder msg = new StringBuilder();
1872
1873            msg.append("No DLFileEntry exists with the key {");
1874
1875            msg.append("groupId=" + groupId);
1876
1877            msg.append(", ");
1878            msg.append("userId=" + userId);
1879
1880            msg.append(StringPool.CLOSE_CURLY_BRACE);
1881
1882            throw new NoSuchFileEntryException(msg.toString());
1883        }
1884        else {
1885            return list.get(0);
1886        }
1887    }
1888
1889    public DLFileEntry findByG_U_Last(long groupId, long userId,
1890        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
1891        int count = countByG_U(groupId, userId);
1892
1893        List<DLFileEntry> list = findByG_U(groupId, userId, count - 1, count,
1894                obc);
1895
1896        if (list.isEmpty()) {
1897            StringBuilder msg = new StringBuilder();
1898
1899            msg.append("No DLFileEntry exists with the key {");
1900
1901            msg.append("groupId=" + groupId);
1902
1903            msg.append(", ");
1904            msg.append("userId=" + userId);
1905
1906            msg.append(StringPool.CLOSE_CURLY_BRACE);
1907
1908            throw new NoSuchFileEntryException(msg.toString());
1909        }
1910        else {
1911            return list.get(0);
1912        }
1913    }
1914
1915    public DLFileEntry[] findByG_U_PrevAndNext(long fileEntryId, long groupId,
1916        long userId, OrderByComparator obc)
1917        throws NoSuchFileEntryException, SystemException {
1918        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
1919
1920        int count = countByG_U(groupId, userId);
1921
1922        Session session = null;
1923
1924        try {
1925            session = openSession();
1926
1927            StringBuilder query = new StringBuilder();
1928
1929            query.append(
1930                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
1931
1932            query.append("dlFileEntry.groupId = ?");
1933
1934            query.append(" AND ");
1935
1936            query.append("dlFileEntry.userId = ?");
1937
1938            query.append(" ");
1939
1940            if (obc != null) {
1941                query.append("ORDER BY ");
1942
1943                String[] orderByFields = obc.getOrderByFields();
1944
1945                for (int i = 0; i < orderByFields.length; i++) {
1946                    query.append("dlFileEntry.");
1947                    query.append(orderByFields[i]);
1948
1949                    if (obc.isAscending()) {
1950                        query.append(" ASC");
1951                    }
1952                    else {
1953                        query.append(" DESC");
1954                    }
1955
1956                    if ((i + 1) < orderByFields.length) {
1957                        query.append(", ");
1958                    }
1959                }
1960            }
1961
1962            else {
1963                query.append("ORDER BY ");
1964
1965                query.append("dlFileEntry.folderId ASC, ");
1966                query.append("dlFileEntry.name ASC");
1967            }
1968
1969            Query q = session.createQuery(query.toString());
1970
1971            QueryPos qPos = QueryPos.getInstance(q);
1972
1973            qPos.add(groupId);
1974
1975            qPos.add(userId);
1976
1977            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1978                    dlFileEntry);
1979
1980            DLFileEntry[] array = new DLFileEntryImpl[3];
1981
1982            array[0] = (DLFileEntry)objArray[0];
1983            array[1] = (DLFileEntry)objArray[1];
1984            array[2] = (DLFileEntry)objArray[2];
1985
1986            return array;
1987        }
1988        catch (Exception e) {
1989            throw processException(e);
1990        }
1991        finally {
1992            closeSession(session);
1993        }
1994    }
1995
1996    public DLFileEntry findByF_N(long folderId, String name)
1997        throws NoSuchFileEntryException, SystemException {
1998        DLFileEntry dlFileEntry = fetchByF_N(folderId, name);
1999
2000        if (dlFileEntry == null) {
2001            StringBuilder msg = new StringBuilder();
2002
2003            msg.append("No DLFileEntry exists with the key {");
2004
2005            msg.append("folderId=" + folderId);
2006
2007            msg.append(", ");
2008            msg.append("name=" + name);
2009
2010            msg.append(StringPool.CLOSE_CURLY_BRACE);
2011
2012            if (_log.isWarnEnabled()) {
2013                _log.warn(msg.toString());
2014            }
2015
2016            throw new NoSuchFileEntryException(msg.toString());
2017        }
2018
2019        return dlFileEntry;
2020    }
2021
2022    public DLFileEntry fetchByF_N(long folderId, String name)
2023        throws SystemException {
2024        return fetchByF_N(folderId, name, true);
2025    }
2026
2027    public DLFileEntry fetchByF_N(long folderId, String name,
2028        boolean retrieveFromCache) throws SystemException {
2029        Object[] finderArgs = new Object[] { new Long(folderId), name };
2030
2031        Object result = null;
2032
2033        if (retrieveFromCache) {
2034            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_F_N,
2035                    finderArgs, this);
2036        }
2037
2038        if (result == null) {
2039            Session session = null;
2040
2041            try {
2042                session = openSession();
2043
2044                StringBuilder query = new StringBuilder();
2045
2046                query.append(
2047                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2048
2049                query.append("dlFileEntry.folderId = ?");
2050
2051                query.append(" AND ");
2052
2053                if (name == null) {
2054                    query.append("dlFileEntry.name IS NULL");
2055                }
2056                else {
2057                    query.append("dlFileEntry.name = ?");
2058                }
2059
2060                query.append(" ");
2061
2062                query.append("ORDER BY ");
2063
2064                query.append("dlFileEntry.folderId ASC, ");
2065                query.append("dlFileEntry.name ASC");
2066
2067                Query q = session.createQuery(query.toString());
2068
2069                QueryPos qPos = QueryPos.getInstance(q);
2070
2071                qPos.add(folderId);
2072
2073                if (name != null) {
2074                    qPos.add(name);
2075                }
2076
2077                List<DLFileEntry> list = q.list();
2078
2079                result = list;
2080
2081                DLFileEntry dlFileEntry = null;
2082
2083                if (list.isEmpty()) {
2084                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2085                        finderArgs, list);
2086                }
2087                else {
2088                    dlFileEntry = list.get(0);
2089
2090                    cacheResult(dlFileEntry);
2091
2092                    if ((dlFileEntry.getFolderId() != folderId) ||
2093                            (dlFileEntry.getName() == null) ||
2094                            !dlFileEntry.getName().equals(name)) {
2095                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2096                            finderArgs, dlFileEntry);
2097                    }
2098                }
2099
2100                return dlFileEntry;
2101            }
2102            catch (Exception e) {
2103                throw processException(e);
2104            }
2105            finally {
2106                if (result == null) {
2107                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_F_N,
2108                        finderArgs, new ArrayList<DLFileEntry>());
2109                }
2110
2111                closeSession(session);
2112            }
2113        }
2114        else {
2115            if (result instanceof List<?>) {
2116                return null;
2117            }
2118            else {
2119                return (DLFileEntry)result;
2120            }
2121        }
2122    }
2123
2124    public List<DLFileEntry> findByF_T(long folderId, String title)
2125        throws SystemException {
2126        Object[] finderArgs = new Object[] { new Long(folderId), title };
2127
2128        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_F_T,
2129                finderArgs, this);
2130
2131        if (list == null) {
2132            Session session = null;
2133
2134            try {
2135                session = openSession();
2136
2137                StringBuilder query = new StringBuilder();
2138
2139                query.append(
2140                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2141
2142                query.append("dlFileEntry.folderId = ?");
2143
2144                query.append(" AND ");
2145
2146                if (title == null) {
2147                    query.append("dlFileEntry.title IS NULL");
2148                }
2149                else {
2150                    query.append("dlFileEntry.title = ?");
2151                }
2152
2153                query.append(" ");
2154
2155                query.append("ORDER BY ");
2156
2157                query.append("dlFileEntry.folderId ASC, ");
2158                query.append("dlFileEntry.name ASC");
2159
2160                Query q = session.createQuery(query.toString());
2161
2162                QueryPos qPos = QueryPos.getInstance(q);
2163
2164                qPos.add(folderId);
2165
2166                if (title != null) {
2167                    qPos.add(title);
2168                }
2169
2170                list = q.list();
2171            }
2172            catch (Exception e) {
2173                throw processException(e);
2174            }
2175            finally {
2176                if (list == null) {
2177                    list = new ArrayList<DLFileEntry>();
2178                }
2179
2180                cacheResult(list);
2181
2182                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_F_T, finderArgs,
2183                    list);
2184
2185                closeSession(session);
2186            }
2187        }
2188
2189        return list;
2190    }
2191
2192    public List<DLFileEntry> findByF_T(long folderId, String title, int start,
2193        int end) throws SystemException {
2194        return findByF_T(folderId, title, start, end, null);
2195    }
2196
2197    public List<DLFileEntry> findByF_T(long folderId, String title, int start,
2198        int end, OrderByComparator obc) throws SystemException {
2199        Object[] finderArgs = new Object[] {
2200                new Long(folderId),
2201                
2202                title,
2203                
2204                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2205            };
2206
2207        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_F_T,
2208                finderArgs, this);
2209
2210        if (list == null) {
2211            Session session = null;
2212
2213            try {
2214                session = openSession();
2215
2216                StringBuilder query = new StringBuilder();
2217
2218                query.append(
2219                    "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2220
2221                query.append("dlFileEntry.folderId = ?");
2222
2223                query.append(" AND ");
2224
2225                if (title == null) {
2226                    query.append("dlFileEntry.title IS NULL");
2227                }
2228                else {
2229                    query.append("dlFileEntry.title = ?");
2230                }
2231
2232                query.append(" ");
2233
2234                if (obc != null) {
2235                    query.append("ORDER BY ");
2236
2237                    String[] orderByFields = obc.getOrderByFields();
2238
2239                    for (int i = 0; i < orderByFields.length; i++) {
2240                        query.append("dlFileEntry.");
2241                        query.append(orderByFields[i]);
2242
2243                        if (obc.isAscending()) {
2244                            query.append(" ASC");
2245                        }
2246                        else {
2247                            query.append(" DESC");
2248                        }
2249
2250                        if ((i + 1) < orderByFields.length) {
2251                            query.append(", ");
2252                        }
2253                    }
2254                }
2255
2256                else {
2257                    query.append("ORDER BY ");
2258
2259                    query.append("dlFileEntry.folderId ASC, ");
2260                    query.append("dlFileEntry.name ASC");
2261                }
2262
2263                Query q = session.createQuery(query.toString());
2264
2265                QueryPos qPos = QueryPos.getInstance(q);
2266
2267                qPos.add(folderId);
2268
2269                if (title != null) {
2270                    qPos.add(title);
2271                }
2272
2273                list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2274                        start, end);
2275            }
2276            catch (Exception e) {
2277                throw processException(e);
2278            }
2279            finally {
2280                if (list == null) {
2281                    list = new ArrayList<DLFileEntry>();
2282                }
2283
2284                cacheResult(list);
2285
2286                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_F_T,
2287                    finderArgs, list);
2288
2289                closeSession(session);
2290            }
2291        }
2292
2293        return list;
2294    }
2295
2296    public DLFileEntry findByF_T_First(long folderId, String title,
2297        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
2298        List<DLFileEntry> list = findByF_T(folderId, title, 0, 1, obc);
2299
2300        if (list.isEmpty()) {
2301            StringBuilder msg = new StringBuilder();
2302
2303            msg.append("No DLFileEntry exists with the key {");
2304
2305            msg.append("folderId=" + folderId);
2306
2307            msg.append(", ");
2308            msg.append("title=" + title);
2309
2310            msg.append(StringPool.CLOSE_CURLY_BRACE);
2311
2312            throw new NoSuchFileEntryException(msg.toString());
2313        }
2314        else {
2315            return list.get(0);
2316        }
2317    }
2318
2319    public DLFileEntry findByF_T_Last(long folderId, String title,
2320        OrderByComparator obc) throws NoSuchFileEntryException, SystemException {
2321        int count = countByF_T(folderId, title);
2322
2323        List<DLFileEntry> list = findByF_T(folderId, title, count - 1, count,
2324                obc);
2325
2326        if (list.isEmpty()) {
2327            StringBuilder msg = new StringBuilder();
2328
2329            msg.append("No DLFileEntry exists with the key {");
2330
2331            msg.append("folderId=" + folderId);
2332
2333            msg.append(", ");
2334            msg.append("title=" + title);
2335
2336            msg.append(StringPool.CLOSE_CURLY_BRACE);
2337
2338            throw new NoSuchFileEntryException(msg.toString());
2339        }
2340        else {
2341            return list.get(0);
2342        }
2343    }
2344
2345    public DLFileEntry[] findByF_T_PrevAndNext(long fileEntryId, long folderId,
2346        String title, OrderByComparator obc)
2347        throws NoSuchFileEntryException, SystemException {
2348        DLFileEntry dlFileEntry = findByPrimaryKey(fileEntryId);
2349
2350        int count = countByF_T(folderId, title);
2351
2352        Session session = null;
2353
2354        try {
2355            session = openSession();
2356
2357            StringBuilder query = new StringBuilder();
2358
2359            query.append(
2360                "SELECT dlFileEntry FROM DLFileEntry dlFileEntry WHERE ");
2361
2362            query.append("dlFileEntry.folderId = ?");
2363
2364            query.append(" AND ");
2365
2366            if (title == null) {
2367                query.append("dlFileEntry.title IS NULL");
2368            }
2369            else {
2370                query.append("dlFileEntry.title = ?");
2371            }
2372
2373            query.append(" ");
2374
2375            if (obc != null) {
2376                query.append("ORDER BY ");
2377
2378                String[] orderByFields = obc.getOrderByFields();
2379
2380                for (int i = 0; i < orderByFields.length; i++) {
2381                    query.append("dlFileEntry.");
2382                    query.append(orderByFields[i]);
2383
2384                    if (obc.isAscending()) {
2385                        query.append(" ASC");
2386                    }
2387                    else {
2388                        query.append(" DESC");
2389                    }
2390
2391                    if ((i + 1) < orderByFields.length) {
2392                        query.append(", ");
2393                    }
2394                }
2395            }
2396
2397            else {
2398                query.append("ORDER BY ");
2399
2400                query.append("dlFileEntry.folderId ASC, ");
2401                query.append("dlFileEntry.name ASC");
2402            }
2403
2404            Query q = session.createQuery(query.toString());
2405
2406            QueryPos qPos = QueryPos.getInstance(q);
2407
2408            qPos.add(folderId);
2409
2410            if (title != null) {
2411                qPos.add(title);
2412            }
2413
2414            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2415                    dlFileEntry);
2416
2417            DLFileEntry[] array = new DLFileEntryImpl[3];
2418
2419            array[0] = (DLFileEntry)objArray[0];
2420            array[1] = (DLFileEntry)objArray[1];
2421            array[2] = (DLFileEntry)objArray[2];
2422
2423            return array;
2424        }
2425        catch (Exception e) {
2426            throw processException(e);
2427        }
2428        finally {
2429            closeSession(session);
2430        }
2431    }
2432
2433    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2434        throws SystemException {
2435        Session session = null;
2436
2437        try {
2438            session = openSession();
2439
2440            dynamicQuery.compile(session);
2441
2442            return dynamicQuery.list();
2443        }
2444        catch (Exception e) {
2445            throw processException(e);
2446        }
2447        finally {
2448            closeSession(session);
2449        }
2450    }
2451
2452    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2453        int start, int end) throws SystemException {
2454        Session session = null;
2455
2456        try {
2457            session = openSession();
2458
2459            dynamicQuery.setLimit(start, end);
2460
2461            dynamicQuery.compile(session);
2462
2463            return dynamicQuery.list();
2464        }
2465        catch (Exception e) {
2466            throw processException(e);
2467        }
2468        finally {
2469            closeSession(session);
2470        }
2471    }
2472
2473    public List<DLFileEntry> findAll() throws SystemException {
2474        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2475    }
2476
2477    public List<DLFileEntry> findAll(int start, int end)
2478        throws SystemException {
2479        return findAll(start, end, null);
2480    }
2481
2482    public List<DLFileEntry> findAll(int start, int end, OrderByComparator obc)
2483        throws SystemException {
2484        Object[] finderArgs = new Object[] {
2485                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2486            };
2487
2488        List<DLFileEntry> list = (List<DLFileEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2489                finderArgs, this);
2490
2491        if (list == null) {
2492            Session session = null;
2493
2494            try {
2495                session = openSession();
2496
2497                StringBuilder query = new StringBuilder();
2498
2499                query.append("SELECT dlFileEntry FROM DLFileEntry dlFileEntry ");
2500
2501                if (obc != null) {
2502                    query.append("ORDER BY ");
2503
2504                    String[] orderByFields = obc.getOrderByFields();
2505
2506                    for (int i = 0; i < orderByFields.length; i++) {
2507                        query.append("dlFileEntry.");
2508                        query.append(orderByFields[i]);
2509
2510                        if (obc.isAscending()) {
2511                            query.append(" ASC");
2512                        }
2513                        else {
2514                            query.append(" DESC");
2515                        }
2516
2517                        if ((i + 1) < orderByFields.length) {
2518                            query.append(", ");
2519                        }
2520                    }
2521                }
2522
2523                else {
2524                    query.append("ORDER BY ");
2525
2526                    query.append("dlFileEntry.folderId ASC, ");
2527                    query.append("dlFileEntry.name ASC");
2528                }
2529
2530                Query q = session.createQuery(query.toString());
2531
2532                if (obc == null) {
2533                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2534                            start, end, false);
2535
2536                    Collections.sort(list);
2537                }
2538                else {
2539                    list = (List<DLFileEntry>)QueryUtil.list(q, getDialect(),
2540                            start, end);
2541                }
2542            }
2543            catch (Exception e) {
2544                throw processException(e);
2545            }
2546            finally {
2547                if (list == null) {
2548                    list = new ArrayList<DLFileEntry>();
2549                }
2550
2551                cacheResult(list);
2552
2553                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2554
2555                closeSession(session);
2556            }
2557        }
2558
2559        return list;
2560    }
2561
2562    public void removeByUuid(String uuid) throws SystemException {
2563        for (DLFileEntry dlFileEntry : findByUuid(uuid)) {
2564            remove(dlFileEntry);
2565        }
2566    }
2567
2568    public void removeByUUID_G(String uuid, long groupId)
2569        throws NoSuchFileEntryException, SystemException {
2570        DLFileEntry dlFileEntry = findByUUID_G(uuid, groupId);
2571
2572        remove(dlFileEntry);
2573    }
2574
2575    public void removeByGroupId(long groupId) throws SystemException {
2576        for (DLFileEntry dlFileEntry : findByGroupId(groupId)) {
2577            remove(dlFileEntry);
2578        }
2579    }
2580
2581    public void removeByCompanyId(long companyId) throws SystemException {
2582        for (DLFileEntry dlFileEntry : findByCompanyId(companyId)) {
2583            remove(dlFileEntry);
2584        }
2585    }
2586
2587    public void removeByFolderId(long folderId) throws SystemException {
2588        for (DLFileEntry dlFileEntry : findByFolderId(folderId)) {
2589            remove(dlFileEntry);
2590        }
2591    }
2592
2593    public void removeByG_U(long groupId, long userId)
2594        throws SystemException {
2595        for (DLFileEntry dlFileEntry : findByG_U(groupId, userId)) {
2596            remove(dlFileEntry);
2597        }
2598    }
2599
2600    public void removeByF_N(long folderId, String name)
2601        throws NoSuchFileEntryException, SystemException {
2602        DLFileEntry dlFileEntry = findByF_N(folderId, name);
2603
2604        remove(dlFileEntry);
2605    }
2606
2607    public void removeByF_T(long folderId, String title)
2608        throws SystemException {
2609        for (DLFileEntry dlFileEntry : findByF_T(folderId, title)) {
2610            remove(dlFileEntry);
2611        }
2612    }
2613
2614    public void removeAll() throws SystemException {
2615        for (DLFileEntry dlFileEntry : findAll()) {
2616            remove(dlFileEntry);
2617        }
2618    }
2619
2620    public int countByUuid(String uuid) throws SystemException {
2621        Object[] finderArgs = new Object[] { uuid };
2622
2623        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2624                finderArgs, this);
2625
2626        if (count == null) {
2627            Session session = null;
2628
2629            try {
2630                session = openSession();
2631
2632                StringBuilder query = new StringBuilder();
2633
2634                query.append("SELECT COUNT(dlFileEntry) ");
2635                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2636
2637                if (uuid == null) {
2638                    query.append("dlFileEntry.uuid IS NULL");
2639                }
2640                else {
2641                    query.append("dlFileEntry.uuid = ?");
2642                }
2643
2644                query.append(" ");
2645
2646                Query q = session.createQuery(query.toString());
2647
2648                QueryPos qPos = QueryPos.getInstance(q);
2649
2650                if (uuid != null) {
2651                    qPos.add(uuid);
2652                }
2653
2654                count = (Long)q.uniqueResult();
2655            }
2656            catch (Exception e) {
2657                throw processException(e);
2658            }
2659            finally {
2660                if (count == null) {
2661                    count = Long.valueOf(0);
2662                }
2663
2664                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2665                    finderArgs, count);
2666
2667                closeSession(session);
2668            }
2669        }
2670
2671        return count.intValue();
2672    }
2673
2674    public int countByUUID_G(String uuid, long groupId)
2675        throws SystemException {
2676        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
2677
2678        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2679                finderArgs, this);
2680
2681        if (count == null) {
2682            Session session = null;
2683
2684            try {
2685                session = openSession();
2686
2687                StringBuilder query = new StringBuilder();
2688
2689                query.append("SELECT COUNT(dlFileEntry) ");
2690                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2691
2692                if (uuid == null) {
2693                    query.append("dlFileEntry.uuid IS NULL");
2694                }
2695                else {
2696                    query.append("dlFileEntry.uuid = ?");
2697                }
2698
2699                query.append(" AND ");
2700
2701                query.append("dlFileEntry.groupId = ?");
2702
2703                query.append(" ");
2704
2705                Query q = session.createQuery(query.toString());
2706
2707                QueryPos qPos = QueryPos.getInstance(q);
2708
2709                if (uuid != null) {
2710                    qPos.add(uuid);
2711                }
2712
2713                qPos.add(groupId);
2714
2715                count = (Long)q.uniqueResult();
2716            }
2717            catch (Exception e) {
2718                throw processException(e);
2719            }
2720            finally {
2721                if (count == null) {
2722                    count = Long.valueOf(0);
2723                }
2724
2725                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2726                    finderArgs, count);
2727
2728                closeSession(session);
2729            }
2730        }
2731
2732        return count.intValue();
2733    }
2734
2735    public int countByGroupId(long groupId) throws SystemException {
2736        Object[] finderArgs = new Object[] { new Long(groupId) };
2737
2738        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2739                finderArgs, this);
2740
2741        if (count == null) {
2742            Session session = null;
2743
2744            try {
2745                session = openSession();
2746
2747                StringBuilder query = new StringBuilder();
2748
2749                query.append("SELECT COUNT(dlFileEntry) ");
2750                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2751
2752                query.append("dlFileEntry.groupId = ?");
2753
2754                query.append(" ");
2755
2756                Query q = session.createQuery(query.toString());
2757
2758                QueryPos qPos = QueryPos.getInstance(q);
2759
2760                qPos.add(groupId);
2761
2762                count = (Long)q.uniqueResult();
2763            }
2764            catch (Exception e) {
2765                throw processException(e);
2766            }
2767            finally {
2768                if (count == null) {
2769                    count = Long.valueOf(0);
2770                }
2771
2772                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2773                    finderArgs, count);
2774
2775                closeSession(session);
2776            }
2777        }
2778
2779        return count.intValue();
2780    }
2781
2782    public int countByCompanyId(long companyId) throws SystemException {
2783        Object[] finderArgs = new Object[] { new Long(companyId) };
2784
2785        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2786                finderArgs, this);
2787
2788        if (count == null) {
2789            Session session = null;
2790
2791            try {
2792                session = openSession();
2793
2794                StringBuilder query = new StringBuilder();
2795
2796                query.append("SELECT COUNT(dlFileEntry) ");
2797                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2798
2799                query.append("dlFileEntry.companyId = ?");
2800
2801                query.append(" ");
2802
2803                Query q = session.createQuery(query.toString());
2804
2805                QueryPos qPos = QueryPos.getInstance(q);
2806
2807                qPos.add(companyId);
2808
2809                count = (Long)q.uniqueResult();
2810            }
2811            catch (Exception e) {
2812                throw processException(e);
2813            }
2814            finally {
2815                if (count == null) {
2816                    count = Long.valueOf(0);
2817                }
2818
2819                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2820                    finderArgs, count);
2821
2822                closeSession(session);
2823            }
2824        }
2825
2826        return count.intValue();
2827    }
2828
2829    public int countByFolderId(long folderId) throws SystemException {
2830        Object[] finderArgs = new Object[] { new Long(folderId) };
2831
2832        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FOLDERID,
2833                finderArgs, this);
2834
2835        if (count == null) {
2836            Session session = null;
2837
2838            try {
2839                session = openSession();
2840
2841                StringBuilder query = new StringBuilder();
2842
2843                query.append("SELECT COUNT(dlFileEntry) ");
2844                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2845
2846                query.append("dlFileEntry.folderId = ?");
2847
2848                query.append(" ");
2849
2850                Query q = session.createQuery(query.toString());
2851
2852                QueryPos qPos = QueryPos.getInstance(q);
2853
2854                qPos.add(folderId);
2855
2856                count = (Long)q.uniqueResult();
2857            }
2858            catch (Exception e) {
2859                throw processException(e);
2860            }
2861            finally {
2862                if (count == null) {
2863                    count = Long.valueOf(0);
2864                }
2865
2866                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FOLDERID,
2867                    finderArgs, count);
2868
2869                closeSession(session);
2870            }
2871        }
2872
2873        return count.intValue();
2874    }
2875
2876    public int countByG_U(long groupId, long userId) throws SystemException {
2877        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
2878
2879        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2880                finderArgs, this);
2881
2882        if (count == null) {
2883            Session session = null;
2884
2885            try {
2886                session = openSession();
2887
2888                StringBuilder query = new StringBuilder();
2889
2890                query.append("SELECT COUNT(dlFileEntry) ");
2891                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2892
2893                query.append("dlFileEntry.groupId = ?");
2894
2895                query.append(" AND ");
2896
2897                query.append("dlFileEntry.userId = ?");
2898
2899                query.append(" ");
2900
2901                Query q = session.createQuery(query.toString());
2902
2903                QueryPos qPos = QueryPos.getInstance(q);
2904
2905                qPos.add(groupId);
2906
2907                qPos.add(userId);
2908
2909                count = (Long)q.uniqueResult();
2910            }
2911            catch (Exception e) {
2912                throw processException(e);
2913            }
2914            finally {
2915                if (count == null) {
2916                    count = Long.valueOf(0);
2917                }
2918
2919                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2920                    count);
2921
2922                closeSession(session);
2923            }
2924        }
2925
2926        return count.intValue();
2927    }
2928
2929    public int countByF_N(long folderId, String name) throws SystemException {
2930        Object[] finderArgs = new Object[] { new Long(folderId), name };
2931
2932        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_N,
2933                finderArgs, this);
2934
2935        if (count == null) {
2936            Session session = null;
2937
2938            try {
2939                session = openSession();
2940
2941                StringBuilder query = new StringBuilder();
2942
2943                query.append("SELECT COUNT(dlFileEntry) ");
2944                query.append("FROM DLFileEntry dlFileEntry WHERE ");
2945
2946                query.append("dlFileEntry.folderId = ?");
2947
2948                query.append(" AND ");
2949
2950                if (name == null) {
2951                    query.append("dlFileEntry.name IS NULL");
2952                }
2953                else {
2954                    query.append("dlFileEntry.name = ?");
2955                }
2956
2957                query.append(" ");
2958
2959                Query q = session.createQuery(query.toString());
2960
2961                QueryPos qPos = QueryPos.getInstance(q);
2962
2963                qPos.add(folderId);
2964
2965                if (name != null) {
2966                    qPos.add(name);
2967                }
2968
2969                count = (Long)q.uniqueResult();
2970            }
2971            catch (Exception e) {
2972                throw processException(e);
2973            }
2974            finally {
2975                if (count == null) {
2976                    count = Long.valueOf(0);
2977                }
2978
2979                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_N, finderArgs,
2980                    count);
2981
2982                closeSession(session);
2983            }
2984        }
2985
2986        return count.intValue();
2987    }
2988
2989    public int countByF_T(long folderId, String title)
2990        throws SystemException {
2991        Object[] finderArgs = new Object[] { new Long(folderId), title };
2992
2993        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_F_T,
2994                finderArgs, this);
2995
2996        if (count == null) {
2997            Session session = null;
2998
2999            try {
3000                session = openSession();
3001
3002                StringBuilder query = new StringBuilder();
3003
3004                query.append("SELECT COUNT(dlFileEntry) ");
3005                query.append("FROM DLFileEntry dlFileEntry WHERE ");
3006
3007                query.append("dlFileEntry.folderId = ?");
3008
3009                query.append(" AND ");
3010
3011                if (title == null) {
3012                    query.append("dlFileEntry.title IS NULL");
3013                }
3014                else {
3015                    query.append("dlFileEntry.title = ?");
3016                }
3017
3018                query.append(" ");
3019
3020                Query q = session.createQuery(query.toString());
3021
3022                QueryPos qPos = QueryPos.getInstance(q);
3023
3024                qPos.add(folderId);
3025
3026                if (title != null) {
3027                    qPos.add(title);
3028                }
3029
3030                count = (Long)q.uniqueResult();
3031            }
3032            catch (Exception e) {
3033                throw processException(e);
3034            }
3035            finally {
3036                if (count == null) {
3037                    count = Long.valueOf(0);
3038                }
3039
3040                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_F_T, finderArgs,
3041                    count);
3042
3043                closeSession(session);
3044            }
3045        }
3046
3047        return count.intValue();
3048    }
3049
3050    public int countAll() throws SystemException {
3051        Object[] finderArgs = new Object[0];
3052
3053        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3054                finderArgs, this);
3055
3056        if (count == null) {
3057            Session session = null;
3058
3059            try {
3060                session = openSession();
3061
3062                Query q = session.createQuery(
3063                        "SELECT COUNT(dlFileEntry) FROM DLFileEntry dlFileEntry");
3064
3065                count = (Long)q.uniqueResult();
3066            }
3067            catch (Exception e) {
3068                throw processException(e);
3069            }
3070            finally {
3071                if (count == null) {
3072                    count = Long.valueOf(0);
3073                }
3074
3075                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3076                    count);
3077
3078                closeSession(session);
3079            }
3080        }
3081
3082        return count.intValue();
3083    }
3084
3085    public void afterPropertiesSet() {
3086        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3087                    com.liferay.portal.util.PropsUtil.get(
3088                        "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntry")));
3089
3090        if (listenerClassNames.length > 0) {
3091            try {
3092                List<ModelListener<DLFileEntry>> listenersList = new ArrayList<ModelListener<DLFileEntry>>();
3093
3094                for (String listenerClassName : listenerClassNames) {
3095                    listenersList.add((ModelListener<DLFileEntry>)Class.forName(
3096                            listenerClassName).newInstance());
3097                }
3098
3099                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3100            }
3101            catch (Exception e) {
3102                _log.error(e);
3103            }
3104        }
3105    }
3106
3107    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence.impl")
3108    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryPersistence dlFileEntryPersistence;
3109    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence.impl")
3110    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence dlFileRankPersistence;
3111    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence.impl")
3112    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileShortcutPersistence dlFileShortcutPersistence;
3113    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence.impl")
3114    protected com.liferay.portlet.documentlibrary.service.persistence.DLFileVersionPersistence dlFileVersionPersistence;
3115    @BeanReference(name = "com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence.impl")
3116    protected com.liferay.portlet.documentlibrary.service.persistence.DLFolderPersistence dlFolderPersistence;
3117    @BeanReference(name = "com.liferay.portal.service.persistence.LockPersistence.impl")
3118    protected com.liferay.portal.service.persistence.LockPersistence lockPersistence;
3119    @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
3120    protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
3121    @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
3122    protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
3123    @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
3124    protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
3125    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence.impl")
3126    protected com.liferay.portlet.messageboards.service.persistence.MBDiscussionPersistence mbDiscussionPersistence;
3127    @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence.impl")
3128    protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
3129    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence.impl")
3130    protected com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence ratingsEntryPersistence;
3131    @BeanReference(name = "com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence.impl")
3132    protected com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence ratingsStatsPersistence;
3133    @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence.impl")
3134    protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
3135    @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence.impl")
3136    protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
3137    private static Log _log = LogFactoryUtil.getLog(DLFileEntryPersistenceImpl.class);
3138}