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