1
22
23 package com.liferay.portlet.imagegallery.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.DynamicQuery;
27 import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
28 import com.liferay.portal.kernel.util.GetterUtil;
29 import com.liferay.portal.kernel.util.OrderByComparator;
30 import com.liferay.portal.kernel.util.StringMaker;
31 import com.liferay.portal.kernel.util.StringPool;
32 import com.liferay.portal.kernel.util.Validator;
33 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
34 import com.liferay.portal.model.ModelListener;
35 import com.liferay.portal.service.persistence.BasePersistence;
36 import com.liferay.portal.spring.hibernate.FinderCache;
37 import com.liferay.portal.spring.hibernate.HibernateUtil;
38 import com.liferay.portal.util.PropsUtil;
39
40 import com.liferay.portlet.imagegallery.NoSuchFolderException;
41 import com.liferay.portlet.imagegallery.model.IGFolder;
42 import com.liferay.portlet.imagegallery.model.impl.IGFolderImpl;
43 import com.liferay.portlet.imagegallery.model.impl.IGFolderModelImpl;
44
45 import com.liferay.util.dao.hibernate.QueryUtil;
46
47 import org.apache.commons.logging.Log;
48 import org.apache.commons.logging.LogFactory;
49
50 import org.hibernate.Query;
51 import org.hibernate.Session;
52
53 import java.util.Collections;
54 import java.util.Iterator;
55 import java.util.List;
56
57
63 public class IGFolderPersistenceImpl extends BasePersistence
64 implements IGFolderPersistence {
65 public IGFolder create(long folderId) {
66 IGFolder igFolder = new IGFolderImpl();
67
68 igFolder.setNew(true);
69 igFolder.setPrimaryKey(folderId);
70
71 String uuid = PortalUUIDUtil.generate();
72
73 igFolder.setUuid(uuid);
74
75 return igFolder;
76 }
77
78 public IGFolder remove(long folderId)
79 throws NoSuchFolderException, SystemException {
80 Session session = null;
81
82 try {
83 session = openSession();
84
85 IGFolder igFolder = (IGFolder)session.get(IGFolderImpl.class,
86 new Long(folderId));
87
88 if (igFolder == null) {
89 if (_log.isWarnEnabled()) {
90 _log.warn("No IGFolder exists with the primary key " +
91 folderId);
92 }
93
94 throw new NoSuchFolderException(
95 "No IGFolder exists with the primary key " + folderId);
96 }
97
98 return remove(igFolder);
99 }
100 catch (NoSuchFolderException nsee) {
101 throw nsee;
102 }
103 catch (Exception e) {
104 throw HibernateUtil.processException(e);
105 }
106 finally {
107 closeSession(session);
108 }
109 }
110
111 public IGFolder remove(IGFolder igFolder) throws SystemException {
112 ModelListener listener = _getListener();
113
114 if (listener != null) {
115 listener.onBeforeRemove(igFolder);
116 }
117
118 igFolder = removeImpl(igFolder);
119
120 if (listener != null) {
121 listener.onAfterRemove(igFolder);
122 }
123
124 return igFolder;
125 }
126
127 protected IGFolder removeImpl(IGFolder igFolder) throws SystemException {
128 Session session = null;
129
130 try {
131 session = openSession();
132
133 session.delete(igFolder);
134
135 session.flush();
136
137 return igFolder;
138 }
139 catch (Exception e) {
140 throw HibernateUtil.processException(e);
141 }
142 finally {
143 closeSession(session);
144
145 FinderCache.clearCache(IGFolder.class.getName());
146 }
147 }
148
149 public IGFolder update(IGFolder igFolder) throws SystemException {
150 return update(igFolder, false);
151 }
152
153 public IGFolder update(IGFolder igFolder, boolean merge)
154 throws SystemException {
155 ModelListener listener = _getListener();
156
157 boolean isNew = igFolder.isNew();
158
159 if (listener != null) {
160 if (isNew) {
161 listener.onBeforeCreate(igFolder);
162 }
163 else {
164 listener.onBeforeUpdate(igFolder);
165 }
166 }
167
168 igFolder = updateImpl(igFolder, merge);
169
170 if (listener != null) {
171 if (isNew) {
172 listener.onAfterCreate(igFolder);
173 }
174 else {
175 listener.onAfterUpdate(igFolder);
176 }
177 }
178
179 return igFolder;
180 }
181
182 public IGFolder updateImpl(
183 com.liferay.portlet.imagegallery.model.IGFolder igFolder, boolean merge)
184 throws SystemException {
185 if (Validator.isNull(igFolder.getUuid())) {
186 String uuid = PortalUUIDUtil.generate();
187
188 igFolder.setUuid(uuid);
189 }
190
191 Session session = null;
192
193 try {
194 session = openSession();
195
196 if (merge) {
197 session.merge(igFolder);
198 }
199 else {
200 if (igFolder.isNew()) {
201 session.save(igFolder);
202 }
203 }
204
205 session.flush();
206
207 igFolder.setNew(false);
208
209 return igFolder;
210 }
211 catch (Exception e) {
212 throw HibernateUtil.processException(e);
213 }
214 finally {
215 closeSession(session);
216
217 FinderCache.clearCache(IGFolder.class.getName());
218 }
219 }
220
221 public IGFolder findByPrimaryKey(long folderId)
222 throws NoSuchFolderException, SystemException {
223 IGFolder igFolder = fetchByPrimaryKey(folderId);
224
225 if (igFolder == null) {
226 if (_log.isWarnEnabled()) {
227 _log.warn("No IGFolder exists with the primary key " +
228 folderId);
229 }
230
231 throw new NoSuchFolderException(
232 "No IGFolder exists with the primary key " + folderId);
233 }
234
235 return igFolder;
236 }
237
238 public IGFolder fetchByPrimaryKey(long folderId) throws SystemException {
239 Session session = null;
240
241 try {
242 session = openSession();
243
244 return (IGFolder)session.get(IGFolderImpl.class, new Long(folderId));
245 }
246 catch (Exception e) {
247 throw HibernateUtil.processException(e);
248 }
249 finally {
250 closeSession(session);
251 }
252 }
253
254 public List findByUuid(String uuid) throws SystemException {
255 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
256 String finderClassName = IGFolder.class.getName();
257 String finderMethodName = "findByUuid";
258 String[] finderParams = new String[] { String.class.getName() };
259 Object[] finderArgs = new Object[] { uuid };
260
261 Object result = null;
262
263 if (finderClassNameCacheEnabled) {
264 result = FinderCache.getResult(finderClassName, finderMethodName,
265 finderParams, finderArgs, getSessionFactory());
266 }
267
268 if (result == null) {
269 Session session = null;
270
271 try {
272 session = openSession();
273
274 StringMaker query = new StringMaker();
275
276 query.append(
277 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
278
279 if (uuid == null) {
280 query.append("uuid_ IS NULL");
281 }
282 else {
283 query.append("uuid_ = ?");
284 }
285
286 query.append(" ");
287
288 query.append("ORDER BY ");
289
290 query.append("folderId ASC, ");
291 query.append("name ASC");
292
293 Query q = session.createQuery(query.toString());
294
295 int queryPos = 0;
296
297 if (uuid != null) {
298 q.setString(queryPos++, uuid);
299 }
300
301 List list = q.list();
302
303 FinderCache.putResult(finderClassNameCacheEnabled,
304 finderClassName, finderMethodName, finderParams,
305 finderArgs, list);
306
307 return list;
308 }
309 catch (Exception e) {
310 throw HibernateUtil.processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315 }
316 else {
317 return (List)result;
318 }
319 }
320
321 public List findByUuid(String uuid, int begin, int end)
322 throws SystemException {
323 return findByUuid(uuid, begin, end, null);
324 }
325
326 public List findByUuid(String uuid, int begin, int end,
327 OrderByComparator obc) throws SystemException {
328 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
329 String finderClassName = IGFolder.class.getName();
330 String finderMethodName = "findByUuid";
331 String[] finderParams = new String[] {
332 String.class.getName(),
333
334 "java.lang.Integer", "java.lang.Integer",
335 "com.liferay.portal.kernel.util.OrderByComparator"
336 };
337 Object[] finderArgs = new Object[] {
338 uuid,
339
340 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
341 };
342
343 Object result = null;
344
345 if (finderClassNameCacheEnabled) {
346 result = FinderCache.getResult(finderClassName, finderMethodName,
347 finderParams, finderArgs, getSessionFactory());
348 }
349
350 if (result == null) {
351 Session session = null;
352
353 try {
354 session = openSession();
355
356 StringMaker query = new StringMaker();
357
358 query.append(
359 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
360
361 if (uuid == null) {
362 query.append("uuid_ IS NULL");
363 }
364 else {
365 query.append("uuid_ = ?");
366 }
367
368 query.append(" ");
369
370 if (obc != null) {
371 query.append("ORDER BY ");
372 query.append(obc.getOrderBy());
373 }
374
375 else {
376 query.append("ORDER BY ");
377
378 query.append("folderId ASC, ");
379 query.append("name ASC");
380 }
381
382 Query q = session.createQuery(query.toString());
383
384 int queryPos = 0;
385
386 if (uuid != null) {
387 q.setString(queryPos++, uuid);
388 }
389
390 List list = QueryUtil.list(q, getDialect(), begin, end);
391
392 FinderCache.putResult(finderClassNameCacheEnabled,
393 finderClassName, finderMethodName, finderParams,
394 finderArgs, list);
395
396 return list;
397 }
398 catch (Exception e) {
399 throw HibernateUtil.processException(e);
400 }
401 finally {
402 closeSession(session);
403 }
404 }
405 else {
406 return (List)result;
407 }
408 }
409
410 public IGFolder findByUuid_First(String uuid, OrderByComparator obc)
411 throws NoSuchFolderException, SystemException {
412 List list = findByUuid(uuid, 0, 1, obc);
413
414 if (list.size() == 0) {
415 StringMaker msg = new StringMaker();
416
417 msg.append("No IGFolder exists with the key {");
418
419 msg.append("uuid=" + uuid);
420
421 msg.append(StringPool.CLOSE_CURLY_BRACE);
422
423 throw new NoSuchFolderException(msg.toString());
424 }
425 else {
426 return (IGFolder)list.get(0);
427 }
428 }
429
430 public IGFolder findByUuid_Last(String uuid, OrderByComparator obc)
431 throws NoSuchFolderException, SystemException {
432 int count = countByUuid(uuid);
433
434 List list = findByUuid(uuid, count - 1, count, obc);
435
436 if (list.size() == 0) {
437 StringMaker msg = new StringMaker();
438
439 msg.append("No IGFolder exists with the key {");
440
441 msg.append("uuid=" + uuid);
442
443 msg.append(StringPool.CLOSE_CURLY_BRACE);
444
445 throw new NoSuchFolderException(msg.toString());
446 }
447 else {
448 return (IGFolder)list.get(0);
449 }
450 }
451
452 public IGFolder[] findByUuid_PrevAndNext(long folderId, String uuid,
453 OrderByComparator obc) throws NoSuchFolderException, SystemException {
454 IGFolder igFolder = findByPrimaryKey(folderId);
455
456 int count = countByUuid(uuid);
457
458 Session session = null;
459
460 try {
461 session = openSession();
462
463 StringMaker query = new StringMaker();
464
465 query.append(
466 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
467
468 if (uuid == null) {
469 query.append("uuid_ IS NULL");
470 }
471 else {
472 query.append("uuid_ = ?");
473 }
474
475 query.append(" ");
476
477 if (obc != null) {
478 query.append("ORDER BY ");
479 query.append(obc.getOrderBy());
480 }
481
482 else {
483 query.append("ORDER BY ");
484
485 query.append("folderId ASC, ");
486 query.append("name ASC");
487 }
488
489 Query q = session.createQuery(query.toString());
490
491 int queryPos = 0;
492
493 if (uuid != null) {
494 q.setString(queryPos++, uuid);
495 }
496
497 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
498
499 IGFolder[] array = new IGFolderImpl[3];
500
501 array[0] = (IGFolder)objArray[0];
502 array[1] = (IGFolder)objArray[1];
503 array[2] = (IGFolder)objArray[2];
504
505 return array;
506 }
507 catch (Exception e) {
508 throw HibernateUtil.processException(e);
509 }
510 finally {
511 closeSession(session);
512 }
513 }
514
515 public IGFolder findByUUID_G(String uuid, long groupId)
516 throws NoSuchFolderException, SystemException {
517 IGFolder igFolder = fetchByUUID_G(uuid, groupId);
518
519 if (igFolder == null) {
520 StringMaker msg = new StringMaker();
521
522 msg.append("No IGFolder exists with the key {");
523
524 msg.append("uuid=" + uuid);
525
526 msg.append(", ");
527 msg.append("groupId=" + groupId);
528
529 msg.append(StringPool.CLOSE_CURLY_BRACE);
530
531 if (_log.isWarnEnabled()) {
532 _log.warn(msg.toString());
533 }
534
535 throw new NoSuchFolderException(msg.toString());
536 }
537
538 return igFolder;
539 }
540
541 public IGFolder fetchByUUID_G(String uuid, long groupId)
542 throws SystemException {
543 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
544 String finderClassName = IGFolder.class.getName();
545 String finderMethodName = "fetchByUUID_G";
546 String[] finderParams = new String[] {
547 String.class.getName(), Long.class.getName()
548 };
549 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
550
551 Object result = null;
552
553 if (finderClassNameCacheEnabled) {
554 result = FinderCache.getResult(finderClassName, finderMethodName,
555 finderParams, finderArgs, getSessionFactory());
556 }
557
558 if (result == null) {
559 Session session = null;
560
561 try {
562 session = openSession();
563
564 StringMaker query = new StringMaker();
565
566 query.append(
567 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
568
569 if (uuid == null) {
570 query.append("uuid_ IS NULL");
571 }
572 else {
573 query.append("uuid_ = ?");
574 }
575
576 query.append(" AND ");
577
578 query.append("groupId = ?");
579
580 query.append(" ");
581
582 query.append("ORDER BY ");
583
584 query.append("folderId ASC, ");
585 query.append("name ASC");
586
587 Query q = session.createQuery(query.toString());
588
589 int queryPos = 0;
590
591 if (uuid != null) {
592 q.setString(queryPos++, uuid);
593 }
594
595 q.setLong(queryPos++, groupId);
596
597 List list = q.list();
598
599 FinderCache.putResult(finderClassNameCacheEnabled,
600 finderClassName, finderMethodName, finderParams,
601 finderArgs, list);
602
603 if (list.size() == 0) {
604 return null;
605 }
606 else {
607 return (IGFolder)list.get(0);
608 }
609 }
610 catch (Exception e) {
611 throw HibernateUtil.processException(e);
612 }
613 finally {
614 closeSession(session);
615 }
616 }
617 else {
618 List list = (List)result;
619
620 if (list.size() == 0) {
621 return null;
622 }
623 else {
624 return (IGFolder)list.get(0);
625 }
626 }
627 }
628
629 public List findByGroupId(long groupId) throws SystemException {
630 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
631 String finderClassName = IGFolder.class.getName();
632 String finderMethodName = "findByGroupId";
633 String[] finderParams = new String[] { Long.class.getName() };
634 Object[] finderArgs = new Object[] { new Long(groupId) };
635
636 Object result = null;
637
638 if (finderClassNameCacheEnabled) {
639 result = FinderCache.getResult(finderClassName, finderMethodName,
640 finderParams, finderArgs, getSessionFactory());
641 }
642
643 if (result == null) {
644 Session session = null;
645
646 try {
647 session = openSession();
648
649 StringMaker query = new StringMaker();
650
651 query.append(
652 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
653
654 query.append("groupId = ?");
655
656 query.append(" ");
657
658 query.append("ORDER BY ");
659
660 query.append("folderId ASC, ");
661 query.append("name ASC");
662
663 Query q = session.createQuery(query.toString());
664
665 int queryPos = 0;
666
667 q.setLong(queryPos++, groupId);
668
669 List list = q.list();
670
671 FinderCache.putResult(finderClassNameCacheEnabled,
672 finderClassName, finderMethodName, finderParams,
673 finderArgs, list);
674
675 return list;
676 }
677 catch (Exception e) {
678 throw HibernateUtil.processException(e);
679 }
680 finally {
681 closeSession(session);
682 }
683 }
684 else {
685 return (List)result;
686 }
687 }
688
689 public List findByGroupId(long groupId, int begin, int end)
690 throws SystemException {
691 return findByGroupId(groupId, begin, end, null);
692 }
693
694 public List findByGroupId(long groupId, int begin, int end,
695 OrderByComparator obc) throws SystemException {
696 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
697 String finderClassName = IGFolder.class.getName();
698 String finderMethodName = "findByGroupId";
699 String[] finderParams = new String[] {
700 Long.class.getName(),
701
702 "java.lang.Integer", "java.lang.Integer",
703 "com.liferay.portal.kernel.util.OrderByComparator"
704 };
705 Object[] finderArgs = new Object[] {
706 new Long(groupId),
707
708 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
709 };
710
711 Object result = null;
712
713 if (finderClassNameCacheEnabled) {
714 result = FinderCache.getResult(finderClassName, finderMethodName,
715 finderParams, finderArgs, getSessionFactory());
716 }
717
718 if (result == null) {
719 Session session = null;
720
721 try {
722 session = openSession();
723
724 StringMaker query = new StringMaker();
725
726 query.append(
727 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
728
729 query.append("groupId = ?");
730
731 query.append(" ");
732
733 if (obc != null) {
734 query.append("ORDER BY ");
735 query.append(obc.getOrderBy());
736 }
737
738 else {
739 query.append("ORDER BY ");
740
741 query.append("folderId ASC, ");
742 query.append("name ASC");
743 }
744
745 Query q = session.createQuery(query.toString());
746
747 int queryPos = 0;
748
749 q.setLong(queryPos++, groupId);
750
751 List list = QueryUtil.list(q, getDialect(), begin, end);
752
753 FinderCache.putResult(finderClassNameCacheEnabled,
754 finderClassName, finderMethodName, finderParams,
755 finderArgs, list);
756
757 return list;
758 }
759 catch (Exception e) {
760 throw HibernateUtil.processException(e);
761 }
762 finally {
763 closeSession(session);
764 }
765 }
766 else {
767 return (List)result;
768 }
769 }
770
771 public IGFolder findByGroupId_First(long groupId, OrderByComparator obc)
772 throws NoSuchFolderException, SystemException {
773 List list = findByGroupId(groupId, 0, 1, obc);
774
775 if (list.size() == 0) {
776 StringMaker msg = new StringMaker();
777
778 msg.append("No IGFolder exists with the key {");
779
780 msg.append("groupId=" + groupId);
781
782 msg.append(StringPool.CLOSE_CURLY_BRACE);
783
784 throw new NoSuchFolderException(msg.toString());
785 }
786 else {
787 return (IGFolder)list.get(0);
788 }
789 }
790
791 public IGFolder findByGroupId_Last(long groupId, OrderByComparator obc)
792 throws NoSuchFolderException, SystemException {
793 int count = countByGroupId(groupId);
794
795 List list = findByGroupId(groupId, count - 1, count, obc);
796
797 if (list.size() == 0) {
798 StringMaker msg = new StringMaker();
799
800 msg.append("No IGFolder exists with the key {");
801
802 msg.append("groupId=" + groupId);
803
804 msg.append(StringPool.CLOSE_CURLY_BRACE);
805
806 throw new NoSuchFolderException(msg.toString());
807 }
808 else {
809 return (IGFolder)list.get(0);
810 }
811 }
812
813 public IGFolder[] findByGroupId_PrevAndNext(long folderId, long groupId,
814 OrderByComparator obc) throws NoSuchFolderException, SystemException {
815 IGFolder igFolder = findByPrimaryKey(folderId);
816
817 int count = countByGroupId(groupId);
818
819 Session session = null;
820
821 try {
822 session = openSession();
823
824 StringMaker query = new StringMaker();
825
826 query.append(
827 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
828
829 query.append("groupId = ?");
830
831 query.append(" ");
832
833 if (obc != null) {
834 query.append("ORDER BY ");
835 query.append(obc.getOrderBy());
836 }
837
838 else {
839 query.append("ORDER BY ");
840
841 query.append("folderId ASC, ");
842 query.append("name ASC");
843 }
844
845 Query q = session.createQuery(query.toString());
846
847 int queryPos = 0;
848
849 q.setLong(queryPos++, groupId);
850
851 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
852
853 IGFolder[] array = new IGFolderImpl[3];
854
855 array[0] = (IGFolder)objArray[0];
856 array[1] = (IGFolder)objArray[1];
857 array[2] = (IGFolder)objArray[2];
858
859 return array;
860 }
861 catch (Exception e) {
862 throw HibernateUtil.processException(e);
863 }
864 finally {
865 closeSession(session);
866 }
867 }
868
869 public List findByCompanyId(long companyId) throws SystemException {
870 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
871 String finderClassName = IGFolder.class.getName();
872 String finderMethodName = "findByCompanyId";
873 String[] finderParams = new String[] { Long.class.getName() };
874 Object[] finderArgs = new Object[] { new Long(companyId) };
875
876 Object result = null;
877
878 if (finderClassNameCacheEnabled) {
879 result = FinderCache.getResult(finderClassName, finderMethodName,
880 finderParams, finderArgs, getSessionFactory());
881 }
882
883 if (result == null) {
884 Session session = null;
885
886 try {
887 session = openSession();
888
889 StringMaker query = new StringMaker();
890
891 query.append(
892 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
893
894 query.append("companyId = ?");
895
896 query.append(" ");
897
898 query.append("ORDER BY ");
899
900 query.append("folderId ASC, ");
901 query.append("name ASC");
902
903 Query q = session.createQuery(query.toString());
904
905 int queryPos = 0;
906
907 q.setLong(queryPos++, companyId);
908
909 List list = q.list();
910
911 FinderCache.putResult(finderClassNameCacheEnabled,
912 finderClassName, finderMethodName, finderParams,
913 finderArgs, list);
914
915 return list;
916 }
917 catch (Exception e) {
918 throw HibernateUtil.processException(e);
919 }
920 finally {
921 closeSession(session);
922 }
923 }
924 else {
925 return (List)result;
926 }
927 }
928
929 public List findByCompanyId(long companyId, int begin, int end)
930 throws SystemException {
931 return findByCompanyId(companyId, begin, end, null);
932 }
933
934 public List findByCompanyId(long companyId, int begin, int end,
935 OrderByComparator obc) throws SystemException {
936 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
937 String finderClassName = IGFolder.class.getName();
938 String finderMethodName = "findByCompanyId";
939 String[] finderParams = new String[] {
940 Long.class.getName(),
941
942 "java.lang.Integer", "java.lang.Integer",
943 "com.liferay.portal.kernel.util.OrderByComparator"
944 };
945 Object[] finderArgs = new Object[] {
946 new Long(companyId),
947
948 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
949 };
950
951 Object result = null;
952
953 if (finderClassNameCacheEnabled) {
954 result = FinderCache.getResult(finderClassName, finderMethodName,
955 finderParams, finderArgs, getSessionFactory());
956 }
957
958 if (result == null) {
959 Session session = null;
960
961 try {
962 session = openSession();
963
964 StringMaker query = new StringMaker();
965
966 query.append(
967 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
968
969 query.append("companyId = ?");
970
971 query.append(" ");
972
973 if (obc != null) {
974 query.append("ORDER BY ");
975 query.append(obc.getOrderBy());
976 }
977
978 else {
979 query.append("ORDER BY ");
980
981 query.append("folderId ASC, ");
982 query.append("name ASC");
983 }
984
985 Query q = session.createQuery(query.toString());
986
987 int queryPos = 0;
988
989 q.setLong(queryPos++, companyId);
990
991 List list = QueryUtil.list(q, getDialect(), begin, end);
992
993 FinderCache.putResult(finderClassNameCacheEnabled,
994 finderClassName, finderMethodName, finderParams,
995 finderArgs, list);
996
997 return list;
998 }
999 catch (Exception e) {
1000 throw HibernateUtil.processException(e);
1001 }
1002 finally {
1003 closeSession(session);
1004 }
1005 }
1006 else {
1007 return (List)result;
1008 }
1009 }
1010
1011 public IGFolder findByCompanyId_First(long companyId, OrderByComparator obc)
1012 throws NoSuchFolderException, SystemException {
1013 List list = findByCompanyId(companyId, 0, 1, obc);
1014
1015 if (list.size() == 0) {
1016 StringMaker msg = new StringMaker();
1017
1018 msg.append("No IGFolder exists with the key {");
1019
1020 msg.append("companyId=" + companyId);
1021
1022 msg.append(StringPool.CLOSE_CURLY_BRACE);
1023
1024 throw new NoSuchFolderException(msg.toString());
1025 }
1026 else {
1027 return (IGFolder)list.get(0);
1028 }
1029 }
1030
1031 public IGFolder findByCompanyId_Last(long companyId, OrderByComparator obc)
1032 throws NoSuchFolderException, SystemException {
1033 int count = countByCompanyId(companyId);
1034
1035 List list = findByCompanyId(companyId, count - 1, count, obc);
1036
1037 if (list.size() == 0) {
1038 StringMaker msg = new StringMaker();
1039
1040 msg.append("No IGFolder exists with the key {");
1041
1042 msg.append("companyId=" + companyId);
1043
1044 msg.append(StringPool.CLOSE_CURLY_BRACE);
1045
1046 throw new NoSuchFolderException(msg.toString());
1047 }
1048 else {
1049 return (IGFolder)list.get(0);
1050 }
1051 }
1052
1053 public IGFolder[] findByCompanyId_PrevAndNext(long folderId,
1054 long companyId, OrderByComparator obc)
1055 throws NoSuchFolderException, SystemException {
1056 IGFolder igFolder = findByPrimaryKey(folderId);
1057
1058 int count = countByCompanyId(companyId);
1059
1060 Session session = null;
1061
1062 try {
1063 session = openSession();
1064
1065 StringMaker query = new StringMaker();
1066
1067 query.append(
1068 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1069
1070 query.append("companyId = ?");
1071
1072 query.append(" ");
1073
1074 if (obc != null) {
1075 query.append("ORDER BY ");
1076 query.append(obc.getOrderBy());
1077 }
1078
1079 else {
1080 query.append("ORDER BY ");
1081
1082 query.append("folderId ASC, ");
1083 query.append("name ASC");
1084 }
1085
1086 Query q = session.createQuery(query.toString());
1087
1088 int queryPos = 0;
1089
1090 q.setLong(queryPos++, companyId);
1091
1092 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
1093
1094 IGFolder[] array = new IGFolderImpl[3];
1095
1096 array[0] = (IGFolder)objArray[0];
1097 array[1] = (IGFolder)objArray[1];
1098 array[2] = (IGFolder)objArray[2];
1099
1100 return array;
1101 }
1102 catch (Exception e) {
1103 throw HibernateUtil.processException(e);
1104 }
1105 finally {
1106 closeSession(session);
1107 }
1108 }
1109
1110 public List findByG_P(long groupId, long parentFolderId)
1111 throws SystemException {
1112 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1113 String finderClassName = IGFolder.class.getName();
1114 String finderMethodName = "findByG_P";
1115 String[] finderParams = new String[] {
1116 Long.class.getName(), Long.class.getName()
1117 };
1118 Object[] finderArgs = new Object[] {
1119 new Long(groupId), new Long(parentFolderId)
1120 };
1121
1122 Object result = null;
1123
1124 if (finderClassNameCacheEnabled) {
1125 result = FinderCache.getResult(finderClassName, finderMethodName,
1126 finderParams, finderArgs, getSessionFactory());
1127 }
1128
1129 if (result == null) {
1130 Session session = null;
1131
1132 try {
1133 session = openSession();
1134
1135 StringMaker query = new StringMaker();
1136
1137 query.append(
1138 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1139
1140 query.append("groupId = ?");
1141
1142 query.append(" AND ");
1143
1144 query.append("parentFolderId = ?");
1145
1146 query.append(" ");
1147
1148 query.append("ORDER BY ");
1149
1150 query.append("folderId ASC, ");
1151 query.append("name ASC");
1152
1153 Query q = session.createQuery(query.toString());
1154
1155 int queryPos = 0;
1156
1157 q.setLong(queryPos++, groupId);
1158
1159 q.setLong(queryPos++, parentFolderId);
1160
1161 List list = q.list();
1162
1163 FinderCache.putResult(finderClassNameCacheEnabled,
1164 finderClassName, finderMethodName, finderParams,
1165 finderArgs, list);
1166
1167 return list;
1168 }
1169 catch (Exception e) {
1170 throw HibernateUtil.processException(e);
1171 }
1172 finally {
1173 closeSession(session);
1174 }
1175 }
1176 else {
1177 return (List)result;
1178 }
1179 }
1180
1181 public List findByG_P(long groupId, long parentFolderId, int begin, int end)
1182 throws SystemException {
1183 return findByG_P(groupId, parentFolderId, begin, end, null);
1184 }
1185
1186 public List findByG_P(long groupId, long parentFolderId, int begin,
1187 int end, OrderByComparator obc) throws SystemException {
1188 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1189 String finderClassName = IGFolder.class.getName();
1190 String finderMethodName = "findByG_P";
1191 String[] finderParams = new String[] {
1192 Long.class.getName(), Long.class.getName(),
1193
1194 "java.lang.Integer", "java.lang.Integer",
1195 "com.liferay.portal.kernel.util.OrderByComparator"
1196 };
1197 Object[] finderArgs = new Object[] {
1198 new Long(groupId), new Long(parentFolderId),
1199
1200 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1201 };
1202
1203 Object result = null;
1204
1205 if (finderClassNameCacheEnabled) {
1206 result = FinderCache.getResult(finderClassName, finderMethodName,
1207 finderParams, finderArgs, getSessionFactory());
1208 }
1209
1210 if (result == null) {
1211 Session session = null;
1212
1213 try {
1214 session = openSession();
1215
1216 StringMaker query = new StringMaker();
1217
1218 query.append(
1219 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1220
1221 query.append("groupId = ?");
1222
1223 query.append(" AND ");
1224
1225 query.append("parentFolderId = ?");
1226
1227 query.append(" ");
1228
1229 if (obc != null) {
1230 query.append("ORDER BY ");
1231 query.append(obc.getOrderBy());
1232 }
1233
1234 else {
1235 query.append("ORDER BY ");
1236
1237 query.append("folderId ASC, ");
1238 query.append("name ASC");
1239 }
1240
1241 Query q = session.createQuery(query.toString());
1242
1243 int queryPos = 0;
1244
1245 q.setLong(queryPos++, groupId);
1246
1247 q.setLong(queryPos++, parentFolderId);
1248
1249 List list = QueryUtil.list(q, getDialect(), begin, end);
1250
1251 FinderCache.putResult(finderClassNameCacheEnabled,
1252 finderClassName, finderMethodName, finderParams,
1253 finderArgs, list);
1254
1255 return list;
1256 }
1257 catch (Exception e) {
1258 throw HibernateUtil.processException(e);
1259 }
1260 finally {
1261 closeSession(session);
1262 }
1263 }
1264 else {
1265 return (List)result;
1266 }
1267 }
1268
1269 public IGFolder findByG_P_First(long groupId, long parentFolderId,
1270 OrderByComparator obc) throws NoSuchFolderException, SystemException {
1271 List list = findByG_P(groupId, parentFolderId, 0, 1, obc);
1272
1273 if (list.size() == 0) {
1274 StringMaker msg = new StringMaker();
1275
1276 msg.append("No IGFolder exists with the key {");
1277
1278 msg.append("groupId=" + groupId);
1279
1280 msg.append(", ");
1281 msg.append("parentFolderId=" + parentFolderId);
1282
1283 msg.append(StringPool.CLOSE_CURLY_BRACE);
1284
1285 throw new NoSuchFolderException(msg.toString());
1286 }
1287 else {
1288 return (IGFolder)list.get(0);
1289 }
1290 }
1291
1292 public IGFolder findByG_P_Last(long groupId, long parentFolderId,
1293 OrderByComparator obc) throws NoSuchFolderException, SystemException {
1294 int count = countByG_P(groupId, parentFolderId);
1295
1296 List list = findByG_P(groupId, parentFolderId, count - 1, count, obc);
1297
1298 if (list.size() == 0) {
1299 StringMaker msg = new StringMaker();
1300
1301 msg.append("No IGFolder exists with the key {");
1302
1303 msg.append("groupId=" + groupId);
1304
1305 msg.append(", ");
1306 msg.append("parentFolderId=" + parentFolderId);
1307
1308 msg.append(StringPool.CLOSE_CURLY_BRACE);
1309
1310 throw new NoSuchFolderException(msg.toString());
1311 }
1312 else {
1313 return (IGFolder)list.get(0);
1314 }
1315 }
1316
1317 public IGFolder[] findByG_P_PrevAndNext(long folderId, long groupId,
1318 long parentFolderId, OrderByComparator obc)
1319 throws NoSuchFolderException, SystemException {
1320 IGFolder igFolder = findByPrimaryKey(folderId);
1321
1322 int count = countByG_P(groupId, parentFolderId);
1323
1324 Session session = null;
1325
1326 try {
1327 session = openSession();
1328
1329 StringMaker query = new StringMaker();
1330
1331 query.append(
1332 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1333
1334 query.append("groupId = ?");
1335
1336 query.append(" AND ");
1337
1338 query.append("parentFolderId = ?");
1339
1340 query.append(" ");
1341
1342 if (obc != null) {
1343 query.append("ORDER BY ");
1344 query.append(obc.getOrderBy());
1345 }
1346
1347 else {
1348 query.append("ORDER BY ");
1349
1350 query.append("folderId ASC, ");
1351 query.append("name ASC");
1352 }
1353
1354 Query q = session.createQuery(query.toString());
1355
1356 int queryPos = 0;
1357
1358 q.setLong(queryPos++, groupId);
1359
1360 q.setLong(queryPos++, parentFolderId);
1361
1362 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, igFolder);
1363
1364 IGFolder[] array = new IGFolderImpl[3];
1365
1366 array[0] = (IGFolder)objArray[0];
1367 array[1] = (IGFolder)objArray[1];
1368 array[2] = (IGFolder)objArray[2];
1369
1370 return array;
1371 }
1372 catch (Exception e) {
1373 throw HibernateUtil.processException(e);
1374 }
1375 finally {
1376 closeSession(session);
1377 }
1378 }
1379
1380 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer)
1381 throws SystemException {
1382 Session session = null;
1383
1384 try {
1385 session = openSession();
1386
1387 DynamicQuery query = queryInitializer.initialize(session);
1388
1389 return query.list();
1390 }
1391 catch (Exception e) {
1392 throw HibernateUtil.processException(e);
1393 }
1394 finally {
1395 closeSession(session);
1396 }
1397 }
1398
1399 public List findWithDynamicQuery(DynamicQueryInitializer queryInitializer,
1400 int begin, int end) throws SystemException {
1401 Session session = null;
1402
1403 try {
1404 session = openSession();
1405
1406 DynamicQuery query = queryInitializer.initialize(session);
1407
1408 query.setLimit(begin, end);
1409
1410 return query.list();
1411 }
1412 catch (Exception e) {
1413 throw HibernateUtil.processException(e);
1414 }
1415 finally {
1416 closeSession(session);
1417 }
1418 }
1419
1420 public List findAll() throws SystemException {
1421 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1422 }
1423
1424 public List findAll(int begin, int end) throws SystemException {
1425 return findAll(begin, end, null);
1426 }
1427
1428 public List findAll(int begin, int end, OrderByComparator obc)
1429 throws SystemException {
1430 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1431 String finderClassName = IGFolder.class.getName();
1432 String finderMethodName = "findAll";
1433 String[] finderParams = new String[] {
1434 "java.lang.Integer", "java.lang.Integer",
1435 "com.liferay.portal.kernel.util.OrderByComparator"
1436 };
1437 Object[] finderArgs = new Object[] {
1438 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
1439 };
1440
1441 Object result = null;
1442
1443 if (finderClassNameCacheEnabled) {
1444 result = FinderCache.getResult(finderClassName, finderMethodName,
1445 finderParams, finderArgs, getSessionFactory());
1446 }
1447
1448 if (result == null) {
1449 Session session = null;
1450
1451 try {
1452 session = openSession();
1453
1454 StringMaker query = new StringMaker();
1455
1456 query.append(
1457 "FROM com.liferay.portlet.imagegallery.model.IGFolder ");
1458
1459 if (obc != null) {
1460 query.append("ORDER BY ");
1461 query.append(obc.getOrderBy());
1462 }
1463
1464 else {
1465 query.append("ORDER BY ");
1466
1467 query.append("folderId ASC, ");
1468 query.append("name ASC");
1469 }
1470
1471 Query q = session.createQuery(query.toString());
1472
1473 List list = QueryUtil.list(q, getDialect(), begin, end);
1474
1475 if (obc == null) {
1476 Collections.sort(list);
1477 }
1478
1479 FinderCache.putResult(finderClassNameCacheEnabled,
1480 finderClassName, finderMethodName, finderParams,
1481 finderArgs, list);
1482
1483 return list;
1484 }
1485 catch (Exception e) {
1486 throw HibernateUtil.processException(e);
1487 }
1488 finally {
1489 closeSession(session);
1490 }
1491 }
1492 else {
1493 return (List)result;
1494 }
1495 }
1496
1497 public void removeByUuid(String uuid) throws SystemException {
1498 Iterator itr = findByUuid(uuid).iterator();
1499
1500 while (itr.hasNext()) {
1501 IGFolder igFolder = (IGFolder)itr.next();
1502
1503 remove(igFolder);
1504 }
1505 }
1506
1507 public void removeByUUID_G(String uuid, long groupId)
1508 throws NoSuchFolderException, SystemException {
1509 IGFolder igFolder = findByUUID_G(uuid, groupId);
1510
1511 remove(igFolder);
1512 }
1513
1514 public void removeByGroupId(long groupId) throws SystemException {
1515 Iterator itr = findByGroupId(groupId).iterator();
1516
1517 while (itr.hasNext()) {
1518 IGFolder igFolder = (IGFolder)itr.next();
1519
1520 remove(igFolder);
1521 }
1522 }
1523
1524 public void removeByCompanyId(long companyId) throws SystemException {
1525 Iterator itr = findByCompanyId(companyId).iterator();
1526
1527 while (itr.hasNext()) {
1528 IGFolder igFolder = (IGFolder)itr.next();
1529
1530 remove(igFolder);
1531 }
1532 }
1533
1534 public void removeByG_P(long groupId, long parentFolderId)
1535 throws SystemException {
1536 Iterator itr = findByG_P(groupId, parentFolderId).iterator();
1537
1538 while (itr.hasNext()) {
1539 IGFolder igFolder = (IGFolder)itr.next();
1540
1541 remove(igFolder);
1542 }
1543 }
1544
1545 public void removeAll() throws SystemException {
1546 Iterator itr = findAll().iterator();
1547
1548 while (itr.hasNext()) {
1549 remove((IGFolder)itr.next());
1550 }
1551 }
1552
1553 public int countByUuid(String uuid) throws SystemException {
1554 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1555 String finderClassName = IGFolder.class.getName();
1556 String finderMethodName = "countByUuid";
1557 String[] finderParams = new String[] { String.class.getName() };
1558 Object[] finderArgs = new Object[] { uuid };
1559
1560 Object result = null;
1561
1562 if (finderClassNameCacheEnabled) {
1563 result = FinderCache.getResult(finderClassName, finderMethodName,
1564 finderParams, finderArgs, getSessionFactory());
1565 }
1566
1567 if (result == null) {
1568 Session session = null;
1569
1570 try {
1571 session = openSession();
1572
1573 StringMaker query = new StringMaker();
1574
1575 query.append("SELECT COUNT(*) ");
1576 query.append(
1577 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1578
1579 if (uuid == null) {
1580 query.append("uuid_ IS NULL");
1581 }
1582 else {
1583 query.append("uuid_ = ?");
1584 }
1585
1586 query.append(" ");
1587
1588 Query q = session.createQuery(query.toString());
1589
1590 int queryPos = 0;
1591
1592 if (uuid != null) {
1593 q.setString(queryPos++, uuid);
1594 }
1595
1596 Long count = null;
1597
1598 Iterator itr = q.list().iterator();
1599
1600 if (itr.hasNext()) {
1601 count = (Long)itr.next();
1602 }
1603
1604 if (count == null) {
1605 count = new Long(0);
1606 }
1607
1608 FinderCache.putResult(finderClassNameCacheEnabled,
1609 finderClassName, finderMethodName, finderParams,
1610 finderArgs, count);
1611
1612 return count.intValue();
1613 }
1614 catch (Exception e) {
1615 throw HibernateUtil.processException(e);
1616 }
1617 finally {
1618 closeSession(session);
1619 }
1620 }
1621 else {
1622 return ((Long)result).intValue();
1623 }
1624 }
1625
1626 public int countByUUID_G(String uuid, long groupId)
1627 throws SystemException {
1628 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1629 String finderClassName = IGFolder.class.getName();
1630 String finderMethodName = "countByUUID_G";
1631 String[] finderParams = new String[] {
1632 String.class.getName(), Long.class.getName()
1633 };
1634 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1635
1636 Object result = null;
1637
1638 if (finderClassNameCacheEnabled) {
1639 result = FinderCache.getResult(finderClassName, finderMethodName,
1640 finderParams, finderArgs, getSessionFactory());
1641 }
1642
1643 if (result == null) {
1644 Session session = null;
1645
1646 try {
1647 session = openSession();
1648
1649 StringMaker query = new StringMaker();
1650
1651 query.append("SELECT COUNT(*) ");
1652 query.append(
1653 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1654
1655 if (uuid == null) {
1656 query.append("uuid_ IS NULL");
1657 }
1658 else {
1659 query.append("uuid_ = ?");
1660 }
1661
1662 query.append(" AND ");
1663
1664 query.append("groupId = ?");
1665
1666 query.append(" ");
1667
1668 Query q = session.createQuery(query.toString());
1669
1670 int queryPos = 0;
1671
1672 if (uuid != null) {
1673 q.setString(queryPos++, uuid);
1674 }
1675
1676 q.setLong(queryPos++, groupId);
1677
1678 Long count = null;
1679
1680 Iterator itr = q.list().iterator();
1681
1682 if (itr.hasNext()) {
1683 count = (Long)itr.next();
1684 }
1685
1686 if (count == null) {
1687 count = new Long(0);
1688 }
1689
1690 FinderCache.putResult(finderClassNameCacheEnabled,
1691 finderClassName, finderMethodName, finderParams,
1692 finderArgs, count);
1693
1694 return count.intValue();
1695 }
1696 catch (Exception e) {
1697 throw HibernateUtil.processException(e);
1698 }
1699 finally {
1700 closeSession(session);
1701 }
1702 }
1703 else {
1704 return ((Long)result).intValue();
1705 }
1706 }
1707
1708 public int countByGroupId(long groupId) throws SystemException {
1709 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1710 String finderClassName = IGFolder.class.getName();
1711 String finderMethodName = "countByGroupId";
1712 String[] finderParams = new String[] { Long.class.getName() };
1713 Object[] finderArgs = new Object[] { new Long(groupId) };
1714
1715 Object result = null;
1716
1717 if (finderClassNameCacheEnabled) {
1718 result = FinderCache.getResult(finderClassName, finderMethodName,
1719 finderParams, finderArgs, getSessionFactory());
1720 }
1721
1722 if (result == null) {
1723 Session session = null;
1724
1725 try {
1726 session = openSession();
1727
1728 StringMaker query = new StringMaker();
1729
1730 query.append("SELECT COUNT(*) ");
1731 query.append(
1732 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1733
1734 query.append("groupId = ?");
1735
1736 query.append(" ");
1737
1738 Query q = session.createQuery(query.toString());
1739
1740 int queryPos = 0;
1741
1742 q.setLong(queryPos++, groupId);
1743
1744 Long count = null;
1745
1746 Iterator itr = q.list().iterator();
1747
1748 if (itr.hasNext()) {
1749 count = (Long)itr.next();
1750 }
1751
1752 if (count == null) {
1753 count = new Long(0);
1754 }
1755
1756 FinderCache.putResult(finderClassNameCacheEnabled,
1757 finderClassName, finderMethodName, finderParams,
1758 finderArgs, count);
1759
1760 return count.intValue();
1761 }
1762 catch (Exception e) {
1763 throw HibernateUtil.processException(e);
1764 }
1765 finally {
1766 closeSession(session);
1767 }
1768 }
1769 else {
1770 return ((Long)result).intValue();
1771 }
1772 }
1773
1774 public int countByCompanyId(long companyId) throws SystemException {
1775 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1776 String finderClassName = IGFolder.class.getName();
1777 String finderMethodName = "countByCompanyId";
1778 String[] finderParams = new String[] { Long.class.getName() };
1779 Object[] finderArgs = new Object[] { new Long(companyId) };
1780
1781 Object result = null;
1782
1783 if (finderClassNameCacheEnabled) {
1784 result = FinderCache.getResult(finderClassName, finderMethodName,
1785 finderParams, finderArgs, getSessionFactory());
1786 }
1787
1788 if (result == null) {
1789 Session session = null;
1790
1791 try {
1792 session = openSession();
1793
1794 StringMaker query = new StringMaker();
1795
1796 query.append("SELECT COUNT(*) ");
1797 query.append(
1798 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1799
1800 query.append("companyId = ?");
1801
1802 query.append(" ");
1803
1804 Query q = session.createQuery(query.toString());
1805
1806 int queryPos = 0;
1807
1808 q.setLong(queryPos++, companyId);
1809
1810 Long count = null;
1811
1812 Iterator itr = q.list().iterator();
1813
1814 if (itr.hasNext()) {
1815 count = (Long)itr.next();
1816 }
1817
1818 if (count == null) {
1819 count = new Long(0);
1820 }
1821
1822 FinderCache.putResult(finderClassNameCacheEnabled,
1823 finderClassName, finderMethodName, finderParams,
1824 finderArgs, count);
1825
1826 return count.intValue();
1827 }
1828 catch (Exception e) {
1829 throw HibernateUtil.processException(e);
1830 }
1831 finally {
1832 closeSession(session);
1833 }
1834 }
1835 else {
1836 return ((Long)result).intValue();
1837 }
1838 }
1839
1840 public int countByG_P(long groupId, long parentFolderId)
1841 throws SystemException {
1842 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1843 String finderClassName = IGFolder.class.getName();
1844 String finderMethodName = "countByG_P";
1845 String[] finderParams = new String[] {
1846 Long.class.getName(), Long.class.getName()
1847 };
1848 Object[] finderArgs = new Object[] {
1849 new Long(groupId), new Long(parentFolderId)
1850 };
1851
1852 Object result = null;
1853
1854 if (finderClassNameCacheEnabled) {
1855 result = FinderCache.getResult(finderClassName, finderMethodName,
1856 finderParams, finderArgs, getSessionFactory());
1857 }
1858
1859 if (result == null) {
1860 Session session = null;
1861
1862 try {
1863 session = openSession();
1864
1865 StringMaker query = new StringMaker();
1866
1867 query.append("SELECT COUNT(*) ");
1868 query.append(
1869 "FROM com.liferay.portlet.imagegallery.model.IGFolder WHERE ");
1870
1871 query.append("groupId = ?");
1872
1873 query.append(" AND ");
1874
1875 query.append("parentFolderId = ?");
1876
1877 query.append(" ");
1878
1879 Query q = session.createQuery(query.toString());
1880
1881 int queryPos = 0;
1882
1883 q.setLong(queryPos++, groupId);
1884
1885 q.setLong(queryPos++, parentFolderId);
1886
1887 Long count = null;
1888
1889 Iterator itr = q.list().iterator();
1890
1891 if (itr.hasNext()) {
1892 count = (Long)itr.next();
1893 }
1894
1895 if (count == null) {
1896 count = new Long(0);
1897 }
1898
1899 FinderCache.putResult(finderClassNameCacheEnabled,
1900 finderClassName, finderMethodName, finderParams,
1901 finderArgs, count);
1902
1903 return count.intValue();
1904 }
1905 catch (Exception e) {
1906 throw HibernateUtil.processException(e);
1907 }
1908 finally {
1909 closeSession(session);
1910 }
1911 }
1912 else {
1913 return ((Long)result).intValue();
1914 }
1915 }
1916
1917 public int countAll() throws SystemException {
1918 boolean finderClassNameCacheEnabled = IGFolderModelImpl.CACHE_ENABLED;
1919 String finderClassName = IGFolder.class.getName();
1920 String finderMethodName = "countAll";
1921 String[] finderParams = new String[] { };
1922 Object[] finderArgs = new Object[] { };
1923
1924 Object result = null;
1925
1926 if (finderClassNameCacheEnabled) {
1927 result = FinderCache.getResult(finderClassName, finderMethodName,
1928 finderParams, finderArgs, getSessionFactory());
1929 }
1930
1931 if (result == null) {
1932 Session session = null;
1933
1934 try {
1935 session = openSession();
1936
1937 Query q = session.createQuery(
1938 "SELECT COUNT(*) FROM com.liferay.portlet.imagegallery.model.IGFolder");
1939
1940 Long count = null;
1941
1942 Iterator itr = q.list().iterator();
1943
1944 if (itr.hasNext()) {
1945 count = (Long)itr.next();
1946 }
1947
1948 if (count == null) {
1949 count = new Long(0);
1950 }
1951
1952 FinderCache.putResult(finderClassNameCacheEnabled,
1953 finderClassName, finderMethodName, finderParams,
1954 finderArgs, count);
1955
1956 return count.intValue();
1957 }
1958 catch (Exception e) {
1959 throw HibernateUtil.processException(e);
1960 }
1961 finally {
1962 closeSession(session);
1963 }
1964 }
1965 else {
1966 return ((Long)result).intValue();
1967 }
1968 }
1969
1970 protected void initDao() {
1971 }
1972
1973 private static ModelListener _getListener() {
1974 if (Validator.isNotNull(_LISTENER)) {
1975 try {
1976 return (ModelListener)Class.forName(_LISTENER).newInstance();
1977 }
1978 catch (Exception e) {
1979 _log.error(e);
1980 }
1981 }
1982
1983 return null;
1984 }
1985
1986 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
1987 "value.object.listener.com.liferay.portlet.imagegallery.model.IGFolder"));
1988 private static Log _log = LogFactory.getLog(IGFolderPersistenceImpl.class);
1989}