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