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.NoSuchProposalException;
40 import com.liferay.portlet.tasks.model.TasksProposal;
41 import com.liferay.portlet.tasks.model.impl.TasksProposalImpl;
42 import com.liferay.portlet.tasks.model.impl.TasksProposalModelImpl;
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 TasksProposalPersistenceImpl extends BasePersistence
64 implements TasksProposalPersistence {
65 public TasksProposal create(long proposalId) {
66 TasksProposal tasksProposal = new TasksProposalImpl();
67
68 tasksProposal.setNew(true);
69 tasksProposal.setPrimaryKey(proposalId);
70
71 return tasksProposal;
72 }
73
74 public TasksProposal remove(long proposalId)
75 throws NoSuchProposalException, SystemException {
76 Session session = null;
77
78 try {
79 session = openSession();
80
81 TasksProposal tasksProposal = (TasksProposal)session.get(TasksProposalImpl.class,
82 new Long(proposalId));
83
84 if (tasksProposal == null) {
85 if (_log.isWarnEnabled()) {
86 _log.warn("No TasksProposal exists with the primary key " +
87 proposalId);
88 }
89
90 throw new NoSuchProposalException(
91 "No TasksProposal exists with the primary key " +
92 proposalId);
93 }
94
95 return remove(tasksProposal);
96 }
97 catch (NoSuchProposalException nsee) {
98 throw nsee;
99 }
100 catch (Exception e) {
101 throw HibernateUtil.processException(e);
102 }
103 finally {
104 closeSession(session);
105 }
106 }
107
108 public TasksProposal remove(TasksProposal tasksProposal)
109 throws SystemException {
110 if (_listeners != null) {
111 for (ModelListener listener : _listeners) {
112 listener.onBeforeRemove(tasksProposal);
113 }
114 }
115
116 tasksProposal = removeImpl(tasksProposal);
117
118 if (_listeners != null) {
119 for (ModelListener listener : _listeners) {
120 listener.onAfterRemove(tasksProposal);
121 }
122 }
123
124 return tasksProposal;
125 }
126
127 protected TasksProposal removeImpl(TasksProposal tasksProposal)
128 throws SystemException {
129 Session session = null;
130
131 try {
132 session = openSession();
133
134 session.delete(tasksProposal);
135
136 session.flush();
137
138 return tasksProposal;
139 }
140 catch (Exception e) {
141 throw HibernateUtil.processException(e);
142 }
143 finally {
144 closeSession(session);
145
146 FinderCache.clearCache(TasksProposal.class.getName());
147 }
148 }
149
150
153 public TasksProposal update(TasksProposal tasksProposal)
154 throws SystemException {
155 if (_log.isWarnEnabled()) {
156 _log.warn(
157 "Using the deprecated update(TasksProposal tasksProposal) method. Use update(TasksProposal tasksProposal, boolean merge) instead.");
158 }
159
160 return update(tasksProposal, false);
161 }
162
163
176 public TasksProposal update(TasksProposal tasksProposal, boolean merge)
177 throws SystemException {
178 boolean isNew = tasksProposal.isNew();
179
180 if (_listeners != null) {
181 for (ModelListener listener : _listeners) {
182 if (isNew) {
183 listener.onBeforeCreate(tasksProposal);
184 }
185 else {
186 listener.onBeforeUpdate(tasksProposal);
187 }
188 }
189 }
190
191 tasksProposal = updateImpl(tasksProposal, merge);
192
193 if (_listeners != null) {
194 for (ModelListener listener : _listeners) {
195 if (isNew) {
196 listener.onAfterCreate(tasksProposal);
197 }
198 else {
199 listener.onAfterUpdate(tasksProposal);
200 }
201 }
202 }
203
204 return tasksProposal;
205 }
206
207 public TasksProposal updateImpl(
208 com.liferay.portlet.tasks.model.TasksProposal tasksProposal,
209 boolean merge) throws SystemException {
210 Session session = null;
211
212 try {
213 session = openSession();
214
215 if (merge) {
216 session.merge(tasksProposal);
217 }
218 else {
219 if (tasksProposal.isNew()) {
220 session.save(tasksProposal);
221 }
222 }
223
224 session.flush();
225
226 tasksProposal.setNew(false);
227
228 return tasksProposal;
229 }
230 catch (Exception e) {
231 throw HibernateUtil.processException(e);
232 }
233 finally {
234 closeSession(session);
235
236 FinderCache.clearCache(TasksProposal.class.getName());
237 }
238 }
239
240 public TasksProposal findByPrimaryKey(long proposalId)
241 throws NoSuchProposalException, SystemException {
242 TasksProposal tasksProposal = fetchByPrimaryKey(proposalId);
243
244 if (tasksProposal == null) {
245 if (_log.isWarnEnabled()) {
246 _log.warn("No TasksProposal exists with the primary key " +
247 proposalId);
248 }
249
250 throw new NoSuchProposalException(
251 "No TasksProposal exists with the primary key " + proposalId);
252 }
253
254 return tasksProposal;
255 }
256
257 public TasksProposal fetchByPrimaryKey(long proposalId)
258 throws SystemException {
259 Session session = null;
260
261 try {
262 session = openSession();
263
264 return (TasksProposal)session.get(TasksProposalImpl.class,
265 new Long(proposalId));
266 }
267 catch (Exception e) {
268 throw HibernateUtil.processException(e);
269 }
270 finally {
271 closeSession(session);
272 }
273 }
274
275 public List<TasksProposal> findByGroupId(long groupId)
276 throws SystemException {
277 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
278 String finderClassName = TasksProposal.class.getName();
279 String finderMethodName = "findByGroupId";
280 String[] finderParams = new String[] { Long.class.getName() };
281 Object[] finderArgs = new Object[] { new Long(groupId) };
282
283 Object result = null;
284
285 if (finderClassNameCacheEnabled) {
286 result = FinderCache.getResult(finderClassName, finderMethodName,
287 finderParams, finderArgs, getSessionFactory());
288 }
289
290 if (result == null) {
291 Session session = null;
292
293 try {
294 session = openSession();
295
296 StringMaker query = new StringMaker();
297
298 query.append(
299 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
300
301 query.append("groupId = ?");
302
303 query.append(" ");
304
305 query.append("ORDER BY ");
306
307 query.append("dueDate ASC, ");
308 query.append("createDate ASC");
309
310 Query q = session.createQuery(query.toString());
311
312 int queryPos = 0;
313
314 q.setLong(queryPos++, groupId);
315
316 List<TasksProposal> list = q.list();
317
318 FinderCache.putResult(finderClassNameCacheEnabled,
319 finderClassName, finderMethodName, finderParams,
320 finderArgs, list);
321
322 return list;
323 }
324 catch (Exception e) {
325 throw HibernateUtil.processException(e);
326 }
327 finally {
328 closeSession(session);
329 }
330 }
331 else {
332 return (List<TasksProposal>)result;
333 }
334 }
335
336 public List<TasksProposal> findByGroupId(long groupId, int begin, int end)
337 throws SystemException {
338 return findByGroupId(groupId, begin, end, null);
339 }
340
341 public List<TasksProposal> findByGroupId(long groupId, int begin, int end,
342 OrderByComparator obc) throws SystemException {
343 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
344 String finderClassName = TasksProposal.class.getName();
345 String finderMethodName = "findByGroupId";
346 String[] finderParams = new String[] {
347 Long.class.getName(),
348
349 "java.lang.Integer", "java.lang.Integer",
350 "com.liferay.portal.kernel.util.OrderByComparator"
351 };
352 Object[] finderArgs = new Object[] {
353 new Long(groupId),
354
355 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
356 };
357
358 Object result = null;
359
360 if (finderClassNameCacheEnabled) {
361 result = FinderCache.getResult(finderClassName, finderMethodName,
362 finderParams, finderArgs, getSessionFactory());
363 }
364
365 if (result == null) {
366 Session session = null;
367
368 try {
369 session = openSession();
370
371 StringMaker query = new StringMaker();
372
373 query.append(
374 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
375
376 query.append("groupId = ?");
377
378 query.append(" ");
379
380 if (obc != null) {
381 query.append("ORDER BY ");
382 query.append(obc.getOrderBy());
383 }
384
385 else {
386 query.append("ORDER BY ");
387
388 query.append("dueDate ASC, ");
389 query.append("createDate ASC");
390 }
391
392 Query q = session.createQuery(query.toString());
393
394 int queryPos = 0;
395
396 q.setLong(queryPos++, groupId);
397
398 List<TasksProposal> list = (List<TasksProposal>)QueryUtil.list(q,
399 getDialect(), begin, end);
400
401 FinderCache.putResult(finderClassNameCacheEnabled,
402 finderClassName, finderMethodName, finderParams,
403 finderArgs, list);
404
405 return list;
406 }
407 catch (Exception e) {
408 throw HibernateUtil.processException(e);
409 }
410 finally {
411 closeSession(session);
412 }
413 }
414 else {
415 return (List<TasksProposal>)result;
416 }
417 }
418
419 public TasksProposal findByGroupId_First(long groupId, OrderByComparator obc)
420 throws NoSuchProposalException, SystemException {
421 List<TasksProposal> list = findByGroupId(groupId, 0, 1, obc);
422
423 if (list.size() == 0) {
424 StringMaker msg = new StringMaker();
425
426 msg.append("No TasksProposal exists with the key {");
427
428 msg.append("groupId=" + groupId);
429
430 msg.append(StringPool.CLOSE_CURLY_BRACE);
431
432 throw new NoSuchProposalException(msg.toString());
433 }
434 else {
435 return list.get(0);
436 }
437 }
438
439 public TasksProposal findByGroupId_Last(long groupId, OrderByComparator obc)
440 throws NoSuchProposalException, SystemException {
441 int count = countByGroupId(groupId);
442
443 List<TasksProposal> list = findByGroupId(groupId, count - 1, count, obc);
444
445 if (list.size() == 0) {
446 StringMaker msg = new StringMaker();
447
448 msg.append("No TasksProposal exists with the key {");
449
450 msg.append("groupId=" + groupId);
451
452 msg.append(StringPool.CLOSE_CURLY_BRACE);
453
454 throw new NoSuchProposalException(msg.toString());
455 }
456 else {
457 return list.get(0);
458 }
459 }
460
461 public TasksProposal[] findByGroupId_PrevAndNext(long proposalId,
462 long groupId, OrderByComparator obc)
463 throws NoSuchProposalException, SystemException {
464 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
465
466 int count = countByGroupId(groupId);
467
468 Session session = null;
469
470 try {
471 session = openSession();
472
473 StringMaker query = new StringMaker();
474
475 query.append(
476 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
477
478 query.append("groupId = ?");
479
480 query.append(" ");
481
482 if (obc != null) {
483 query.append("ORDER BY ");
484 query.append(obc.getOrderBy());
485 }
486
487 else {
488 query.append("ORDER BY ");
489
490 query.append("dueDate ASC, ");
491 query.append("createDate ASC");
492 }
493
494 Query q = session.createQuery(query.toString());
495
496 int queryPos = 0;
497
498 q.setLong(queryPos++, groupId);
499
500 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
501 tasksProposal);
502
503 TasksProposal[] array = new TasksProposalImpl[3];
504
505 array[0] = (TasksProposal)objArray[0];
506 array[1] = (TasksProposal)objArray[1];
507 array[2] = (TasksProposal)objArray[2];
508
509 return array;
510 }
511 catch (Exception e) {
512 throw HibernateUtil.processException(e);
513 }
514 finally {
515 closeSession(session);
516 }
517 }
518
519 public List<TasksProposal> findByG_U(long groupId, long userId)
520 throws SystemException {
521 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
522 String finderClassName = TasksProposal.class.getName();
523 String finderMethodName = "findByG_U";
524 String[] finderParams = new String[] {
525 Long.class.getName(), Long.class.getName()
526 };
527 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
528
529 Object result = null;
530
531 if (finderClassNameCacheEnabled) {
532 result = FinderCache.getResult(finderClassName, finderMethodName,
533 finderParams, finderArgs, getSessionFactory());
534 }
535
536 if (result == null) {
537 Session session = null;
538
539 try {
540 session = openSession();
541
542 StringMaker query = new StringMaker();
543
544 query.append(
545 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
546
547 query.append("groupId = ?");
548
549 query.append(" AND ");
550
551 query.append("userId = ?");
552
553 query.append(" ");
554
555 query.append("ORDER BY ");
556
557 query.append("dueDate ASC, ");
558 query.append("createDate ASC");
559
560 Query q = session.createQuery(query.toString());
561
562 int queryPos = 0;
563
564 q.setLong(queryPos++, groupId);
565
566 q.setLong(queryPos++, userId);
567
568 List<TasksProposal> list = q.list();
569
570 FinderCache.putResult(finderClassNameCacheEnabled,
571 finderClassName, finderMethodName, finderParams,
572 finderArgs, list);
573
574 return list;
575 }
576 catch (Exception e) {
577 throw HibernateUtil.processException(e);
578 }
579 finally {
580 closeSession(session);
581 }
582 }
583 else {
584 return (List<TasksProposal>)result;
585 }
586 }
587
588 public List<TasksProposal> findByG_U(long groupId, long userId, int begin,
589 int end) throws SystemException {
590 return findByG_U(groupId, userId, begin, end, null);
591 }
592
593 public List<TasksProposal> findByG_U(long groupId, long userId, int begin,
594 int end, OrderByComparator obc) throws SystemException {
595 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
596 String finderClassName = TasksProposal.class.getName();
597 String finderMethodName = "findByG_U";
598 String[] finderParams = new String[] {
599 Long.class.getName(), Long.class.getName(),
600
601 "java.lang.Integer", "java.lang.Integer",
602 "com.liferay.portal.kernel.util.OrderByComparator"
603 };
604 Object[] finderArgs = new Object[] {
605 new Long(groupId), new Long(userId),
606
607 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
608 };
609
610 Object result = null;
611
612 if (finderClassNameCacheEnabled) {
613 result = FinderCache.getResult(finderClassName, finderMethodName,
614 finderParams, finderArgs, getSessionFactory());
615 }
616
617 if (result == null) {
618 Session session = null;
619
620 try {
621 session = openSession();
622
623 StringMaker query = new StringMaker();
624
625 query.append(
626 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
627
628 query.append("groupId = ?");
629
630 query.append(" AND ");
631
632 query.append("userId = ?");
633
634 query.append(" ");
635
636 if (obc != null) {
637 query.append("ORDER BY ");
638 query.append(obc.getOrderBy());
639 }
640
641 else {
642 query.append("ORDER BY ");
643
644 query.append("dueDate ASC, ");
645 query.append("createDate ASC");
646 }
647
648 Query q = session.createQuery(query.toString());
649
650 int queryPos = 0;
651
652 q.setLong(queryPos++, groupId);
653
654 q.setLong(queryPos++, userId);
655
656 List<TasksProposal> list = (List<TasksProposal>)QueryUtil.list(q,
657 getDialect(), begin, end);
658
659 FinderCache.putResult(finderClassNameCacheEnabled,
660 finderClassName, finderMethodName, finderParams,
661 finderArgs, list);
662
663 return list;
664 }
665 catch (Exception e) {
666 throw HibernateUtil.processException(e);
667 }
668 finally {
669 closeSession(session);
670 }
671 }
672 else {
673 return (List<TasksProposal>)result;
674 }
675 }
676
677 public TasksProposal findByG_U_First(long groupId, long userId,
678 OrderByComparator obc) throws NoSuchProposalException, SystemException {
679 List<TasksProposal> list = findByG_U(groupId, userId, 0, 1, obc);
680
681 if (list.size() == 0) {
682 StringMaker msg = new StringMaker();
683
684 msg.append("No TasksProposal exists with the key {");
685
686 msg.append("groupId=" + groupId);
687
688 msg.append(", ");
689 msg.append("userId=" + userId);
690
691 msg.append(StringPool.CLOSE_CURLY_BRACE);
692
693 throw new NoSuchProposalException(msg.toString());
694 }
695 else {
696 return list.get(0);
697 }
698 }
699
700 public TasksProposal findByG_U_Last(long groupId, long userId,
701 OrderByComparator obc) throws NoSuchProposalException, SystemException {
702 int count = countByG_U(groupId, userId);
703
704 List<TasksProposal> list = findByG_U(groupId, userId, count - 1, count,
705 obc);
706
707 if (list.size() == 0) {
708 StringMaker msg = new StringMaker();
709
710 msg.append("No TasksProposal exists with the key {");
711
712 msg.append("groupId=" + groupId);
713
714 msg.append(", ");
715 msg.append("userId=" + userId);
716
717 msg.append(StringPool.CLOSE_CURLY_BRACE);
718
719 throw new NoSuchProposalException(msg.toString());
720 }
721 else {
722 return list.get(0);
723 }
724 }
725
726 public TasksProposal[] findByG_U_PrevAndNext(long proposalId, long groupId,
727 long userId, OrderByComparator obc)
728 throws NoSuchProposalException, SystemException {
729 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
730
731 int count = countByG_U(groupId, userId);
732
733 Session session = null;
734
735 try {
736 session = openSession();
737
738 StringMaker query = new StringMaker();
739
740 query.append(
741 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
742
743 query.append("groupId = ?");
744
745 query.append(" AND ");
746
747 query.append("userId = ?");
748
749 query.append(" ");
750
751 if (obc != null) {
752 query.append("ORDER BY ");
753 query.append(obc.getOrderBy());
754 }
755
756 else {
757 query.append("ORDER BY ");
758
759 query.append("dueDate ASC, ");
760 query.append("createDate ASC");
761 }
762
763 Query q = session.createQuery(query.toString());
764
765 int queryPos = 0;
766
767 q.setLong(queryPos++, groupId);
768
769 q.setLong(queryPos++, userId);
770
771 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
772 tasksProposal);
773
774 TasksProposal[] array = new TasksProposalImpl[3];
775
776 array[0] = (TasksProposal)objArray[0];
777 array[1] = (TasksProposal)objArray[1];
778 array[2] = (TasksProposal)objArray[2];
779
780 return array;
781 }
782 catch (Exception e) {
783 throw HibernateUtil.processException(e);
784 }
785 finally {
786 closeSession(session);
787 }
788 }
789
790 public TasksProposal findByC_C(long classNameId, String classPK)
791 throws NoSuchProposalException, SystemException {
792 TasksProposal tasksProposal = fetchByC_C(classNameId, classPK);
793
794 if (tasksProposal == null) {
795 StringMaker msg = new StringMaker();
796
797 msg.append("No TasksProposal exists with the key {");
798
799 msg.append("classNameId=" + classNameId);
800
801 msg.append(", ");
802 msg.append("classPK=" + classPK);
803
804 msg.append(StringPool.CLOSE_CURLY_BRACE);
805
806 if (_log.isWarnEnabled()) {
807 _log.warn(msg.toString());
808 }
809
810 throw new NoSuchProposalException(msg.toString());
811 }
812
813 return tasksProposal;
814 }
815
816 public TasksProposal fetchByC_C(long classNameId, String classPK)
817 throws SystemException {
818 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
819 String finderClassName = TasksProposal.class.getName();
820 String finderMethodName = "fetchByC_C";
821 String[] finderParams = new String[] {
822 Long.class.getName(), String.class.getName()
823 };
824 Object[] finderArgs = new Object[] { new Long(classNameId), classPK };
825
826 Object result = null;
827
828 if (finderClassNameCacheEnabled) {
829 result = FinderCache.getResult(finderClassName, finderMethodName,
830 finderParams, finderArgs, getSessionFactory());
831 }
832
833 if (result == null) {
834 Session session = null;
835
836 try {
837 session = openSession();
838
839 StringMaker query = new StringMaker();
840
841 query.append(
842 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
843
844 query.append("classNameId = ?");
845
846 query.append(" AND ");
847
848 if (classPK == null) {
849 query.append("classPK IS NULL");
850 }
851 else {
852 query.append("classPK = ?");
853 }
854
855 query.append(" ");
856
857 query.append("ORDER BY ");
858
859 query.append("dueDate ASC, ");
860 query.append("createDate ASC");
861
862 Query q = session.createQuery(query.toString());
863
864 int queryPos = 0;
865
866 q.setLong(queryPos++, classNameId);
867
868 if (classPK != null) {
869 q.setString(queryPos++, classPK);
870 }
871
872 List<TasksProposal> list = q.list();
873
874 FinderCache.putResult(finderClassNameCacheEnabled,
875 finderClassName, finderMethodName, finderParams,
876 finderArgs, list);
877
878 if (list.size() == 0) {
879 return null;
880 }
881 else {
882 return list.get(0);
883 }
884 }
885 catch (Exception e) {
886 throw HibernateUtil.processException(e);
887 }
888 finally {
889 closeSession(session);
890 }
891 }
892 else {
893 List<TasksProposal> list = (List<TasksProposal>)result;
894
895 if (list.size() == 0) {
896 return null;
897 }
898 else {
899 return list.get(0);
900 }
901 }
902 }
903
904 public List<TasksProposal> findWithDynamicQuery(
905 DynamicQueryInitializer queryInitializer) throws SystemException {
906 Session session = null;
907
908 try {
909 session = openSession();
910
911 DynamicQuery query = queryInitializer.initialize(session);
912
913 return query.list();
914 }
915 catch (Exception e) {
916 throw HibernateUtil.processException(e);
917 }
918 finally {
919 closeSession(session);
920 }
921 }
922
923 public List<TasksProposal> findWithDynamicQuery(
924 DynamicQueryInitializer queryInitializer, int begin, int end)
925 throws SystemException {
926 Session session = null;
927
928 try {
929 session = openSession();
930
931 DynamicQuery query = queryInitializer.initialize(session);
932
933 query.setLimit(begin, end);
934
935 return query.list();
936 }
937 catch (Exception e) {
938 throw HibernateUtil.processException(e);
939 }
940 finally {
941 closeSession(session);
942 }
943 }
944
945 public List<TasksProposal> findAll() throws SystemException {
946 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
947 }
948
949 public List<TasksProposal> findAll(int begin, int end)
950 throws SystemException {
951 return findAll(begin, end, null);
952 }
953
954 public List<TasksProposal> findAll(int begin, int end, OrderByComparator obc)
955 throws SystemException {
956 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
957 String finderClassName = TasksProposal.class.getName();
958 String finderMethodName = "findAll";
959 String[] finderParams = new String[] {
960 "java.lang.Integer", "java.lang.Integer",
961 "com.liferay.portal.kernel.util.OrderByComparator"
962 };
963 Object[] finderArgs = new Object[] {
964 String.valueOf(begin), String.valueOf(end), String.valueOf(obc)
965 };
966
967 Object result = null;
968
969 if (finderClassNameCacheEnabled) {
970 result = FinderCache.getResult(finderClassName, finderMethodName,
971 finderParams, finderArgs, getSessionFactory());
972 }
973
974 if (result == null) {
975 Session session = null;
976
977 try {
978 session = openSession();
979
980 StringMaker query = new StringMaker();
981
982 query.append(
983 "FROM com.liferay.portlet.tasks.model.TasksProposal ");
984
985 if (obc != null) {
986 query.append("ORDER BY ");
987 query.append(obc.getOrderBy());
988 }
989
990 else {
991 query.append("ORDER BY ");
992
993 query.append("dueDate ASC, ");
994 query.append("createDate ASC");
995 }
996
997 Query q = session.createQuery(query.toString());
998
999 List<TasksProposal> list = (List<TasksProposal>)QueryUtil.list(q,
1000 getDialect(), begin, end);
1001
1002 if (obc == null) {
1003 Collections.sort(list);
1004 }
1005
1006 FinderCache.putResult(finderClassNameCacheEnabled,
1007 finderClassName, finderMethodName, finderParams,
1008 finderArgs, list);
1009
1010 return list;
1011 }
1012 catch (Exception e) {
1013 throw HibernateUtil.processException(e);
1014 }
1015 finally {
1016 closeSession(session);
1017 }
1018 }
1019 else {
1020 return (List<TasksProposal>)result;
1021 }
1022 }
1023
1024 public void removeByGroupId(long groupId) throws SystemException {
1025 for (TasksProposal tasksProposal : findByGroupId(groupId)) {
1026 remove(tasksProposal);
1027 }
1028 }
1029
1030 public void removeByG_U(long groupId, long userId)
1031 throws SystemException {
1032 for (TasksProposal tasksProposal : findByG_U(groupId, userId)) {
1033 remove(tasksProposal);
1034 }
1035 }
1036
1037 public void removeByC_C(long classNameId, String classPK)
1038 throws NoSuchProposalException, SystemException {
1039 TasksProposal tasksProposal = findByC_C(classNameId, classPK);
1040
1041 remove(tasksProposal);
1042 }
1043
1044 public void removeAll() throws SystemException {
1045 for (TasksProposal tasksProposal : findAll()) {
1046 remove(tasksProposal);
1047 }
1048 }
1049
1050 public int countByGroupId(long groupId) throws SystemException {
1051 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1052 String finderClassName = TasksProposal.class.getName();
1053 String finderMethodName = "countByGroupId";
1054 String[] finderParams = new String[] { Long.class.getName() };
1055 Object[] finderArgs = new Object[] { new Long(groupId) };
1056
1057 Object result = null;
1058
1059 if (finderClassNameCacheEnabled) {
1060 result = FinderCache.getResult(finderClassName, finderMethodName,
1061 finderParams, finderArgs, getSessionFactory());
1062 }
1063
1064 if (result == null) {
1065 Session session = null;
1066
1067 try {
1068 session = openSession();
1069
1070 StringMaker query = new StringMaker();
1071
1072 query.append("SELECT COUNT(*) ");
1073 query.append(
1074 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1075
1076 query.append("groupId = ?");
1077
1078 query.append(" ");
1079
1080 Query q = session.createQuery(query.toString());
1081
1082 int queryPos = 0;
1083
1084 q.setLong(queryPos++, groupId);
1085
1086 Long count = null;
1087
1088 Iterator<Long> itr = q.list().iterator();
1089
1090 if (itr.hasNext()) {
1091 count = itr.next();
1092 }
1093
1094 if (count == null) {
1095 count = new Long(0);
1096 }
1097
1098 FinderCache.putResult(finderClassNameCacheEnabled,
1099 finderClassName, finderMethodName, finderParams,
1100 finderArgs, count);
1101
1102 return count.intValue();
1103 }
1104 catch (Exception e) {
1105 throw HibernateUtil.processException(e);
1106 }
1107 finally {
1108 closeSession(session);
1109 }
1110 }
1111 else {
1112 return ((Long)result).intValue();
1113 }
1114 }
1115
1116 public int countByG_U(long groupId, long userId) throws SystemException {
1117 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1118 String finderClassName = TasksProposal.class.getName();
1119 String finderMethodName = "countByG_U";
1120 String[] finderParams = new String[] {
1121 Long.class.getName(), Long.class.getName()
1122 };
1123 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1124
1125 Object result = null;
1126
1127 if (finderClassNameCacheEnabled) {
1128 result = FinderCache.getResult(finderClassName, finderMethodName,
1129 finderParams, finderArgs, getSessionFactory());
1130 }
1131
1132 if (result == null) {
1133 Session session = null;
1134
1135 try {
1136 session = openSession();
1137
1138 StringMaker query = new StringMaker();
1139
1140 query.append("SELECT COUNT(*) ");
1141 query.append(
1142 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1143
1144 query.append("groupId = ?");
1145
1146 query.append(" AND ");
1147
1148 query.append("userId = ?");
1149
1150 query.append(" ");
1151
1152 Query q = session.createQuery(query.toString());
1153
1154 int queryPos = 0;
1155
1156 q.setLong(queryPos++, groupId);
1157
1158 q.setLong(queryPos++, userId);
1159
1160 Long count = null;
1161
1162 Iterator<Long> itr = q.list().iterator();
1163
1164 if (itr.hasNext()) {
1165 count = itr.next();
1166 }
1167
1168 if (count == null) {
1169 count = new Long(0);
1170 }
1171
1172 FinderCache.putResult(finderClassNameCacheEnabled,
1173 finderClassName, finderMethodName, finderParams,
1174 finderArgs, count);
1175
1176 return count.intValue();
1177 }
1178 catch (Exception e) {
1179 throw HibernateUtil.processException(e);
1180 }
1181 finally {
1182 closeSession(session);
1183 }
1184 }
1185 else {
1186 return ((Long)result).intValue();
1187 }
1188 }
1189
1190 public int countByC_C(long classNameId, String classPK)
1191 throws SystemException {
1192 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1193 String finderClassName = TasksProposal.class.getName();
1194 String finderMethodName = "countByC_C";
1195 String[] finderParams = new String[] {
1196 Long.class.getName(), String.class.getName()
1197 };
1198 Object[] finderArgs = new Object[] { new Long(classNameId), classPK };
1199
1200 Object result = null;
1201
1202 if (finderClassNameCacheEnabled) {
1203 result = FinderCache.getResult(finderClassName, finderMethodName,
1204 finderParams, finderArgs, getSessionFactory());
1205 }
1206
1207 if (result == null) {
1208 Session session = null;
1209
1210 try {
1211 session = openSession();
1212
1213 StringMaker query = new StringMaker();
1214
1215 query.append("SELECT COUNT(*) ");
1216 query.append(
1217 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1218
1219 query.append("classNameId = ?");
1220
1221 query.append(" AND ");
1222
1223 if (classPK == null) {
1224 query.append("classPK IS NULL");
1225 }
1226 else {
1227 query.append("classPK = ?");
1228 }
1229
1230 query.append(" ");
1231
1232 Query q = session.createQuery(query.toString());
1233
1234 int queryPos = 0;
1235
1236 q.setLong(queryPos++, classNameId);
1237
1238 if (classPK != null) {
1239 q.setString(queryPos++, classPK);
1240 }
1241
1242 Long count = null;
1243
1244 Iterator<Long> itr = q.list().iterator();
1245
1246 if (itr.hasNext()) {
1247 count = itr.next();
1248 }
1249
1250 if (count == null) {
1251 count = new Long(0);
1252 }
1253
1254 FinderCache.putResult(finderClassNameCacheEnabled,
1255 finderClassName, finderMethodName, finderParams,
1256 finderArgs, count);
1257
1258 return count.intValue();
1259 }
1260 catch (Exception e) {
1261 throw HibernateUtil.processException(e);
1262 }
1263 finally {
1264 closeSession(session);
1265 }
1266 }
1267 else {
1268 return ((Long)result).intValue();
1269 }
1270 }
1271
1272 public int countAll() throws SystemException {
1273 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1274 String finderClassName = TasksProposal.class.getName();
1275 String finderMethodName = "countAll";
1276 String[] finderParams = new String[] { };
1277 Object[] finderArgs = new Object[] { };
1278
1279 Object result = null;
1280
1281 if (finderClassNameCacheEnabled) {
1282 result = FinderCache.getResult(finderClassName, finderMethodName,
1283 finderParams, finderArgs, getSessionFactory());
1284 }
1285
1286 if (result == null) {
1287 Session session = null;
1288
1289 try {
1290 session = openSession();
1291
1292 Query q = session.createQuery(
1293 "SELECT COUNT(*) FROM com.liferay.portlet.tasks.model.TasksProposal");
1294
1295 Long count = null;
1296
1297 Iterator<Long> itr = q.list().iterator();
1298
1299 if (itr.hasNext()) {
1300 count = itr.next();
1301 }
1302
1303 if (count == null) {
1304 count = new Long(0);
1305 }
1306
1307 FinderCache.putResult(finderClassNameCacheEnabled,
1308 finderClassName, finderMethodName, finderParams,
1309 finderArgs, count);
1310
1311 return count.intValue();
1312 }
1313 catch (Exception e) {
1314 throw HibernateUtil.processException(e);
1315 }
1316 finally {
1317 closeSession(session);
1318 }
1319 }
1320 else {
1321 return ((Long)result).intValue();
1322 }
1323 }
1324
1325 protected void initDao() {
1326 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1327 PropsUtil.get(
1328 "value.object.listener.com.liferay.portlet.tasks.model.TasksProposal")));
1329
1330 if (listenerClassNames.length > 0) {
1331 try {
1332 List<ModelListener> listeners = new ArrayList<ModelListener>();
1333
1334 for (String listenerClassName : listenerClassNames) {
1335 listeners.add((ModelListener)Class.forName(
1336 listenerClassName).newInstance());
1337 }
1338
1339 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1340 }
1341 catch (Exception e) {
1342 _log.error(e);
1343 }
1344 }
1345 }
1346
1347 private static Log _log = LogFactory.getLog(TasksProposalPersistenceImpl.class);
1348 private ModelListener[] _listeners;
1349}