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