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