001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchWorkflowInstanceLinkException;
019 import com.liferay.portal.kernel.annotation.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023 import com.liferay.portal.kernel.dao.orm.FinderPath;
024 import com.liferay.portal.kernel.dao.orm.Query;
025 import com.liferay.portal.kernel.dao.orm.QueryPos;
026 import com.liferay.portal.kernel.dao.orm.QueryUtil;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.model.WorkflowInstanceLink;
039 import com.liferay.portal.model.impl.WorkflowInstanceLinkImpl;
040 import com.liferay.portal.model.impl.WorkflowInstanceLinkModelImpl;
041 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042
043 import java.io.Serializable;
044
045 import java.util.ArrayList;
046 import java.util.Collections;
047 import java.util.List;
048
049
065 public class WorkflowInstanceLinkPersistenceImpl extends BasePersistenceImpl<WorkflowInstanceLink>
066 implements WorkflowInstanceLinkPersistence {
067 public static final String FINDER_CLASS_NAME_ENTITY = WorkflowInstanceLinkImpl.class.getName();
068 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
069 ".List";
070 public static final FinderPath FINDER_PATH_FIND_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
071 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
072 FINDER_CLASS_NAME_LIST, "findByG_C_C_C",
073 new String[] {
074 Long.class.getName(), Long.class.getName(), Long.class.getName(),
075 Long.class.getName(),
076
077 "java.lang.Integer", "java.lang.Integer",
078 "com.liferay.portal.kernel.util.OrderByComparator"
079 });
080 public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
081 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
082 FINDER_CLASS_NAME_LIST, "countByG_C_C_C",
083 new String[] {
084 Long.class.getName(), Long.class.getName(), Long.class.getName(),
085 Long.class.getName()
086 });
087 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
088 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
089 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
090 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
091 WorkflowInstanceLinkModelImpl.FINDER_CACHE_ENABLED,
092 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
093
094
099 public void cacheResult(WorkflowInstanceLink workflowInstanceLink) {
100 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
101 WorkflowInstanceLinkImpl.class,
102 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
103 }
104
105
110 public void cacheResult(List<WorkflowInstanceLink> workflowInstanceLinks) {
111 for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) {
112 if (EntityCacheUtil.getResult(
113 WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
114 WorkflowInstanceLinkImpl.class,
115 workflowInstanceLink.getPrimaryKey(), this) == null) {
116 cacheResult(workflowInstanceLink);
117 }
118 }
119 }
120
121
128 public void clearCache() {
129 CacheRegistryUtil.clear(WorkflowInstanceLinkImpl.class.getName());
130 EntityCacheUtil.clearCache(WorkflowInstanceLinkImpl.class.getName());
131 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
133 }
134
135
142 public void clearCache(WorkflowInstanceLink workflowInstanceLink) {
143 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
144 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
145 }
146
147
153 public WorkflowInstanceLink create(long workflowInstanceLinkId) {
154 WorkflowInstanceLink workflowInstanceLink = new WorkflowInstanceLinkImpl();
155
156 workflowInstanceLink.setNew(true);
157 workflowInstanceLink.setPrimaryKey(workflowInstanceLinkId);
158
159 return workflowInstanceLink;
160 }
161
162
170 public WorkflowInstanceLink remove(Serializable primaryKey)
171 throws NoSuchModelException, SystemException {
172 return remove(((Long)primaryKey).longValue());
173 }
174
175
183 public WorkflowInstanceLink remove(long workflowInstanceLinkId)
184 throws NoSuchWorkflowInstanceLinkException, SystemException {
185 Session session = null;
186
187 try {
188 session = openSession();
189
190 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
191 new Long(workflowInstanceLinkId));
192
193 if (workflowInstanceLink == null) {
194 if (_log.isWarnEnabled()) {
195 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
196 workflowInstanceLinkId);
197 }
198
199 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
200 workflowInstanceLinkId);
201 }
202
203 return remove(workflowInstanceLink);
204 }
205 catch (NoSuchWorkflowInstanceLinkException nsee) {
206 throw nsee;
207 }
208 catch (Exception e) {
209 throw processException(e);
210 }
211 finally {
212 closeSession(session);
213 }
214 }
215
216 protected WorkflowInstanceLink removeImpl(
217 WorkflowInstanceLink workflowInstanceLink) throws SystemException {
218 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
219
220 Session session = null;
221
222 try {
223 session = openSession();
224
225 if (workflowInstanceLink.isCachedModel() ||
226 BatchSessionUtil.isEnabled()) {
227 Object staleObject = session.get(WorkflowInstanceLinkImpl.class,
228 workflowInstanceLink.getPrimaryKeyObj());
229
230 if (staleObject != null) {
231 session.evict(staleObject);
232 }
233 }
234
235 session.delete(workflowInstanceLink);
236
237 session.flush();
238 }
239 catch (Exception e) {
240 throw processException(e);
241 }
242 finally {
243 closeSession(session);
244 }
245
246 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
247
248 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
249 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
250
251 return workflowInstanceLink;
252 }
253
254 public WorkflowInstanceLink updateImpl(
255 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
256 boolean merge) throws SystemException {
257 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
258
259 Session session = null;
260
261 try {
262 session = openSession();
263
264 BatchSessionUtil.update(session, workflowInstanceLink, merge);
265
266 workflowInstanceLink.setNew(false);
267 }
268 catch (Exception e) {
269 throw processException(e);
270 }
271 finally {
272 closeSession(session);
273 }
274
275 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
276
277 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
278 WorkflowInstanceLinkImpl.class,
279 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
280
281 return workflowInstanceLink;
282 }
283
284 protected WorkflowInstanceLink toUnwrappedModel(
285 WorkflowInstanceLink workflowInstanceLink) {
286 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
287 return workflowInstanceLink;
288 }
289
290 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
291
292 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
293 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
294
295 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
296 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
297 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
298 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
299 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
300 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
301 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
302 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
303 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
304 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
305
306 return workflowInstanceLinkImpl;
307 }
308
309
317 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
318 throws NoSuchModelException, SystemException {
319 return findByPrimaryKey(((Long)primaryKey).longValue());
320 }
321
322
330 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
331 throws NoSuchWorkflowInstanceLinkException, SystemException {
332 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
333
334 if (workflowInstanceLink == null) {
335 if (_log.isWarnEnabled()) {
336 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
337 workflowInstanceLinkId);
338 }
339
340 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
341 workflowInstanceLinkId);
342 }
343
344 return workflowInstanceLink;
345 }
346
347
354 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
355 throws SystemException {
356 return fetchByPrimaryKey(((Long)primaryKey).longValue());
357 }
358
359
366 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
367 throws SystemException {
368 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
369 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId, this);
370
371 if (workflowInstanceLink == null) {
372 Session session = null;
373
374 try {
375 session = openSession();
376
377 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
378 new Long(workflowInstanceLinkId));
379 }
380 catch (Exception e) {
381 throw processException(e);
382 }
383 finally {
384 if (workflowInstanceLink != null) {
385 cacheResult(workflowInstanceLink);
386 }
387
388 closeSession(session);
389 }
390 }
391
392 return workflowInstanceLink;
393 }
394
395
405 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
406 long companyId, long classNameId, long classPK)
407 throws SystemException {
408 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
409 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
410 }
411
412
428 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
429 long companyId, long classNameId, long classPK, int start, int end)
430 throws SystemException {
431 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
432 end, null);
433 }
434
435
452 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
453 long companyId, long classNameId, long classPK, int start, int end,
454 OrderByComparator orderByComparator) throws SystemException {
455 Object[] finderArgs = new Object[] {
456 groupId, companyId, classNameId, classPK,
457
458 String.valueOf(start), String.valueOf(end),
459 String.valueOf(orderByComparator)
460 };
461
462 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_C_C,
463 finderArgs, this);
464
465 if (list == null) {
466 Session session = null;
467
468 try {
469 session = openSession();
470
471 StringBundler query = null;
472
473 if (orderByComparator != null) {
474 query = new StringBundler(6 +
475 (orderByComparator.getOrderByFields().length * 3));
476 }
477 else {
478 query = new StringBundler(6);
479 }
480
481 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
482
483 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
484
485 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
486
487 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
488
489 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
490
491 if (orderByComparator != null) {
492 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
493 orderByComparator);
494 }
495
496 else {
497 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
498 }
499
500 String sql = query.toString();
501
502 Query q = session.createQuery(sql);
503
504 QueryPos qPos = QueryPos.getInstance(q);
505
506 qPos.add(groupId);
507
508 qPos.add(companyId);
509
510 qPos.add(classNameId);
511
512 qPos.add(classPK);
513
514 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
515 getDialect(), start, end);
516 }
517 catch (Exception e) {
518 throw processException(e);
519 }
520 finally {
521 if (list == null) {
522 list = new ArrayList<WorkflowInstanceLink>();
523 }
524
525 cacheResult(list);
526
527 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_C_C,
528 finderArgs, list);
529
530 closeSession(session);
531 }
532 }
533
534 return list;
535 }
536
537
553 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
554 long companyId, long classNameId, long classPK,
555 OrderByComparator orderByComparator)
556 throws NoSuchWorkflowInstanceLinkException, SystemException {
557 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
558 classNameId, classPK, 0, 1, orderByComparator);
559
560 if (list.isEmpty()) {
561 StringBundler msg = new StringBundler(10);
562
563 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
564
565 msg.append("groupId=");
566 msg.append(groupId);
567
568 msg.append(", companyId=");
569 msg.append(companyId);
570
571 msg.append(", classNameId=");
572 msg.append(classNameId);
573
574 msg.append(", classPK=");
575 msg.append(classPK);
576
577 msg.append(StringPool.CLOSE_CURLY_BRACE);
578
579 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
580 }
581 else {
582 return list.get(0);
583 }
584 }
585
586
602 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
603 long companyId, long classNameId, long classPK,
604 OrderByComparator orderByComparator)
605 throws NoSuchWorkflowInstanceLinkException, SystemException {
606 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
607
608 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
609 classNameId, classPK, count - 1, count, orderByComparator);
610
611 if (list.isEmpty()) {
612 StringBundler msg = new StringBundler(10);
613
614 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
615
616 msg.append("groupId=");
617 msg.append(groupId);
618
619 msg.append(", companyId=");
620 msg.append(companyId);
621
622 msg.append(", classNameId=");
623 msg.append(classNameId);
624
625 msg.append(", classPK=");
626 msg.append(classPK);
627
628 msg.append(StringPool.CLOSE_CURLY_BRACE);
629
630 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
631 }
632 else {
633 return list.get(0);
634 }
635 }
636
637
654 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
655 long workflowInstanceLinkId, long groupId, long companyId,
656 long classNameId, long classPK, OrderByComparator orderByComparator)
657 throws NoSuchWorkflowInstanceLinkException, SystemException {
658 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
659
660 Session session = null;
661
662 try {
663 session = openSession();
664
665 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
666
667 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
668 groupId, companyId, classNameId, classPK,
669 orderByComparator, true);
670
671 array[1] = workflowInstanceLink;
672
673 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
674 groupId, companyId, classNameId, classPK,
675 orderByComparator, false);
676
677 return array;
678 }
679 catch (Exception e) {
680 throw processException(e);
681 }
682 finally {
683 closeSession(session);
684 }
685 }
686
687 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
688 WorkflowInstanceLink workflowInstanceLink, long groupId,
689 long companyId, long classNameId, long classPK,
690 OrderByComparator orderByComparator, boolean previous) {
691 StringBundler query = null;
692
693 if (orderByComparator != null) {
694 query = new StringBundler(6 +
695 (orderByComparator.getOrderByFields().length * 6));
696 }
697 else {
698 query = new StringBundler(3);
699 }
700
701 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
702
703 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
704
705 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
706
707 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
708
709 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
710
711 if (orderByComparator != null) {
712 String[] orderByFields = orderByComparator.getOrderByFields();
713
714 if (orderByFields.length > 0) {
715 query.append(WHERE_AND);
716 }
717
718 for (int i = 0; i < orderByFields.length; i++) {
719 query.append(_ORDER_BY_ENTITY_ALIAS);
720 query.append(orderByFields[i]);
721
722 if ((i + 1) < orderByFields.length) {
723 if (orderByComparator.isAscending() ^ previous) {
724 query.append(WHERE_GREATER_THAN_HAS_NEXT);
725 }
726 else {
727 query.append(WHERE_LESSER_THAN_HAS_NEXT);
728 }
729 }
730 else {
731 if (orderByComparator.isAscending() ^ previous) {
732 query.append(WHERE_GREATER_THAN);
733 }
734 else {
735 query.append(WHERE_LESSER_THAN);
736 }
737 }
738 }
739
740 query.append(ORDER_BY_CLAUSE);
741
742 for (int i = 0; i < orderByFields.length; i++) {
743 query.append(_ORDER_BY_ENTITY_ALIAS);
744 query.append(orderByFields[i]);
745
746 if ((i + 1) < orderByFields.length) {
747 if (orderByComparator.isAscending() ^ previous) {
748 query.append(ORDER_BY_ASC_HAS_NEXT);
749 }
750 else {
751 query.append(ORDER_BY_DESC_HAS_NEXT);
752 }
753 }
754 else {
755 if (orderByComparator.isAscending() ^ previous) {
756 query.append(ORDER_BY_ASC);
757 }
758 else {
759 query.append(ORDER_BY_DESC);
760 }
761 }
762 }
763 }
764
765 else {
766 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
767 }
768
769 String sql = query.toString();
770
771 Query q = session.createQuery(sql);
772
773 q.setFirstResult(0);
774 q.setMaxResults(2);
775
776 QueryPos qPos = QueryPos.getInstance(q);
777
778 qPos.add(groupId);
779
780 qPos.add(companyId);
781
782 qPos.add(classNameId);
783
784 qPos.add(classPK);
785
786 if (orderByComparator != null) {
787 Object[] values = orderByComparator.getOrderByValues(workflowInstanceLink);
788
789 for (Object value : values) {
790 qPos.add(value);
791 }
792 }
793
794 List<WorkflowInstanceLink> list = q.list();
795
796 if (list.size() == 2) {
797 return list.get(1);
798 }
799 else {
800 return null;
801 }
802 }
803
804
810 public List<WorkflowInstanceLink> findAll() throws SystemException {
811 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
812 }
813
814
826 public List<WorkflowInstanceLink> findAll(int start, int end)
827 throws SystemException {
828 return findAll(start, end, null);
829 }
830
831
844 public List<WorkflowInstanceLink> findAll(int start, int end,
845 OrderByComparator orderByComparator) throws SystemException {
846 Object[] finderArgs = new Object[] {
847 String.valueOf(start), String.valueOf(end),
848 String.valueOf(orderByComparator)
849 };
850
851 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
852 finderArgs, this);
853
854 if (list == null) {
855 Session session = null;
856
857 try {
858 session = openSession();
859
860 StringBundler query = null;
861 String sql = null;
862
863 if (orderByComparator != null) {
864 query = new StringBundler(2 +
865 (orderByComparator.getOrderByFields().length * 3));
866
867 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
868
869 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
870 orderByComparator);
871
872 sql = query.toString();
873 }
874 else {
875 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
876 }
877
878 Query q = session.createQuery(sql);
879
880 if (orderByComparator == null) {
881 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
882 getDialect(), start, end, false);
883
884 Collections.sort(list);
885 }
886 else {
887 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
888 getDialect(), start, end);
889 }
890 }
891 catch (Exception e) {
892 throw processException(e);
893 }
894 finally {
895 if (list == null) {
896 list = new ArrayList<WorkflowInstanceLink>();
897 }
898
899 cacheResult(list);
900
901 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
902
903 closeSession(session);
904 }
905 }
906
907 return list;
908 }
909
910
919 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
920 long classPK) throws SystemException {
921 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
922 groupId, companyId, classNameId, classPK)) {
923 remove(workflowInstanceLink);
924 }
925 }
926
927
932 public void removeAll() throws SystemException {
933 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
934 remove(workflowInstanceLink);
935 }
936 }
937
938
948 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
949 long classPK) throws SystemException {
950 Object[] finderArgs = new Object[] {
951 groupId, companyId, classNameId, classPK
952 };
953
954 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
955 finderArgs, this);
956
957 if (count == null) {
958 Session session = null;
959
960 try {
961 session = openSession();
962
963 StringBundler query = new StringBundler(5);
964
965 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
966
967 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
968
969 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
970
971 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
972
973 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
974
975 String sql = query.toString();
976
977 Query q = session.createQuery(sql);
978
979 QueryPos qPos = QueryPos.getInstance(q);
980
981 qPos.add(groupId);
982
983 qPos.add(companyId);
984
985 qPos.add(classNameId);
986
987 qPos.add(classPK);
988
989 count = (Long)q.uniqueResult();
990 }
991 catch (Exception e) {
992 throw processException(e);
993 }
994 finally {
995 if (count == null) {
996 count = Long.valueOf(0);
997 }
998
999 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
1000 finderArgs, count);
1001
1002 closeSession(session);
1003 }
1004 }
1005
1006 return count.intValue();
1007 }
1008
1009
1015 public int countAll() throws SystemException {
1016 Object[] finderArgs = new Object[0];
1017
1018 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1019 finderArgs, this);
1020
1021 if (count == null) {
1022 Session session = null;
1023
1024 try {
1025 session = openSession();
1026
1027 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1028
1029 count = (Long)q.uniqueResult();
1030 }
1031 catch (Exception e) {
1032 throw processException(e);
1033 }
1034 finally {
1035 if (count == null) {
1036 count = Long.valueOf(0);
1037 }
1038
1039 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1040 count);
1041
1042 closeSession(session);
1043 }
1044 }
1045
1046 return count.intValue();
1047 }
1048
1049
1052 public void afterPropertiesSet() {
1053 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1054 com.liferay.portal.util.PropsUtil.get(
1055 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1056
1057 if (listenerClassNames.length > 0) {
1058 try {
1059 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1060
1061 for (String listenerClassName : listenerClassNames) {
1062 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1063 listenerClassName));
1064 }
1065
1066 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1067 }
1068 catch (Exception e) {
1069 _log.error(e);
1070 }
1071 }
1072 }
1073
1074 @BeanReference(type = AccountPersistence.class)
1075 protected AccountPersistence accountPersistence;
1076 @BeanReference(type = AddressPersistence.class)
1077 protected AddressPersistence addressPersistence;
1078 @BeanReference(type = BrowserTrackerPersistence.class)
1079 protected BrowserTrackerPersistence browserTrackerPersistence;
1080 @BeanReference(type = ClassNamePersistence.class)
1081 protected ClassNamePersistence classNamePersistence;
1082 @BeanReference(type = CompanyPersistence.class)
1083 protected CompanyPersistence companyPersistence;
1084 @BeanReference(type = ContactPersistence.class)
1085 protected ContactPersistence contactPersistence;
1086 @BeanReference(type = CountryPersistence.class)
1087 protected CountryPersistence countryPersistence;
1088 @BeanReference(type = EmailAddressPersistence.class)
1089 protected EmailAddressPersistence emailAddressPersistence;
1090 @BeanReference(type = GroupPersistence.class)
1091 protected GroupPersistence groupPersistence;
1092 @BeanReference(type = ImagePersistence.class)
1093 protected ImagePersistence imagePersistence;
1094 @BeanReference(type = LayoutPersistence.class)
1095 protected LayoutPersistence layoutPersistence;
1096 @BeanReference(type = LayoutPrototypePersistence.class)
1097 protected LayoutPrototypePersistence layoutPrototypePersistence;
1098 @BeanReference(type = LayoutSetPersistence.class)
1099 protected LayoutSetPersistence layoutSetPersistence;
1100 @BeanReference(type = LayoutSetPrototypePersistence.class)
1101 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1102 @BeanReference(type = ListTypePersistence.class)
1103 protected ListTypePersistence listTypePersistence;
1104 @BeanReference(type = LockPersistence.class)
1105 protected LockPersistence lockPersistence;
1106 @BeanReference(type = MembershipRequestPersistence.class)
1107 protected MembershipRequestPersistence membershipRequestPersistence;
1108 @BeanReference(type = OrganizationPersistence.class)
1109 protected OrganizationPersistence organizationPersistence;
1110 @BeanReference(type = OrgGroupPermissionPersistence.class)
1111 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1112 @BeanReference(type = OrgGroupRolePersistence.class)
1113 protected OrgGroupRolePersistence orgGroupRolePersistence;
1114 @BeanReference(type = OrgLaborPersistence.class)
1115 protected OrgLaborPersistence orgLaborPersistence;
1116 @BeanReference(type = PasswordPolicyPersistence.class)
1117 protected PasswordPolicyPersistence passwordPolicyPersistence;
1118 @BeanReference(type = PasswordPolicyRelPersistence.class)
1119 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1120 @BeanReference(type = PasswordTrackerPersistence.class)
1121 protected PasswordTrackerPersistence passwordTrackerPersistence;
1122 @BeanReference(type = PermissionPersistence.class)
1123 protected PermissionPersistence permissionPersistence;
1124 @BeanReference(type = PhonePersistence.class)
1125 protected PhonePersistence phonePersistence;
1126 @BeanReference(type = PluginSettingPersistence.class)
1127 protected PluginSettingPersistence pluginSettingPersistence;
1128 @BeanReference(type = PortletPersistence.class)
1129 protected PortletPersistence portletPersistence;
1130 @BeanReference(type = PortletItemPersistence.class)
1131 protected PortletItemPersistence portletItemPersistence;
1132 @BeanReference(type = PortletPreferencesPersistence.class)
1133 protected PortletPreferencesPersistence portletPreferencesPersistence;
1134 @BeanReference(type = RegionPersistence.class)
1135 protected RegionPersistence regionPersistence;
1136 @BeanReference(type = ReleasePersistence.class)
1137 protected ReleasePersistence releasePersistence;
1138 @BeanReference(type = ResourcePersistence.class)
1139 protected ResourcePersistence resourcePersistence;
1140 @BeanReference(type = ResourceActionPersistence.class)
1141 protected ResourceActionPersistence resourceActionPersistence;
1142 @BeanReference(type = ResourceCodePersistence.class)
1143 protected ResourceCodePersistence resourceCodePersistence;
1144 @BeanReference(type = ResourcePermissionPersistence.class)
1145 protected ResourcePermissionPersistence resourcePermissionPersistence;
1146 @BeanReference(type = RolePersistence.class)
1147 protected RolePersistence rolePersistence;
1148 @BeanReference(type = ServiceComponentPersistence.class)
1149 protected ServiceComponentPersistence serviceComponentPersistence;
1150 @BeanReference(type = ShardPersistence.class)
1151 protected ShardPersistence shardPersistence;
1152 @BeanReference(type = SubscriptionPersistence.class)
1153 protected SubscriptionPersistence subscriptionPersistence;
1154 @BeanReference(type = TicketPersistence.class)
1155 protected TicketPersistence ticketPersistence;
1156 @BeanReference(type = TeamPersistence.class)
1157 protected TeamPersistence teamPersistence;
1158 @BeanReference(type = UserPersistence.class)
1159 protected UserPersistence userPersistence;
1160 @BeanReference(type = UserGroupPersistence.class)
1161 protected UserGroupPersistence userGroupPersistence;
1162 @BeanReference(type = UserGroupGroupRolePersistence.class)
1163 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1164 @BeanReference(type = UserGroupRolePersistence.class)
1165 protected UserGroupRolePersistence userGroupRolePersistence;
1166 @BeanReference(type = UserIdMapperPersistence.class)
1167 protected UserIdMapperPersistence userIdMapperPersistence;
1168 @BeanReference(type = UserTrackerPersistence.class)
1169 protected UserTrackerPersistence userTrackerPersistence;
1170 @BeanReference(type = UserTrackerPathPersistence.class)
1171 protected UserTrackerPathPersistence userTrackerPathPersistence;
1172 @BeanReference(type = WebDAVPropsPersistence.class)
1173 protected WebDAVPropsPersistence webDAVPropsPersistence;
1174 @BeanReference(type = WebsitePersistence.class)
1175 protected WebsitePersistence websitePersistence;
1176 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1177 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1178 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1179 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1180 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1181 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1182 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1183 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1184 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1185 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1186 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1187 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1188 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1189 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1190 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1191 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1192 }