1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.imagegallery.service.persistence;
16  
17  import com.liferay.portal.NoSuchModelException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.cache.CacheRegistry;
21  import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
22  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
23  import com.liferay.portal.kernel.dao.orm.FinderPath;
24  import com.liferay.portal.kernel.dao.orm.Query;
25  import com.liferay.portal.kernel.dao.orm.QueryPos;
26  import com.liferay.portal.kernel.dao.orm.QueryUtil;
27  import com.liferay.portal.kernel.dao.orm.Session;
28  import com.liferay.portal.kernel.log.Log;
29  import com.liferay.portal.kernel.log.LogFactoryUtil;
30  import com.liferay.portal.kernel.util.GetterUtil;
31  import com.liferay.portal.kernel.util.OrderByComparator;
32  import com.liferay.portal.kernel.util.StringBundler;
33  import com.liferay.portal.kernel.util.StringPool;
34  import com.liferay.portal.kernel.util.StringUtil;
35  import com.liferay.portal.kernel.util.Validator;
36  import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
37  import com.liferay.portal.model.ModelListener;
38  import com.liferay.portal.service.persistence.BatchSessionUtil;
39  import com.liferay.portal.service.persistence.GroupPersistence;
40  import com.liferay.portal.service.persistence.ImagePersistence;
41  import com.liferay.portal.service.persistence.LayoutPersistence;
42  import com.liferay.portal.service.persistence.ResourcePersistence;
43  import com.liferay.portal.service.persistence.UserPersistence;
44  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45  
46  import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
47  import com.liferay.portlet.imagegallery.NoSuchFolderException;
48  import com.liferay.portlet.imagegallery.model.IGFolder;
49  import com.liferay.portlet.imagegallery.model.impl.IGFolderImpl;
50  import com.liferay.portlet.imagegallery.model.impl.IGFolderModelImpl;
51  
52  import java.io.Serializable;
53  
54  import java.util.ArrayList;
55  import java.util.Collections;
56  import java.util.List;
57  
58  /**
59   * <a href="IGFolderPersistenceImpl.java.html"><b><i>View Source</i></b></a>
60   *
61   * <p>
62   * ServiceBuilder generated this class. Modifications in this class will be
63   * overwritten the next time is generated.
64   * </p>
65   *
66   * @author    Brian Wing Shun Chan
67   * @see       IGFolderPersistence
68   * @see       IGFolderUtil
69   * @generated
70   */
71  public class IGFolderPersistenceImpl extends BasePersistenceImpl<IGFolder>
72      implements IGFolderPersistence {
73      public static final String FINDER_CLASS_NAME_ENTITY = IGFolderImpl.class.getName();
74      public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
75          ".List";
76      public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
77              IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
78              "findByUuid", new String[] { String.class.getName() });
79      public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
80              IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
81              "findByUuid",
82              new String[] {
83                  String.class.getName(),
84                  
85              "java.lang.Integer", "java.lang.Integer",
86                  "com.liferay.portal.kernel.util.OrderByComparator"
87              });
88      public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
89              IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
90              "countByUuid", new String[] { String.class.getName() });
91      public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
92              IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
93              "fetchByUUID_G",
94              new String[] { String.class.getName(), Long.class.getName() });
95      public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
96              IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
97              "countByUUID_G",
98              new String[] { String.class.getName(), Long.class.getName() });
99      public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
100             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
101             "findByGroupId", new String[] { Long.class.getName() });
102     public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
103             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
104             "findByGroupId",
105             new String[] {
106                 Long.class.getName(),
107                 
108             "java.lang.Integer", "java.lang.Integer",
109                 "com.liferay.portal.kernel.util.OrderByComparator"
110             });
111     public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
112             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113             "countByGroupId", new String[] { Long.class.getName() });
114     public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
115             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
116             "findByCompanyId", new String[] { Long.class.getName() });
117     public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
118             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
119             "findByCompanyId",
120             new String[] {
121                 Long.class.getName(),
122                 
123             "java.lang.Integer", "java.lang.Integer",
124                 "com.liferay.portal.kernel.util.OrderByComparator"
125             });
126     public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
127             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
128             "countByCompanyId", new String[] { Long.class.getName() });
129     public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
130             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
131             "findByG_P",
132             new String[] { Long.class.getName(), Long.class.getName() });
133     public static final FinderPath FINDER_PATH_FIND_BY_OBC_G_P = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
134             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135             "findByG_P",
136             new String[] {
137                 Long.class.getName(), Long.class.getName(),
138                 
139             "java.lang.Integer", "java.lang.Integer",
140                 "com.liferay.portal.kernel.util.OrderByComparator"
141             });
142     public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
143             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
144             "countByG_P",
145             new String[] { Long.class.getName(), Long.class.getName() });
146     public static final FinderPath FINDER_PATH_FETCH_BY_G_P_N = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
147             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
148             "fetchByG_P_N",
149             new String[] {
150                 Long.class.getName(), Long.class.getName(),
151                 String.class.getName()
152             });
153     public static final FinderPath FINDER_PATH_COUNT_BY_G_P_N = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
154             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
155             "countByG_P_N",
156             new String[] {
157                 Long.class.getName(), Long.class.getName(),
158                 String.class.getName()
159             });
160     public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
161             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
162             "findAll", new String[0]);
163     public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
164             IGFolderModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
165             "countAll", new String[0]);
166 
167     public void cacheResult(IGFolder igFolder) {
168         EntityCacheUtil.putResult(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
169             IGFolderImpl.class, igFolder.getPrimaryKey(), igFolder);
170 
171         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
172             new Object[] { igFolder.getUuid(), new Long(igFolder.getGroupId()) },
173             igFolder);
174 
175         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
176             new Object[] {
177                 new Long(igFolder.getGroupId()),
178                 new Long(igFolder.getParentFolderId()),
179                 
180             igFolder.getName()
181             }, igFolder);
182     }
183 
184     public void cacheResult(List<IGFolder> igFolders) {
185         for (IGFolder igFolder : igFolders) {
186             if (EntityCacheUtil.getResult(
187                         IGFolderModelImpl.ENTITY_CACHE_ENABLED,
188                         IGFolderImpl.class, igFolder.getPrimaryKey(), this) == null) {
189                 cacheResult(igFolder);
190             }
191         }
192     }
193 
194     public void clearCache() {
195         CacheRegistry.clear(IGFolderImpl.class.getName());
196         EntityCacheUtil.clearCache(IGFolderImpl.class.getName());
197         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
198         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
199     }
200 
201     public IGFolder create(long folderId) {
202         IGFolder igFolder = new IGFolderImpl();
203 
204         igFolder.setNew(true);
205         igFolder.setPrimaryKey(folderId);
206 
207         String uuid = PortalUUIDUtil.generate();
208 
209         igFolder.setUuid(uuid);
210 
211         return igFolder;
212     }
213 
214     public IGFolder remove(Serializable primaryKey)
215         throws NoSuchModelException, SystemException {
216         return remove(((Long)primaryKey).longValue());
217     }
218 
219     public IGFolder remove(long folderId)
220         throws NoSuchFolderException, SystemException {
221         Session session = null;
222 
223         try {
224             session = openSession();
225 
226             IGFolder igFolder = (IGFolder)session.get(IGFolderImpl.class,
227                     new Long(folderId));
228 
229             if (igFolder == null) {
230                 if (_log.isWarnEnabled()) {
231                     _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
232                 }
233 
234                 throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
235                     folderId);
236             }
237 
238             return remove(igFolder);
239         }
240         catch (NoSuchFolderException nsee) {
241             throw nsee;
242         }
243         catch (Exception e) {
244             throw processException(e);
245         }
246         finally {
247             closeSession(session);
248         }
249     }
250 
251     public IGFolder remove(IGFolder igFolder) throws SystemException {
252         for (ModelListener<IGFolder> listener : listeners) {
253             listener.onBeforeRemove(igFolder);
254         }
255 
256         igFolder = removeImpl(igFolder);
257 
258         for (ModelListener<IGFolder> listener : listeners) {
259             listener.onAfterRemove(igFolder);
260         }
261 
262         return igFolder;
263     }
264 
265     protected IGFolder removeImpl(IGFolder igFolder) throws SystemException {
266         igFolder = toUnwrappedModel(igFolder);
267 
268         Session session = null;
269 
270         try {
271             session = openSession();
272 
273             if (igFolder.isCachedModel() || BatchSessionUtil.isEnabled()) {
274                 Object staleObject = session.get(IGFolderImpl.class,
275                         igFolder.getPrimaryKeyObj());
276 
277                 if (staleObject != null) {
278                     session.evict(staleObject);
279                 }
280             }
281 
282             session.delete(igFolder);
283 
284             session.flush();
285         }
286         catch (Exception e) {
287             throw processException(e);
288         }
289         finally {
290             closeSession(session);
291         }
292 
293         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
294 
295         IGFolderModelImpl igFolderModelImpl = (IGFolderModelImpl)igFolder;
296 
297         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
298             new Object[] {
299                 igFolderModelImpl.getOriginalUuid(),
300                 new Long(igFolderModelImpl.getOriginalGroupId())
301             });
302 
303         FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
304             new Object[] {
305                 new Long(igFolderModelImpl.getOriginalGroupId()),
306                 new Long(igFolderModelImpl.getOriginalParentFolderId()),
307                 
308             igFolderModelImpl.getOriginalName()
309             });
310 
311         EntityCacheUtil.removeResult(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
312             IGFolderImpl.class, igFolder.getPrimaryKey());
313 
314         return igFolder;
315     }
316 
317     /**
318      * @deprecated Use {@link BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)}.
319      */
320     public IGFolder update(IGFolder igFolder) throws SystemException {
321         if (_log.isWarnEnabled()) {
322             _log.warn(
323                 "Using the deprecated update(IGFolder igFolder) method. Use update(IGFolder igFolder, boolean merge) instead.");
324         }
325 
326         return update(igFolder, false);
327     }
328 
329     public IGFolder updateImpl(
330         com.liferay.portlet.imagegallery.model.IGFolder igFolder, boolean merge)
331         throws SystemException {
332         igFolder = toUnwrappedModel(igFolder);
333 
334         boolean isNew = igFolder.isNew();
335 
336         IGFolderModelImpl igFolderModelImpl = (IGFolderModelImpl)igFolder;
337 
338         if (Validator.isNull(igFolder.getUuid())) {
339             String uuid = PortalUUIDUtil.generate();
340 
341             igFolder.setUuid(uuid);
342         }
343 
344         Session session = null;
345 
346         try {
347             session = openSession();
348 
349             BatchSessionUtil.update(session, igFolder, merge);
350 
351             igFolder.setNew(false);
352         }
353         catch (Exception e) {
354             throw processException(e);
355         }
356         finally {
357             closeSession(session);
358         }
359 
360         FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
361 
362         EntityCacheUtil.putResult(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
363             IGFolderImpl.class, igFolder.getPrimaryKey(), igFolder);
364 
365         if (!isNew &&
366                 (!Validator.equals(igFolder.getUuid(),
367                     igFolderModelImpl.getOriginalUuid()) ||
368                 (igFolder.getGroupId() != igFolderModelImpl.getOriginalGroupId()))) {
369             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
370                 new Object[] {
371                     igFolderModelImpl.getOriginalUuid(),
372                     new Long(igFolderModelImpl.getOriginalGroupId())
373                 });
374         }
375 
376         if (isNew ||
377                 (!Validator.equals(igFolder.getUuid(),
378                     igFolderModelImpl.getOriginalUuid()) ||
379                 (igFolder.getGroupId() != igFolderModelImpl.getOriginalGroupId()))) {
380             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
381                 new Object[] { igFolder.getUuid(), new Long(
382                         igFolder.getGroupId()) }, igFolder);
383         }
384 
385         if (!isNew &&
386                 ((igFolder.getGroupId() != igFolderModelImpl.getOriginalGroupId()) ||
387                 (igFolder.getParentFolderId() != igFolderModelImpl.getOriginalParentFolderId()) ||
388                 !Validator.equals(igFolder.getName(),
389                     igFolderModelImpl.getOriginalName()))) {
390             FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_N,
391                 new Object[] {
392                     new Long(igFolderModelImpl.getOriginalGroupId()),
393                     new Long(igFolderModelImpl.getOriginalParentFolderId()),
394                     
395                 igFolderModelImpl.getOriginalName()
396                 });
397         }
398 
399         if (isNew ||
400                 ((igFolder.getGroupId() != igFolderModelImpl.getOriginalGroupId()) ||
401                 (igFolder.getParentFolderId() != igFolderModelImpl.getOriginalParentFolderId()) ||
402                 !Validator.equals(igFolder.getName(),
403                     igFolderModelImpl.getOriginalName()))) {
404             FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
405                 new Object[] {
406                     new Long(igFolder.getGroupId()),
407                     new Long(igFolder.getParentFolderId()),
408                     
409                 igFolder.getName()
410                 }, igFolder);
411         }
412 
413         return igFolder;
414     }
415 
416     protected IGFolder toUnwrappedModel(IGFolder igFolder) {
417         if (igFolder instanceof IGFolderImpl) {
418             return igFolder;
419         }
420 
421         IGFolderImpl igFolderImpl = new IGFolderImpl();
422 
423         igFolderImpl.setNew(igFolder.isNew());
424         igFolderImpl.setPrimaryKey(igFolder.getPrimaryKey());
425 
426         igFolderImpl.setUuid(igFolder.getUuid());
427         igFolderImpl.setFolderId(igFolder.getFolderId());
428         igFolderImpl.setGroupId(igFolder.getGroupId());
429         igFolderImpl.setCompanyId(igFolder.getCompanyId());
430         igFolderImpl.setUserId(igFolder.getUserId());
431         igFolderImpl.setCreateDate(igFolder.getCreateDate());
432         igFolderImpl.setModifiedDate(igFolder.getModifiedDate());
433         igFolderImpl.setParentFolderId(igFolder.getParentFolderId());
434         igFolderImpl.setName(igFolder.getName());
435         igFolderImpl.setDescription(igFolder.getDescription());
436 
437         return igFolderImpl;
438     }
439 
440     public IGFolder findByPrimaryKey(Serializable primaryKey)
441         throws NoSuchModelException, SystemException {
442         return findByPrimaryKey(((Long)primaryKey).longValue());
443     }
444 
445     public IGFolder findByPrimaryKey(long folderId)
446         throws NoSuchFolderException, SystemException {
447         IGFolder igFolder = fetchByPrimaryKey(folderId);
448 
449         if (igFolder == null) {
450             if (_log.isWarnEnabled()) {
451                 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + folderId);
452             }
453 
454             throw new NoSuchFolderException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
455                 folderId);
456         }
457 
458         return igFolder;
459     }
460 
461     public IGFolder fetchByPrimaryKey(Serializable primaryKey)
462         throws SystemException {
463         return fetchByPrimaryKey(((Long)primaryKey).longValue());
464     }
465 
466     public IGFolder fetchByPrimaryKey(long folderId) throws SystemException {
467         IGFolder igFolder = (IGFolder)EntityCacheUtil.getResult(IGFolderModelImpl.ENTITY_CACHE_ENABLED,
468                 IGFolderImpl.class, folderId, this);
469 
470         if (igFolder == null) {
471             Session session = null;
472 
473             try {
474                 session = openSession();
475 
476                 igFolder = (IGFolder)session.get(IGFolderImpl.class,
477                         new Long(folderId));
478             }
479             catch (Exception e) {
480                 throw processException(e);
481             }
482             finally {
483                 if (igFolder != null) {
484                     cacheResult(igFolder);
485                 }
486 
487                 closeSession(session);
488             }
489         }
490 
491         return igFolder;
492     }
493 
494     public List<IGFolder> findByUuid(String uuid) throws SystemException {
495         Object[] finderArgs = new Object[] { uuid };
496 
497         List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
498                 finderArgs, this);
499 
500         if (list == null) {
501             Session session = null;
502 
503             try {
504                 session = openSession();
505 
506                 StringBundler query = new StringBundler(3);
507 
508                 query.append(_SQL_SELECT_IGFOLDER_WHERE);
509 
510                 if (uuid == null) {
511                     query.append(_FINDER_COLUMN_UUID_UUID_1);
512                 }
513                 else {
514                     if (uuid.equals(StringPool.BLANK)) {
515                         query.append(_FINDER_COLUMN_UUID_UUID_3);
516                     }
517                     else {
518                         query.append(_FINDER_COLUMN_UUID_UUID_2);
519                     }
520                 }
521 
522                 query.append(IGFolderModelImpl.ORDER_BY_JPQL);
523 
524                 String sql = query.toString();
525 
526                 Query q = session.createQuery(sql);
527 
528                 QueryPos qPos = QueryPos.getInstance(q);
529 
530                 if (uuid != null) {
531                     qPos.add(uuid);
532                 }
533 
534                 list = q.list();
535             }
536             catch (Exception e) {
537                 throw processException(e);
538             }
539             finally {
540                 if (list == null) {
541                     list = new ArrayList<IGFolder>();
542                 }
543 
544                 cacheResult(list);
545 
546                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
547                     list);
548 
549                 closeSession(session);
550             }
551         }
552 
553         return list;
554     }
555 
556     public List<IGFolder> findByUuid(String uuid, int start, int end)
557         throws SystemException {
558         return findByUuid(uuid, start, end, null);
559     }
560 
561     public List<IGFolder> findByUuid(String uuid, int start, int end,
562         OrderByComparator orderByComparator) throws SystemException {
563         Object[] finderArgs = new Object[] {
564                 uuid,
565                 
566                 String.valueOf(start), String.valueOf(end),
567                 String.valueOf(orderByComparator)
568             };
569 
570         List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
571                 finderArgs, this);
572 
573         if (list == null) {
574             Session session = null;
575 
576             try {
577                 session = openSession();
578 
579                 StringBundler query = null;
580 
581                 if (orderByComparator != null) {
582                     query = new StringBundler(3 +
583                             (orderByComparator.getOrderByFields().length * 3));
584                 }
585                 else {
586                     query = new StringBundler(3);
587                 }
588 
589                 query.append(_SQL_SELECT_IGFOLDER_WHERE);
590 
591                 if (uuid == null) {
592                     query.append(_FINDER_COLUMN_UUID_UUID_1);
593                 }
594                 else {
595                     if (uuid.equals(StringPool.BLANK)) {
596                         query.append(_FINDER_COLUMN_UUID_UUID_3);
597                     }
598                     else {
599                         query.append(_FINDER_COLUMN_UUID_UUID_2);
600                     }
601                 }
602 
603                 if (orderByComparator != null) {
604                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
605                         orderByComparator);
606                 }
607 
608                 else {
609                     query.append(IGFolderModelImpl.ORDER_BY_JPQL);
610                 }
611 
612                 String sql = query.toString();
613 
614                 Query q = session.createQuery(sql);
615 
616                 QueryPos qPos = QueryPos.getInstance(q);
617 
618                 if (uuid != null) {
619                     qPos.add(uuid);
620                 }
621 
622                 list = (List<IGFolder>)QueryUtil.list(q, getDialect(), start,
623                         end);
624             }
625             catch (Exception e) {
626                 throw processException(e);
627             }
628             finally {
629                 if (list == null) {
630                     list = new ArrayList<IGFolder>();
631                 }
632 
633                 cacheResult(list);
634 
635                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
636                     finderArgs, list);
637 
638                 closeSession(session);
639             }
640         }
641 
642         return list;
643     }
644 
645     public IGFolder findByUuid_First(String uuid,
646         OrderByComparator orderByComparator)
647         throws NoSuchFolderException, SystemException {
648         List<IGFolder> list = findByUuid(uuid, 0, 1, orderByComparator);
649 
650         if (list.isEmpty()) {
651             StringBundler msg = new StringBundler(4);
652 
653             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
654 
655             msg.append("uuid=");
656             msg.append(uuid);
657 
658             msg.append(StringPool.CLOSE_CURLY_BRACE);
659 
660             throw new NoSuchFolderException(msg.toString());
661         }
662         else {
663             return list.get(0);
664         }
665     }
666 
667     public IGFolder findByUuid_Last(String uuid,
668         OrderByComparator orderByComparator)
669         throws NoSuchFolderException, SystemException {
670         int count = countByUuid(uuid);
671 
672         List<IGFolder> list = findByUuid(uuid, count - 1, count,
673                 orderByComparator);
674 
675         if (list.isEmpty()) {
676             StringBundler msg = new StringBundler(4);
677 
678             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
679 
680             msg.append("uuid=");
681             msg.append(uuid);
682 
683             msg.append(StringPool.CLOSE_CURLY_BRACE);
684 
685             throw new NoSuchFolderException(msg.toString());
686         }
687         else {
688             return list.get(0);
689         }
690     }
691 
692     public IGFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
693         OrderByComparator orderByComparator)
694         throws NoSuchFolderException, SystemException {
695         IGFolder igFolder = findByPrimaryKey(folderId);
696 
697         int count = countByUuid(uuid);
698 
699         Session session = null;
700 
701         try {
702             session = openSession();
703 
704             StringBundler query = null;
705 
706             if (orderByComparator != null) {
707                 query = new StringBundler(3 +
708                         (orderByComparator.getOrderByFields().length * 3));
709             }
710             else {
711                 query = new StringBundler(3);
712             }
713 
714             query.append(_SQL_SELECT_IGFOLDER_WHERE);
715 
716             if (uuid == null) {
717                 query.append(_FINDER_COLUMN_UUID_UUID_1);
718             }
719             else {
720                 if (uuid.equals(StringPool.BLANK)) {
721                     query.append(_FINDER_COLUMN_UUID_UUID_3);
722                 }
723                 else {
724                     query.append(_FINDER_COLUMN_UUID_UUID_2);
725                 }
726             }
727 
728             if (orderByComparator != null) {
729                 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
730                     orderByComparator);
731             }
732 
733             else {
734                 query.append(IGFolderModelImpl.ORDER_BY_JPQL);
735             }
736 
737             String sql = query.toString();
738 
739             Query q = session.createQuery(sql);
740 
741             QueryPos qPos = QueryPos.getInstance(q);
742 
743             if (uuid != null) {
744                 qPos.add(uuid);
745             }
746 
747             Object[] objArray = QueryUtil.getPrevAndNext(q, count,
748                     orderByComparator, igFolder);
749 
750             IGFolder[] array = new IGFolderImpl[3];
751 
752             array[0] = (IGFolder)objArray[0];
753             array[1] = (IGFolder)objArray[1];
754             array[2] = (IGFolder)objArray[2];
755 
756             return array;
757         }
758         catch (Exception e) {
759             throw processException(e);
760         }
761         finally {
762             closeSession(session);
763         }
764     }
765 
766     public IGFolder findByUUID_G(String uuid, long groupId)
767         throws NoSuchFolderException, SystemException {
768         IGFolder igFolder = fetchByUUID_G(uuid, groupId);
769 
770         if (igFolder == null) {
771             StringBundler msg = new StringBundler(6);
772 
773             msg.append(_NO_SUCH_ENTITY_WITH_KEY);
774 
775             msg.append("uuid=");
776             msg.append(uuid);
777 
778             msg.append(", groupId=");
779             msg.append(groupId);
780 
781             msg.append(StringPool.CLOSE_CURLY_BRACE);
782 
783             if (_log.isWarnEnabled()) {
784                 _log.warn(msg.toString());
785             }
786 
787             throw new NoSuchFolderException(msg.toString());
788         }
789 
790         return igFolder;
791     }
792 
793     public IGFolder fetchByUUID_G(String uuid, long groupId)
794         throws SystemException {
795         return fetchByUUID_G(uuid, groupId, true);
796     }
797 
798     public IGFolder fetchByUUID_G(String uuid, long groupId,
799         boolean retrieveFromCache) throws SystemException {
800         Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
801 
802         Object result = null;
803 
804         if (retrieveFromCache) {
805             result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
806                     finderArgs, this);
807         }
808 
809         if (result == null) {
810             Session session = null;
811 
812             try {
813                 session = openSession();
814 
815                 StringBundler query = new StringBundler(4);
816 
817                 query.append(_SQL_SELECT_IGFOLDER_WHERE);
818 
819                 if (uuid == null) {
820                     query.append(_FINDER_COLUMN_UUID_G_UUID_1);
821                 }
822                 else {
823                     if (uuid.equals(StringPool.BLANK)) {
824                         query.append(_FINDER_COLUMN_UUID_G_UUID_3);
825                     }
826                     else {
827                         query.append(_FINDER_COLUMN_UUID_G_UUID_2);
828                     }
829                 }
830 
831                 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
832 
833                 query.append(IGFolderModelImpl.ORDER_BY_JPQL);
834 
835                 String sql = query.toString();
836 
837                 Query q = session.createQuery(sql);
838 
839                 QueryPos qPos = QueryPos.getInstance(q);
840 
841                 if (uuid != null) {
842                     qPos.add(uuid);
843                 }
844 
845                 qPos.add(groupId);
846 
847                 List<IGFolder> list = q.list();
848 
849                 result = list;
850 
851                 IGFolder igFolder = null;
852 
853                 if (list.isEmpty()) {
854                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
855                         finderArgs, list);
856                 }
857                 else {
858                     igFolder = list.get(0);
859 
860                     cacheResult(igFolder);
861 
862                     if ((igFolder.getUuid() == null) ||
863                             !igFolder.getUuid().equals(uuid) ||
864                             (igFolder.getGroupId() != groupId)) {
865                         FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
866                             finderArgs, igFolder);
867                     }
868                 }
869 
870                 return igFolder;
871             }
872             catch (Exception e) {
873                 throw processException(e);
874             }
875             finally {
876                 if (result == null) {
877                     FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
878                         finderArgs, new ArrayList<IGFolder>());
879                 }
880 
881                 closeSession(session);
882             }
883         }
884         else {
885             if (result instanceof List<?>) {
886                 return null;
887             }
888             else {
889                 return (IGFolder)result;
890             }
891         }
892     }
893 
894     public List<IGFolder> findByGroupId(long groupId) throws SystemException {
895         Object[] finderArgs = new Object[] { new Long(groupId) };
896 
897         List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
898                 finderArgs, this);
899 
900         if (list == null) {
901             Session session = null;
902 
903             try {
904                 session = openSession();
905 
906                 StringBundler query = new StringBundler(3);
907 
908                 query.append(_SQL_SELECT_IGFOLDER_WHERE);
909 
910                 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
911 
912                 query.append(IGFolderModelImpl.ORDER_BY_JPQL);
913 
914                 String sql = query.toString();
915 
916                 Query q = session.createQuery(sql);
917 
918                 QueryPos qPos = QueryPos.getInstance(q);
919 
920                 qPos.add(groupId);
921 
922                 list = q.list();
923             }
924             catch (Exception e) {
925                 throw processException(e);
926             }
927             finally {
928                 if (list == null) {
929                     list = new ArrayList<IGFolder>();
930                 }
931 
932                 cacheResult(list);
933 
934                 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
935                     finderArgs, list);
936 
937                 closeSession(session);
938             }
939         }
940 
941         return list;
942     }
943 
944     public List<IGFolder> findByGroupId(long groupId, int start, int end)
945         throws SystemException {
946         return findByGroupId(groupId, start, end, null);
947     }
948 
949     public List<IGFolder> findByGroupId(long groupId, int start, int end,
950         OrderByComparator orderByComparator) throws SystemException {
951         Object[] finderArgs = new Object[] {
952                 new Long(groupId),
953                 
954                 String.valueOf(start), String.valueOf(end),
955                 String.valueOf(orderByComparator)
956             };
957 
958         List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
959                 finderArgs, this);
960 
961         if (list == null) {
962             Session session = null;
963 
964             try {
965                 session = openSession();
966 
967                 StringBundler query = null;
968 
969                 if (orderByComparator != null) {
970                     query = new StringBundler(3 +
971                             (orderByComparator.getOrderByFields().length * 3));
972                 }
973                 else {
974                     query = new StringBundler(3);
975                 }
976 
977                 query.append(_SQL_SELECT_IGFOLDER_WHERE);
978 
979                 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
980 
981                 if (orderByComparator != null) {
982                     appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
983                         orderByComparator);
984                 }
985 
986                 else {
987                     query.append(IGFolderModelImpl.ORDER_BY_JPQL);
988                 }
989 
990                 String sql = query.toString();
991 
992                 Query q = session.createQuery(sql);
993 
994                 QueryPos qPos = QueryPos.getInstance(q);
995 
996                 qPos.add(groupId);
997 
998                 list = (List<IGFolder>)QueryUtil.list(q, getDialect(), start,
999                         end);
1000            }
1001            catch (Exception e) {
1002                throw processException(e);
1003            }
1004            finally {
1005                if (list == null) {
1006                    list = new ArrayList<IGFolder>();
1007                }
1008
1009                cacheResult(list);
1010
1011                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
1012                    finderArgs, list);
1013
1014                closeSession(session);
1015            }
1016        }
1017
1018        return list;
1019    }
1020
1021    public IGFolder findByGroupId_First(long groupId,
1022        OrderByComparator orderByComparator)
1023        throws NoSuchFolderException, SystemException {
1024        List<IGFolder> list = findByGroupId(groupId, 0, 1, orderByComparator);
1025
1026        if (list.isEmpty()) {
1027            StringBundler msg = new StringBundler(4);
1028
1029            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1030
1031            msg.append("groupId=");
1032            msg.append(groupId);
1033
1034            msg.append(StringPool.CLOSE_CURLY_BRACE);
1035
1036            throw new NoSuchFolderException(msg.toString());
1037        }
1038        else {
1039            return list.get(0);
1040        }
1041    }
1042
1043    public IGFolder findByGroupId_Last(long groupId,
1044        OrderByComparator orderByComparator)
1045        throws NoSuchFolderException, SystemException {
1046        int count = countByGroupId(groupId);
1047
1048        List<IGFolder> list = findByGroupId(groupId, count - 1, count,
1049                orderByComparator);
1050
1051        if (list.isEmpty()) {
1052            StringBundler msg = new StringBundler(4);
1053
1054            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1055
1056            msg.append("groupId=");
1057            msg.append(groupId);
1058
1059            msg.append(StringPool.CLOSE_CURLY_BRACE);
1060
1061            throw new NoSuchFolderException(msg.toString());
1062        }
1063        else {
1064            return list.get(0);
1065        }
1066    }
1067
1068    public IGFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
1069        OrderByComparator orderByComparator)
1070        throws NoSuchFolderException, SystemException {
1071        IGFolder igFolder = findByPrimaryKey(folderId);
1072
1073        int count = countByGroupId(groupId);
1074
1075        Session session = null;
1076
1077        try {
1078            session = openSession();
1079
1080            StringBundler query = null;
1081
1082            if (orderByComparator != null) {
1083                query = new StringBundler(3 +
1084                        (orderByComparator.getOrderByFields().length * 3));
1085            }
1086            else {
1087                query = new StringBundler(3);
1088            }
1089
1090            query.append(_SQL_SELECT_IGFOLDER_WHERE);
1091
1092            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1093
1094            if (orderByComparator != null) {
1095                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1096                    orderByComparator);
1097            }
1098
1099            else {
1100                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1101            }
1102
1103            String sql = query.toString();
1104
1105            Query q = session.createQuery(sql);
1106
1107            QueryPos qPos = QueryPos.getInstance(q);
1108
1109            qPos.add(groupId);
1110
1111            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1112                    orderByComparator, igFolder);
1113
1114            IGFolder[] array = new IGFolderImpl[3];
1115
1116            array[0] = (IGFolder)objArray[0];
1117            array[1] = (IGFolder)objArray[1];
1118            array[2] = (IGFolder)objArray[2];
1119
1120            return array;
1121        }
1122        catch (Exception e) {
1123            throw processException(e);
1124        }
1125        finally {
1126            closeSession(session);
1127        }
1128    }
1129
1130    public List<IGFolder> findByCompanyId(long companyId)
1131        throws SystemException {
1132        Object[] finderArgs = new Object[] { new Long(companyId) };
1133
1134        List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1135                finderArgs, this);
1136
1137        if (list == null) {
1138            Session session = null;
1139
1140            try {
1141                session = openSession();
1142
1143                StringBundler query = new StringBundler(3);
1144
1145                query.append(_SQL_SELECT_IGFOLDER_WHERE);
1146
1147                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1148
1149                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1150
1151                String sql = query.toString();
1152
1153                Query q = session.createQuery(sql);
1154
1155                QueryPos qPos = QueryPos.getInstance(q);
1156
1157                qPos.add(companyId);
1158
1159                list = q.list();
1160            }
1161            catch (Exception e) {
1162                throw processException(e);
1163            }
1164            finally {
1165                if (list == null) {
1166                    list = new ArrayList<IGFolder>();
1167                }
1168
1169                cacheResult(list);
1170
1171                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1172                    finderArgs, list);
1173
1174                closeSession(session);
1175            }
1176        }
1177
1178        return list;
1179    }
1180
1181    public List<IGFolder> findByCompanyId(long companyId, int start, int end)
1182        throws SystemException {
1183        return findByCompanyId(companyId, start, end, null);
1184    }
1185
1186    public List<IGFolder> findByCompanyId(long companyId, int start, int end,
1187        OrderByComparator orderByComparator) throws SystemException {
1188        Object[] finderArgs = new Object[] {
1189                new Long(companyId),
1190                
1191                String.valueOf(start), String.valueOf(end),
1192                String.valueOf(orderByComparator)
1193            };
1194
1195        List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1196                finderArgs, this);
1197
1198        if (list == null) {
1199            Session session = null;
1200
1201            try {
1202                session = openSession();
1203
1204                StringBundler query = null;
1205
1206                if (orderByComparator != null) {
1207                    query = new StringBundler(3 +
1208                            (orderByComparator.getOrderByFields().length * 3));
1209                }
1210                else {
1211                    query = new StringBundler(3);
1212                }
1213
1214                query.append(_SQL_SELECT_IGFOLDER_WHERE);
1215
1216                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1217
1218                if (orderByComparator != null) {
1219                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1220                        orderByComparator);
1221                }
1222
1223                else {
1224                    query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1225                }
1226
1227                String sql = query.toString();
1228
1229                Query q = session.createQuery(sql);
1230
1231                QueryPos qPos = QueryPos.getInstance(q);
1232
1233                qPos.add(companyId);
1234
1235                list = (List<IGFolder>)QueryUtil.list(q, getDialect(), start,
1236                        end);
1237            }
1238            catch (Exception e) {
1239                throw processException(e);
1240            }
1241            finally {
1242                if (list == null) {
1243                    list = new ArrayList<IGFolder>();
1244                }
1245
1246                cacheResult(list);
1247
1248                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1249                    finderArgs, list);
1250
1251                closeSession(session);
1252            }
1253        }
1254
1255        return list;
1256    }
1257
1258    public IGFolder findByCompanyId_First(long companyId,
1259        OrderByComparator orderByComparator)
1260        throws NoSuchFolderException, SystemException {
1261        List<IGFolder> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1262
1263        if (list.isEmpty()) {
1264            StringBundler msg = new StringBundler(4);
1265
1266            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1267
1268            msg.append("companyId=");
1269            msg.append(companyId);
1270
1271            msg.append(StringPool.CLOSE_CURLY_BRACE);
1272
1273            throw new NoSuchFolderException(msg.toString());
1274        }
1275        else {
1276            return list.get(0);
1277        }
1278    }
1279
1280    public IGFolder findByCompanyId_Last(long companyId,
1281        OrderByComparator orderByComparator)
1282        throws NoSuchFolderException, SystemException {
1283        int count = countByCompanyId(companyId);
1284
1285        List<IGFolder> list = findByCompanyId(companyId, count - 1, count,
1286                orderByComparator);
1287
1288        if (list.isEmpty()) {
1289            StringBundler msg = new StringBundler(4);
1290
1291            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1292
1293            msg.append("companyId=");
1294            msg.append(companyId);
1295
1296            msg.append(StringPool.CLOSE_CURLY_BRACE);
1297
1298            throw new NoSuchFolderException(msg.toString());
1299        }
1300        else {
1301            return list.get(0);
1302        }
1303    }
1304
1305    public IGFolder[] findByCompanyId_PrevAndNext(long folderId,
1306        long companyId, OrderByComparator orderByComparator)
1307        throws NoSuchFolderException, SystemException {
1308        IGFolder igFolder = findByPrimaryKey(folderId);
1309
1310        int count = countByCompanyId(companyId);
1311
1312        Session session = null;
1313
1314        try {
1315            session = openSession();
1316
1317            StringBundler query = null;
1318
1319            if (orderByComparator != null) {
1320                query = new StringBundler(3 +
1321                        (orderByComparator.getOrderByFields().length * 3));
1322            }
1323            else {
1324                query = new StringBundler(3);
1325            }
1326
1327            query.append(_SQL_SELECT_IGFOLDER_WHERE);
1328
1329            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1330
1331            if (orderByComparator != null) {
1332                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1333                    orderByComparator);
1334            }
1335
1336            else {
1337                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1338            }
1339
1340            String sql = query.toString();
1341
1342            Query q = session.createQuery(sql);
1343
1344            QueryPos qPos = QueryPos.getInstance(q);
1345
1346            qPos.add(companyId);
1347
1348            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1349                    orderByComparator, igFolder);
1350
1351            IGFolder[] array = new IGFolderImpl[3];
1352
1353            array[0] = (IGFolder)objArray[0];
1354            array[1] = (IGFolder)objArray[1];
1355            array[2] = (IGFolder)objArray[2];
1356
1357            return array;
1358        }
1359        catch (Exception e) {
1360            throw processException(e);
1361        }
1362        finally {
1363            closeSession(session);
1364        }
1365    }
1366
1367    public List<IGFolder> findByG_P(long groupId, long parentFolderId)
1368        throws SystemException {
1369        Object[] finderArgs = new Object[] {
1370                new Long(groupId), new Long(parentFolderId)
1371            };
1372
1373        List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
1374                finderArgs, this);
1375
1376        if (list == null) {
1377            Session session = null;
1378
1379            try {
1380                session = openSession();
1381
1382                StringBundler query = new StringBundler(4);
1383
1384                query.append(_SQL_SELECT_IGFOLDER_WHERE);
1385
1386                query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1387
1388                query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1389
1390                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1391
1392                String sql = query.toString();
1393
1394                Query q = session.createQuery(sql);
1395
1396                QueryPos qPos = QueryPos.getInstance(q);
1397
1398                qPos.add(groupId);
1399
1400                qPos.add(parentFolderId);
1401
1402                list = q.list();
1403            }
1404            catch (Exception e) {
1405                throw processException(e);
1406            }
1407            finally {
1408                if (list == null) {
1409                    list = new ArrayList<IGFolder>();
1410                }
1411
1412                cacheResult(list);
1413
1414                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1415                    list);
1416
1417                closeSession(session);
1418            }
1419        }
1420
1421        return list;
1422    }
1423
1424    public List<IGFolder> findByG_P(long groupId, long parentFolderId,
1425        int start, int end) throws SystemException {
1426        return findByG_P(groupId, parentFolderId, start, end, null);
1427    }
1428
1429    public List<IGFolder> findByG_P(long groupId, long parentFolderId,
1430        int start, int end, OrderByComparator orderByComparator)
1431        throws SystemException {
1432        Object[] finderArgs = new Object[] {
1433                new Long(groupId), new Long(parentFolderId),
1434                
1435                String.valueOf(start), String.valueOf(end),
1436                String.valueOf(orderByComparator)
1437            };
1438
1439        List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_G_P,
1440                finderArgs, this);
1441
1442        if (list == null) {
1443            Session session = null;
1444
1445            try {
1446                session = openSession();
1447
1448                StringBundler query = null;
1449
1450                if (orderByComparator != null) {
1451                    query = new StringBundler(4 +
1452                            (orderByComparator.getOrderByFields().length * 3));
1453                }
1454                else {
1455                    query = new StringBundler(4);
1456                }
1457
1458                query.append(_SQL_SELECT_IGFOLDER_WHERE);
1459
1460                query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1461
1462                query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1463
1464                if (orderByComparator != null) {
1465                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1466                        orderByComparator);
1467                }
1468
1469                else {
1470                    query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1471                }
1472
1473                String sql = query.toString();
1474
1475                Query q = session.createQuery(sql);
1476
1477                QueryPos qPos = QueryPos.getInstance(q);
1478
1479                qPos.add(groupId);
1480
1481                qPos.add(parentFolderId);
1482
1483                list = (List<IGFolder>)QueryUtil.list(q, getDialect(), start,
1484                        end);
1485            }
1486            catch (Exception e) {
1487                throw processException(e);
1488            }
1489            finally {
1490                if (list == null) {
1491                    list = new ArrayList<IGFolder>();
1492                }
1493
1494                cacheResult(list);
1495
1496                FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_G_P,
1497                    finderArgs, list);
1498
1499                closeSession(session);
1500            }
1501        }
1502
1503        return list;
1504    }
1505
1506    public IGFolder findByG_P_First(long groupId, long parentFolderId,
1507        OrderByComparator orderByComparator)
1508        throws NoSuchFolderException, SystemException {
1509        List<IGFolder> list = findByG_P(groupId, parentFolderId, 0, 1,
1510                orderByComparator);
1511
1512        if (list.isEmpty()) {
1513            StringBundler msg = new StringBundler(6);
1514
1515            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1516
1517            msg.append("groupId=");
1518            msg.append(groupId);
1519
1520            msg.append(", parentFolderId=");
1521            msg.append(parentFolderId);
1522
1523            msg.append(StringPool.CLOSE_CURLY_BRACE);
1524
1525            throw new NoSuchFolderException(msg.toString());
1526        }
1527        else {
1528            return list.get(0);
1529        }
1530    }
1531
1532    public IGFolder findByG_P_Last(long groupId, long parentFolderId,
1533        OrderByComparator orderByComparator)
1534        throws NoSuchFolderException, SystemException {
1535        int count = countByG_P(groupId, parentFolderId);
1536
1537        List<IGFolder> list = findByG_P(groupId, parentFolderId, count - 1,
1538                count, orderByComparator);
1539
1540        if (list.isEmpty()) {
1541            StringBundler msg = new StringBundler(6);
1542
1543            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1544
1545            msg.append("groupId=");
1546            msg.append(groupId);
1547
1548            msg.append(", parentFolderId=");
1549            msg.append(parentFolderId);
1550
1551            msg.append(StringPool.CLOSE_CURLY_BRACE);
1552
1553            throw new NoSuchFolderException(msg.toString());
1554        }
1555        else {
1556            return list.get(0);
1557        }
1558    }
1559
1560    public IGFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
1561        long parentFolderId, OrderByComparator orderByComparator)
1562        throws NoSuchFolderException, SystemException {
1563        IGFolder igFolder = findByPrimaryKey(folderId);
1564
1565        int count = countByG_P(groupId, parentFolderId);
1566
1567        Session session = null;
1568
1569        try {
1570            session = openSession();
1571
1572            StringBundler query = null;
1573
1574            if (orderByComparator != null) {
1575                query = new StringBundler(4 +
1576                        (orderByComparator.getOrderByFields().length * 3));
1577            }
1578            else {
1579                query = new StringBundler(4);
1580            }
1581
1582            query.append(_SQL_SELECT_IGFOLDER_WHERE);
1583
1584            query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1585
1586            query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
1587
1588            if (orderByComparator != null) {
1589                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1590                    orderByComparator);
1591            }
1592
1593            else {
1594                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1595            }
1596
1597            String sql = query.toString();
1598
1599            Query q = session.createQuery(sql);
1600
1601            QueryPos qPos = QueryPos.getInstance(q);
1602
1603            qPos.add(groupId);
1604
1605            qPos.add(parentFolderId);
1606
1607            Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1608                    orderByComparator, igFolder);
1609
1610            IGFolder[] array = new IGFolderImpl[3];
1611
1612            array[0] = (IGFolder)objArray[0];
1613            array[1] = (IGFolder)objArray[1];
1614            array[2] = (IGFolder)objArray[2];
1615
1616            return array;
1617        }
1618        catch (Exception e) {
1619            throw processException(e);
1620        }
1621        finally {
1622            closeSession(session);
1623        }
1624    }
1625
1626    public IGFolder findByG_P_N(long groupId, long parentFolderId, String name)
1627        throws NoSuchFolderException, SystemException {
1628        IGFolder igFolder = fetchByG_P_N(groupId, parentFolderId, name);
1629
1630        if (igFolder == null) {
1631            StringBundler msg = new StringBundler(8);
1632
1633            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1634
1635            msg.append("groupId=");
1636            msg.append(groupId);
1637
1638            msg.append(", parentFolderId=");
1639            msg.append(parentFolderId);
1640
1641            msg.append(", name=");
1642            msg.append(name);
1643
1644            msg.append(StringPool.CLOSE_CURLY_BRACE);
1645
1646            if (_log.isWarnEnabled()) {
1647                _log.warn(msg.toString());
1648            }
1649
1650            throw new NoSuchFolderException(msg.toString());
1651        }
1652
1653        return igFolder;
1654    }
1655
1656    public IGFolder fetchByG_P_N(long groupId, long parentFolderId, String name)
1657        throws SystemException {
1658        return fetchByG_P_N(groupId, parentFolderId, name, true);
1659    }
1660
1661    public IGFolder fetchByG_P_N(long groupId, long parentFolderId,
1662        String name, boolean retrieveFromCache) throws SystemException {
1663        Object[] finderArgs = new Object[] {
1664                new Long(groupId), new Long(parentFolderId),
1665                
1666                name
1667            };
1668
1669        Object result = null;
1670
1671        if (retrieveFromCache) {
1672            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_N,
1673                    finderArgs, this);
1674        }
1675
1676        if (result == null) {
1677            Session session = null;
1678
1679            try {
1680                session = openSession();
1681
1682                StringBundler query = new StringBundler(5);
1683
1684                query.append(_SQL_SELECT_IGFOLDER_WHERE);
1685
1686                query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
1687
1688                query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
1689
1690                if (name == null) {
1691                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
1692                }
1693                else {
1694                    if (name.equals(StringPool.BLANK)) {
1695                        query.append(_FINDER_COLUMN_G_P_N_NAME_3);
1696                    }
1697                    else {
1698                        query.append(_FINDER_COLUMN_G_P_N_NAME_2);
1699                    }
1700                }
1701
1702                query.append(IGFolderModelImpl.ORDER_BY_JPQL);
1703
1704                String sql = query.toString();
1705
1706                Query q = session.createQuery(sql);
1707
1708                QueryPos qPos = QueryPos.getInstance(q);
1709
1710                qPos.add(groupId);
1711
1712                qPos.add(parentFolderId);
1713
1714                if (name != null) {
1715                    qPos.add(name);
1716                }
1717
1718                List<IGFolder> list = q.list();
1719
1720                result = list;
1721
1722                IGFolder igFolder = null;
1723
1724                if (list.isEmpty()) {
1725                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1726                        finderArgs, list);
1727                }
1728                else {
1729                    igFolder = list.get(0);
1730
1731                    cacheResult(igFolder);
1732
1733                    if ((igFolder.getGroupId() != groupId) ||
1734                            (igFolder.getParentFolderId() != parentFolderId) ||
1735                            (igFolder.getName() == null) ||
1736                            !igFolder.getName().equals(name)) {
1737                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1738                            finderArgs, igFolder);
1739                    }
1740                }
1741
1742                return igFolder;
1743            }
1744            catch (Exception e) {
1745                throw processException(e);
1746            }
1747            finally {
1748                if (result == null) {
1749                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_N,
1750                        finderArgs, new ArrayList<IGFolder>());
1751                }
1752
1753                closeSession(session);
1754            }
1755        }
1756        else {
1757            if (result instanceof List<?>) {
1758                return null;
1759            }
1760            else {
1761                return (IGFolder)result;
1762            }
1763        }
1764    }
1765
1766    public List<IGFolder> findAll() throws SystemException {
1767        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1768    }
1769
1770    public List<IGFolder> findAll(int start, int end) throws SystemException {
1771        return findAll(start, end, null);
1772    }
1773
1774    public List<IGFolder> findAll(int start, int end,
1775        OrderByComparator orderByComparator) throws SystemException {
1776        Object[] finderArgs = new Object[] {
1777                String.valueOf(start), String.valueOf(end),
1778                String.valueOf(orderByComparator)
1779            };
1780
1781        List<IGFolder> list = (List<IGFolder>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1782                finderArgs, this);
1783
1784        if (list == null) {
1785            Session session = null;
1786
1787            try {
1788                session = openSession();
1789
1790                StringBundler query = null;
1791                String sql = null;
1792
1793                if (orderByComparator != null) {
1794                    query = new StringBundler(2 +
1795                            (orderByComparator.getOrderByFields().length * 3));
1796
1797                    query.append(_SQL_SELECT_IGFOLDER);
1798
1799                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1800                        orderByComparator);
1801
1802                    sql = query.toString();
1803                }
1804
1805                else {
1806                    sql = _SQL_SELECT_IGFOLDER.concat(IGFolderModelImpl.ORDER_BY_JPQL);
1807                }
1808
1809                Query q = session.createQuery(sql);
1810
1811                if (orderByComparator == null) {
1812                    list = (List<IGFolder>)QueryUtil.list(q, getDialect(),
1813                            start, end, false);
1814
1815                    Collections.sort(list);
1816                }
1817                else {
1818                    list = (List<IGFolder>)QueryUtil.list(q, getDialect(),
1819                            start, end);
1820                }
1821            }
1822            catch (Exception e) {
1823                throw processException(e);
1824            }
1825            finally {
1826                if (list == null) {
1827                    list = new ArrayList<IGFolder>();
1828                }
1829
1830                cacheResult(list);
1831
1832                FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1833
1834                closeSession(session);
1835            }
1836        }
1837
1838        return list;
1839    }
1840
1841    public void removeByUuid(String uuid) throws SystemException {
1842        for (IGFolder igFolder : findByUuid(uuid)) {
1843            remove(igFolder);
1844        }
1845    }
1846
1847    public void removeByUUID_G(String uuid, long groupId)
1848        throws NoSuchFolderException, SystemException {
1849        IGFolder igFolder = findByUUID_G(uuid, groupId);
1850
1851        remove(igFolder);
1852    }
1853
1854    public void removeByGroupId(long groupId) throws SystemException {
1855        for (IGFolder igFolder : findByGroupId(groupId)) {
1856            remove(igFolder);
1857        }
1858    }
1859
1860    public void removeByCompanyId(long companyId) throws SystemException {
1861        for (IGFolder igFolder : findByCompanyId(companyId)) {
1862            remove(igFolder);
1863        }
1864    }
1865
1866    public void removeByG_P(long groupId, long parentFolderId)
1867        throws SystemException {
1868        for (IGFolder igFolder : findByG_P(groupId, parentFolderId)) {
1869            remove(igFolder);
1870        }
1871    }
1872
1873    public void removeByG_P_N(long groupId, long parentFolderId, String name)
1874        throws NoSuchFolderException, SystemException {
1875        IGFolder igFolder = findByG_P_N(groupId, parentFolderId, name);
1876
1877        remove(igFolder);
1878    }
1879
1880    public void removeAll() throws SystemException {
1881        for (IGFolder igFolder : findAll()) {
1882            remove(igFolder);
1883        }
1884    }
1885
1886    public int countByUuid(String uuid) throws SystemException {
1887        Object[] finderArgs = new Object[] { uuid };
1888
1889        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1890                finderArgs, this);
1891
1892        if (count == null) {
1893            Session session = null;
1894
1895            try {
1896                session = openSession();
1897
1898                StringBundler query = new StringBundler(2);
1899
1900                query.append(_SQL_COUNT_IGFOLDER_WHERE);
1901
1902                if (uuid == null) {
1903                    query.append(_FINDER_COLUMN_UUID_UUID_1);
1904                }
1905                else {
1906                    if (uuid.equals(StringPool.BLANK)) {
1907                        query.append(_FINDER_COLUMN_UUID_UUID_3);
1908                    }
1909                    else {
1910                        query.append(_FINDER_COLUMN_UUID_UUID_2);
1911                    }
1912                }
1913
1914                String sql = query.toString();
1915
1916                Query q = session.createQuery(sql);
1917
1918                QueryPos qPos = QueryPos.getInstance(q);
1919
1920                if (uuid != null) {
1921                    qPos.add(uuid);
1922                }
1923
1924                count = (Long)q.uniqueResult();
1925            }
1926            catch (Exception e) {
1927                throw processException(e);
1928            }
1929            finally {
1930                if (count == null) {
1931                    count = Long.valueOf(0);
1932                }
1933
1934                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1935                    finderArgs, count);
1936
1937                closeSession(session);
1938            }
1939        }
1940
1941        return count.intValue();
1942    }
1943
1944    public int countByUUID_G(String uuid, long groupId)
1945        throws SystemException {
1946        Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1947
1948        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1949                finderArgs, this);
1950
1951        if (count == null) {
1952            Session session = null;
1953
1954            try {
1955                session = openSession();
1956
1957                StringBundler query = new StringBundler(3);
1958
1959                query.append(_SQL_COUNT_IGFOLDER_WHERE);
1960
1961                if (uuid == null) {
1962                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1963                }
1964                else {
1965                    if (uuid.equals(StringPool.BLANK)) {
1966                        query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1967                    }
1968                    else {
1969                        query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1970                    }
1971                }
1972
1973                query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1974
1975                String sql = query.toString();
1976
1977                Query q = session.createQuery(sql);
1978
1979                QueryPos qPos = QueryPos.getInstance(q);
1980
1981                if (uuid != null) {
1982                    qPos.add(uuid);
1983                }
1984
1985                qPos.add(groupId);
1986
1987                count = (Long)q.uniqueResult();
1988            }
1989            catch (Exception e) {
1990                throw processException(e);
1991            }
1992            finally {
1993                if (count == null) {
1994                    count = Long.valueOf(0);
1995                }
1996
1997                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1998                    finderArgs, count);
1999
2000                closeSession(session);
2001            }
2002        }
2003
2004        return count.intValue();
2005    }
2006
2007    public int countByGroupId(long groupId) throws SystemException {
2008        Object[] finderArgs = new Object[] { new Long(groupId) };
2009
2010        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2011                finderArgs, this);
2012
2013        if (count == null) {
2014            Session session = null;
2015
2016            try {
2017                session = openSession();
2018
2019                StringBundler query = new StringBundler(2);
2020
2021                query.append(_SQL_COUNT_IGFOLDER_WHERE);
2022
2023                query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2024
2025                String sql = query.toString();
2026
2027                Query q = session.createQuery(sql);
2028
2029                QueryPos qPos = QueryPos.getInstance(q);
2030
2031                qPos.add(groupId);
2032
2033                count = (Long)q.uniqueResult();
2034            }
2035            catch (Exception e) {
2036                throw processException(e);
2037            }
2038            finally {
2039                if (count == null) {
2040                    count = Long.valueOf(0);
2041                }
2042
2043                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2044                    finderArgs, count);
2045
2046                closeSession(session);
2047            }
2048        }
2049
2050        return count.intValue();
2051    }
2052
2053    public int countByCompanyId(long companyId) throws SystemException {
2054        Object[] finderArgs = new Object[] { new Long(companyId) };
2055
2056        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2057                finderArgs, this);
2058
2059        if (count == null) {
2060            Session session = null;
2061
2062            try {
2063                session = openSession();
2064
2065                StringBundler query = new StringBundler(2);
2066
2067                query.append(_SQL_COUNT_IGFOLDER_WHERE);
2068
2069                query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2070
2071                String sql = query.toString();
2072
2073                Query q = session.createQuery(sql);
2074
2075                QueryPos qPos = QueryPos.getInstance(q);
2076
2077                qPos.add(companyId);
2078
2079                count = (Long)q.uniqueResult();
2080            }
2081            catch (Exception e) {
2082                throw processException(e);
2083            }
2084            finally {
2085                if (count == null) {
2086                    count = Long.valueOf(0);
2087                }
2088
2089                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2090                    finderArgs, count);
2091
2092                closeSession(session);
2093            }
2094        }
2095
2096        return count.intValue();
2097    }
2098
2099    public int countByG_P(long groupId, long parentFolderId)
2100        throws SystemException {
2101        Object[] finderArgs = new Object[] {
2102                new Long(groupId), new Long(parentFolderId)
2103            };
2104
2105        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2106                finderArgs, this);
2107
2108        if (count == null) {
2109            Session session = null;
2110
2111            try {
2112                session = openSession();
2113
2114                StringBundler query = new StringBundler(3);
2115
2116                query.append(_SQL_COUNT_IGFOLDER_WHERE);
2117
2118                query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2119
2120                query.append(_FINDER_COLUMN_G_P_PARENTFOLDERID_2);
2121
2122                String sql = query.toString();
2123
2124                Query q = session.createQuery(sql);
2125
2126                QueryPos qPos = QueryPos.getInstance(q);
2127
2128                qPos.add(groupId);
2129
2130                qPos.add(parentFolderId);
2131
2132                count = (Long)q.uniqueResult();
2133            }
2134            catch (Exception e) {
2135                throw processException(e);
2136            }
2137            finally {
2138                if (count == null) {
2139                    count = Long.valueOf(0);
2140                }
2141
2142                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2143                    count);
2144
2145                closeSession(session);
2146            }
2147        }
2148
2149        return count.intValue();
2150    }
2151
2152    public int countByG_P_N(long groupId, long parentFolderId, String name)
2153        throws SystemException {
2154        Object[] finderArgs = new Object[] {
2155                new Long(groupId), new Long(parentFolderId),
2156                
2157                name
2158            };
2159
2160        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_N,
2161                finderArgs, this);
2162
2163        if (count == null) {
2164            Session session = null;
2165
2166            try {
2167                session = openSession();
2168
2169                StringBundler query = new StringBundler(4);
2170
2171                query.append(_SQL_COUNT_IGFOLDER_WHERE);
2172
2173                query.append(_FINDER_COLUMN_G_P_N_GROUPID_2);
2174
2175                query.append(_FINDER_COLUMN_G_P_N_PARENTFOLDERID_2);
2176
2177                if (name == null) {
2178                    query.append(_FINDER_COLUMN_G_P_N_NAME_1);
2179                }
2180                else {
2181                    if (name.equals(StringPool.BLANK)) {
2182                        query.append(_FINDER_COLUMN_G_P_N_NAME_3);
2183                    }
2184                    else {
2185                        query.append(_FINDER_COLUMN_G_P_N_NAME_2);
2186                    }
2187                }
2188
2189                String sql = query.toString();
2190
2191                Query q = session.createQuery(sql);
2192
2193                QueryPos qPos = QueryPos.getInstance(q);
2194
2195                qPos.add(groupId);
2196
2197                qPos.add(parentFolderId);
2198
2199                if (name != null) {
2200                    qPos.add(name);
2201                }
2202
2203                count = (Long)q.uniqueResult();
2204            }
2205            catch (Exception e) {
2206                throw processException(e);
2207            }
2208            finally {
2209                if (count == null) {
2210                    count = Long.valueOf(0);
2211                }
2212
2213                FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_N,
2214                    finderArgs, count);
2215
2216                closeSession(session);
2217            }
2218        }
2219
2220        return count.intValue();
2221    }
2222
2223    public int countAll() throws SystemException {
2224        Object[] finderArgs = new Object[0];
2225
2226        Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2227                finderArgs, this);
2228
2229        if (count == null) {
2230            Session session = null;
2231
2232            try {
2233                session = openSession();
2234
2235                Query q = session.createQuery(_SQL_COUNT_IGFOLDER);
2236
2237                count = (Long)q.uniqueResult();
2238            }
2239            catch (Exception e) {
2240                throw processException(e);
2241            }
2242            finally {
2243                if (count == null) {
2244                    count = Long.valueOf(0);
2245                }
2246
2247                FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2248                    count);
2249
2250                closeSession(session);
2251            }
2252        }
2253
2254        return count.intValue();
2255    }
2256
2257    public void afterPropertiesSet() {
2258        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2259                    com.liferay.portal.util.PropsUtil.get(
2260                        "value.object.listener.com.liferay.portlet.imagegallery.model.IGFolder")));
2261
2262        if (listenerClassNames.length > 0) {
2263            try {
2264                List<ModelListener<IGFolder>> listenersList = new ArrayList<ModelListener<IGFolder>>();
2265
2266                for (String listenerClassName : listenerClassNames) {
2267                    listenersList.add((ModelListener<IGFolder>)Class.forName(
2268                            listenerClassName).newInstance());
2269                }
2270
2271                listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2272            }
2273            catch (Exception e) {
2274                _log.error(e);
2275            }
2276        }
2277    }
2278
2279    @BeanReference(type = IGFolderPersistence.class)
2280    protected IGFolderPersistence igFolderPersistence;
2281    @BeanReference(type = IGImagePersistence.class)
2282    protected IGImagePersistence igImagePersistence;
2283    @BeanReference(type = GroupPersistence.class)
2284    protected GroupPersistence groupPersistence;
2285    @BeanReference(type = ImagePersistence.class)
2286    protected ImagePersistence imagePersistence;
2287    @BeanReference(type = LayoutPersistence.class)
2288    protected LayoutPersistence layoutPersistence;
2289    @BeanReference(type = ResourcePersistence.class)
2290    protected ResourcePersistence resourcePersistence;
2291    @BeanReference(type = UserPersistence.class)
2292    protected UserPersistence userPersistence;
2293    @BeanReference(type = ExpandoValuePersistence.class)
2294    protected ExpandoValuePersistence expandoValuePersistence;
2295    private static final String _SQL_SELECT_IGFOLDER = "SELECT igFolder FROM IGFolder igFolder";
2296    private static final String _SQL_SELECT_IGFOLDER_WHERE = "SELECT igFolder FROM IGFolder igFolder WHERE ";
2297    private static final String _SQL_COUNT_IGFOLDER = "SELECT COUNT(igFolder) FROM IGFolder igFolder";
2298    private static final String _SQL_COUNT_IGFOLDER_WHERE = "SELECT COUNT(igFolder) FROM IGFolder igFolder WHERE ";
2299    private static final String _FINDER_COLUMN_UUID_UUID_1 = "igFolder.uuid IS NULL";
2300    private static final String _FINDER_COLUMN_UUID_UUID_2 = "igFolder.uuid = ?";
2301    private static final String _FINDER_COLUMN_UUID_UUID_3 = "(igFolder.uuid IS NULL OR igFolder.uuid = ?)";
2302    private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "igFolder.uuid IS NULL AND ";
2303    private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "igFolder.uuid = ? AND ";
2304    private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(igFolder.uuid IS NULL OR igFolder.uuid = ?) AND ";
2305    private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "igFolder.groupId = ?";
2306    private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "igFolder.groupId = ?";
2307    private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "igFolder.companyId = ?";
2308    private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "igFolder.groupId = ? AND ";
2309    private static final String _FINDER_COLUMN_G_P_PARENTFOLDERID_2 = "igFolder.parentFolderId = ?";
2310    private static final String _FINDER_COLUMN_G_P_N_GROUPID_2 = "igFolder.groupId = ? AND ";
2311    private static final String _FINDER_COLUMN_G_P_N_PARENTFOLDERID_2 = "igFolder.parentFolderId = ? AND ";
2312    private static final String _FINDER_COLUMN_G_P_N_NAME_1 = "igFolder.name IS NULL";
2313    private static final String _FINDER_COLUMN_G_P_N_NAME_2 = "igFolder.name = ?";
2314    private static final String _FINDER_COLUMN_G_P_N_NAME_3 = "(igFolder.name IS NULL OR igFolder.name = ?)";
2315    private static final String _ORDER_BY_ENTITY_ALIAS = "igFolder.";
2316    private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No IGFolder exists with the primary key ";
2317    private static final String _NO_SUCH_ENTITY_WITH_KEY = "No IGFolder exists with the key {";
2318    private static Log _log = LogFactoryUtil.getLog(IGFolderPersistenceImpl.class);
2319}