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 BatchSessionUtil.delete(session, workflowInstanceLink);
226 }
227 catch (Exception e) {
228 throw processException(e);
229 }
230 finally {
231 closeSession(session);
232 }
233
234 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
235
236 EntityCacheUtil.removeResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
237 WorkflowInstanceLinkImpl.class, workflowInstanceLink.getPrimaryKey());
238
239 return workflowInstanceLink;
240 }
241
242 public WorkflowInstanceLink updateImpl(
243 com.liferay.portal.model.WorkflowInstanceLink workflowInstanceLink,
244 boolean merge) throws SystemException {
245 workflowInstanceLink = toUnwrappedModel(workflowInstanceLink);
246
247 Session session = null;
248
249 try {
250 session = openSession();
251
252 BatchSessionUtil.update(session, workflowInstanceLink, merge);
253
254 workflowInstanceLink.setNew(false);
255 }
256 catch (Exception e) {
257 throw processException(e);
258 }
259 finally {
260 closeSession(session);
261 }
262
263 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
264
265 EntityCacheUtil.putResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
266 WorkflowInstanceLinkImpl.class,
267 workflowInstanceLink.getPrimaryKey(), workflowInstanceLink);
268
269 return workflowInstanceLink;
270 }
271
272 protected WorkflowInstanceLink toUnwrappedModel(
273 WorkflowInstanceLink workflowInstanceLink) {
274 if (workflowInstanceLink instanceof WorkflowInstanceLinkImpl) {
275 return workflowInstanceLink;
276 }
277
278 WorkflowInstanceLinkImpl workflowInstanceLinkImpl = new WorkflowInstanceLinkImpl();
279
280 workflowInstanceLinkImpl.setNew(workflowInstanceLink.isNew());
281 workflowInstanceLinkImpl.setPrimaryKey(workflowInstanceLink.getPrimaryKey());
282
283 workflowInstanceLinkImpl.setWorkflowInstanceLinkId(workflowInstanceLink.getWorkflowInstanceLinkId());
284 workflowInstanceLinkImpl.setGroupId(workflowInstanceLink.getGroupId());
285 workflowInstanceLinkImpl.setCompanyId(workflowInstanceLink.getCompanyId());
286 workflowInstanceLinkImpl.setUserId(workflowInstanceLink.getUserId());
287 workflowInstanceLinkImpl.setUserName(workflowInstanceLink.getUserName());
288 workflowInstanceLinkImpl.setCreateDate(workflowInstanceLink.getCreateDate());
289 workflowInstanceLinkImpl.setModifiedDate(workflowInstanceLink.getModifiedDate());
290 workflowInstanceLinkImpl.setClassNameId(workflowInstanceLink.getClassNameId());
291 workflowInstanceLinkImpl.setClassPK(workflowInstanceLink.getClassPK());
292 workflowInstanceLinkImpl.setWorkflowInstanceId(workflowInstanceLink.getWorkflowInstanceId());
293
294 return workflowInstanceLinkImpl;
295 }
296
297
305 public WorkflowInstanceLink findByPrimaryKey(Serializable primaryKey)
306 throws NoSuchModelException, SystemException {
307 return findByPrimaryKey(((Long)primaryKey).longValue());
308 }
309
310
318 public WorkflowInstanceLink findByPrimaryKey(long workflowInstanceLinkId)
319 throws NoSuchWorkflowInstanceLinkException, SystemException {
320 WorkflowInstanceLink workflowInstanceLink = fetchByPrimaryKey(workflowInstanceLinkId);
321
322 if (workflowInstanceLink == null) {
323 if (_log.isWarnEnabled()) {
324 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
325 workflowInstanceLinkId);
326 }
327
328 throw new NoSuchWorkflowInstanceLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
329 workflowInstanceLinkId);
330 }
331
332 return workflowInstanceLink;
333 }
334
335
342 public WorkflowInstanceLink fetchByPrimaryKey(Serializable primaryKey)
343 throws SystemException {
344 return fetchByPrimaryKey(((Long)primaryKey).longValue());
345 }
346
347
354 public WorkflowInstanceLink fetchByPrimaryKey(long workflowInstanceLinkId)
355 throws SystemException {
356 WorkflowInstanceLink workflowInstanceLink = (WorkflowInstanceLink)EntityCacheUtil.getResult(WorkflowInstanceLinkModelImpl.ENTITY_CACHE_ENABLED,
357 WorkflowInstanceLinkImpl.class, workflowInstanceLinkId, this);
358
359 if (workflowInstanceLink == null) {
360 Session session = null;
361
362 try {
363 session = openSession();
364
365 workflowInstanceLink = (WorkflowInstanceLink)session.get(WorkflowInstanceLinkImpl.class,
366 new Long(workflowInstanceLinkId));
367 }
368 catch (Exception e) {
369 throw processException(e);
370 }
371 finally {
372 if (workflowInstanceLink != null) {
373 cacheResult(workflowInstanceLink);
374 }
375
376 closeSession(session);
377 }
378 }
379
380 return workflowInstanceLink;
381 }
382
383
393 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
394 long companyId, long classNameId, long classPK)
395 throws SystemException {
396 return findByG_C_C_C(groupId, companyId, classNameId, classPK,
397 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
398 }
399
400
416 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
417 long companyId, long classNameId, long classPK, int start, int end)
418 throws SystemException {
419 return findByG_C_C_C(groupId, companyId, classNameId, classPK, start,
420 end, null);
421 }
422
423
440 public List<WorkflowInstanceLink> findByG_C_C_C(long groupId,
441 long companyId, long classNameId, long classPK, int start, int end,
442 OrderByComparator orderByComparator) throws SystemException {
443 Object[] finderArgs = new Object[] {
444 groupId, companyId, classNameId, classPK,
445
446 String.valueOf(start), String.valueOf(end),
447 String.valueOf(orderByComparator)
448 };
449
450 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_C_C_C,
451 finderArgs, this);
452
453 if (list == null) {
454 StringBundler query = null;
455
456 if (orderByComparator != null) {
457 query = new StringBundler(6 +
458 (orderByComparator.getOrderByFields().length * 3));
459 }
460 else {
461 query = new StringBundler(6);
462 }
463
464 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
465
466 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
467
468 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
469
470 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
471
472 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
473
474 if (orderByComparator != null) {
475 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
476 orderByComparator);
477 }
478
479 else {
480 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
481 }
482
483 String sql = query.toString();
484
485 Session session = null;
486
487 try {
488 session = openSession();
489
490 Query q = session.createQuery(sql);
491
492 QueryPos qPos = QueryPos.getInstance(q);
493
494 qPos.add(groupId);
495
496 qPos.add(companyId);
497
498 qPos.add(classNameId);
499
500 qPos.add(classPK);
501
502 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
503 getDialect(), start, end);
504 }
505 catch (Exception e) {
506 throw processException(e);
507 }
508 finally {
509 if (list == null) {
510 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_C_C_C,
511 finderArgs);
512 }
513 else {
514 cacheResult(list);
515
516 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_C_C_C,
517 finderArgs, list);
518 }
519
520 closeSession(session);
521 }
522 }
523
524 return list;
525 }
526
527
543 public WorkflowInstanceLink findByG_C_C_C_First(long groupId,
544 long companyId, long classNameId, long classPK,
545 OrderByComparator orderByComparator)
546 throws NoSuchWorkflowInstanceLinkException, SystemException {
547 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
548 classNameId, classPK, 0, 1, orderByComparator);
549
550 if (list.isEmpty()) {
551 StringBundler msg = new StringBundler(10);
552
553 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
554
555 msg.append("groupId=");
556 msg.append(groupId);
557
558 msg.append(", companyId=");
559 msg.append(companyId);
560
561 msg.append(", classNameId=");
562 msg.append(classNameId);
563
564 msg.append(", classPK=");
565 msg.append(classPK);
566
567 msg.append(StringPool.CLOSE_CURLY_BRACE);
568
569 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
570 }
571 else {
572 return list.get(0);
573 }
574 }
575
576
592 public WorkflowInstanceLink findByG_C_C_C_Last(long groupId,
593 long companyId, long classNameId, long classPK,
594 OrderByComparator orderByComparator)
595 throws NoSuchWorkflowInstanceLinkException, SystemException {
596 int count = countByG_C_C_C(groupId, companyId, classNameId, classPK);
597
598 List<WorkflowInstanceLink> list = findByG_C_C_C(groupId, companyId,
599 classNameId, classPK, count - 1, count, orderByComparator);
600
601 if (list.isEmpty()) {
602 StringBundler msg = new StringBundler(10);
603
604 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
605
606 msg.append("groupId=");
607 msg.append(groupId);
608
609 msg.append(", companyId=");
610 msg.append(companyId);
611
612 msg.append(", classNameId=");
613 msg.append(classNameId);
614
615 msg.append(", classPK=");
616 msg.append(classPK);
617
618 msg.append(StringPool.CLOSE_CURLY_BRACE);
619
620 throw new NoSuchWorkflowInstanceLinkException(msg.toString());
621 }
622 else {
623 return list.get(0);
624 }
625 }
626
627
644 public WorkflowInstanceLink[] findByG_C_C_C_PrevAndNext(
645 long workflowInstanceLinkId, long groupId, long companyId,
646 long classNameId, long classPK, OrderByComparator orderByComparator)
647 throws NoSuchWorkflowInstanceLinkException, SystemException {
648 WorkflowInstanceLink workflowInstanceLink = findByPrimaryKey(workflowInstanceLinkId);
649
650 Session session = null;
651
652 try {
653 session = openSession();
654
655 WorkflowInstanceLink[] array = new WorkflowInstanceLinkImpl[3];
656
657 array[0] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
658 groupId, companyId, classNameId, classPK,
659 orderByComparator, true);
660
661 array[1] = workflowInstanceLink;
662
663 array[2] = getByG_C_C_C_PrevAndNext(session, workflowInstanceLink,
664 groupId, companyId, classNameId, classPK,
665 orderByComparator, false);
666
667 return array;
668 }
669 catch (Exception e) {
670 throw processException(e);
671 }
672 finally {
673 closeSession(session);
674 }
675 }
676
677 protected WorkflowInstanceLink getByG_C_C_C_PrevAndNext(Session session,
678 WorkflowInstanceLink workflowInstanceLink, long groupId,
679 long companyId, long classNameId, long classPK,
680 OrderByComparator orderByComparator, boolean previous) {
681 StringBundler query = null;
682
683 if (orderByComparator != null) {
684 query = new StringBundler(6 +
685 (orderByComparator.getOrderByFields().length * 6));
686 }
687 else {
688 query = new StringBundler(3);
689 }
690
691 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK_WHERE);
692
693 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
694
695 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
696
697 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
698
699 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
700
701 if (orderByComparator != null) {
702 String[] orderByFields = orderByComparator.getOrderByFields();
703
704 if (orderByFields.length > 0) {
705 query.append(WHERE_AND);
706 }
707
708 for (int i = 0; i < orderByFields.length; i++) {
709 query.append(_ORDER_BY_ENTITY_ALIAS);
710 query.append(orderByFields[i]);
711
712 if ((i + 1) < orderByFields.length) {
713 if (orderByComparator.isAscending() ^ previous) {
714 query.append(WHERE_GREATER_THAN_HAS_NEXT);
715 }
716 else {
717 query.append(WHERE_LESSER_THAN_HAS_NEXT);
718 }
719 }
720 else {
721 if (orderByComparator.isAscending() ^ previous) {
722 query.append(WHERE_GREATER_THAN);
723 }
724 else {
725 query.append(WHERE_LESSER_THAN);
726 }
727 }
728 }
729
730 query.append(ORDER_BY_CLAUSE);
731
732 for (int i = 0; i < orderByFields.length; i++) {
733 query.append(_ORDER_BY_ENTITY_ALIAS);
734 query.append(orderByFields[i]);
735
736 if ((i + 1) < orderByFields.length) {
737 if (orderByComparator.isAscending() ^ previous) {
738 query.append(ORDER_BY_ASC_HAS_NEXT);
739 }
740 else {
741 query.append(ORDER_BY_DESC_HAS_NEXT);
742 }
743 }
744 else {
745 if (orderByComparator.isAscending() ^ previous) {
746 query.append(ORDER_BY_ASC);
747 }
748 else {
749 query.append(ORDER_BY_DESC);
750 }
751 }
752 }
753 }
754
755 else {
756 query.append(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
757 }
758
759 String sql = query.toString();
760
761 Query q = session.createQuery(sql);
762
763 q.setFirstResult(0);
764 q.setMaxResults(2);
765
766 QueryPos qPos = QueryPos.getInstance(q);
767
768 qPos.add(groupId);
769
770 qPos.add(companyId);
771
772 qPos.add(classNameId);
773
774 qPos.add(classPK);
775
776 if (orderByComparator != null) {
777 Object[] values = orderByComparator.getOrderByValues(workflowInstanceLink);
778
779 for (Object value : values) {
780 qPos.add(value);
781 }
782 }
783
784 List<WorkflowInstanceLink> list = q.list();
785
786 if (list.size() == 2) {
787 return list.get(1);
788 }
789 else {
790 return null;
791 }
792 }
793
794
800 public List<WorkflowInstanceLink> findAll() throws SystemException {
801 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
802 }
803
804
816 public List<WorkflowInstanceLink> findAll(int start, int end)
817 throws SystemException {
818 return findAll(start, end, null);
819 }
820
821
834 public List<WorkflowInstanceLink> findAll(int start, int end,
835 OrderByComparator orderByComparator) throws SystemException {
836 Object[] finderArgs = new Object[] {
837 String.valueOf(start), String.valueOf(end),
838 String.valueOf(orderByComparator)
839 };
840
841 List<WorkflowInstanceLink> list = (List<WorkflowInstanceLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
842 finderArgs, this);
843
844 if (list == null) {
845 StringBundler query = null;
846 String sql = null;
847
848 if (orderByComparator != null) {
849 query = new StringBundler(2 +
850 (orderByComparator.getOrderByFields().length * 3));
851
852 query.append(_SQL_SELECT_WORKFLOWINSTANCELINK);
853
854 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
855 orderByComparator);
856
857 sql = query.toString();
858 }
859 else {
860 sql = _SQL_SELECT_WORKFLOWINSTANCELINK.concat(WorkflowInstanceLinkModelImpl.ORDER_BY_JPQL);
861 }
862
863 Session session = null;
864
865 try {
866 session = openSession();
867
868 Query q = session.createQuery(sql);
869
870 if (orderByComparator == null) {
871 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
872 getDialect(), start, end, false);
873
874 Collections.sort(list);
875 }
876 else {
877 list = (List<WorkflowInstanceLink>)QueryUtil.list(q,
878 getDialect(), start, end);
879 }
880 }
881 catch (Exception e) {
882 throw processException(e);
883 }
884 finally {
885 if (list == null) {
886 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
887 finderArgs);
888 }
889 else {
890 cacheResult(list);
891
892 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
893 list);
894 }
895
896 closeSession(session);
897 }
898 }
899
900 return list;
901 }
902
903
912 public void removeByG_C_C_C(long groupId, long companyId, long classNameId,
913 long classPK) throws SystemException {
914 for (WorkflowInstanceLink workflowInstanceLink : findByG_C_C_C(
915 groupId, companyId, classNameId, classPK)) {
916 remove(workflowInstanceLink);
917 }
918 }
919
920
925 public void removeAll() throws SystemException {
926 for (WorkflowInstanceLink workflowInstanceLink : findAll()) {
927 remove(workflowInstanceLink);
928 }
929 }
930
931
941 public int countByG_C_C_C(long groupId, long companyId, long classNameId,
942 long classPK) throws SystemException {
943 Object[] finderArgs = new Object[] {
944 groupId, companyId, classNameId, classPK
945 };
946
947 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C,
948 finderArgs, this);
949
950 if (count == null) {
951 StringBundler query = new StringBundler(5);
952
953 query.append(_SQL_COUNT_WORKFLOWINSTANCELINK_WHERE);
954
955 query.append(_FINDER_COLUMN_G_C_C_C_GROUPID_2);
956
957 query.append(_FINDER_COLUMN_G_C_C_C_COMPANYID_2);
958
959 query.append(_FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2);
960
961 query.append(_FINDER_COLUMN_G_C_C_C_CLASSPK_2);
962
963 String sql = query.toString();
964
965 Session session = null;
966
967 try {
968 session = openSession();
969
970 Query q = session.createQuery(sql);
971
972 QueryPos qPos = QueryPos.getInstance(q);
973
974 qPos.add(groupId);
975
976 qPos.add(companyId);
977
978 qPos.add(classNameId);
979
980 qPos.add(classPK);
981
982 count = (Long)q.uniqueResult();
983 }
984 catch (Exception e) {
985 throw processException(e);
986 }
987 finally {
988 if (count == null) {
989 count = Long.valueOf(0);
990 }
991
992 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C,
993 finderArgs, count);
994
995 closeSession(session);
996 }
997 }
998
999 return count.intValue();
1000 }
1001
1002
1008 public int countAll() throws SystemException {
1009 Object[] finderArgs = new Object[0];
1010
1011 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1012 finderArgs, this);
1013
1014 if (count == null) {
1015 Session session = null;
1016
1017 try {
1018 session = openSession();
1019
1020 Query q = session.createQuery(_SQL_COUNT_WORKFLOWINSTANCELINK);
1021
1022 count = (Long)q.uniqueResult();
1023 }
1024 catch (Exception e) {
1025 throw processException(e);
1026 }
1027 finally {
1028 if (count == null) {
1029 count = Long.valueOf(0);
1030 }
1031
1032 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1033 count);
1034
1035 closeSession(session);
1036 }
1037 }
1038
1039 return count.intValue();
1040 }
1041
1042
1045 public void afterPropertiesSet() {
1046 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1047 com.liferay.portal.util.PropsUtil.get(
1048 "value.object.listener.com.liferay.portal.model.WorkflowInstanceLink")));
1049
1050 if (listenerClassNames.length > 0) {
1051 try {
1052 List<ModelListener<WorkflowInstanceLink>> listenersList = new ArrayList<ModelListener<WorkflowInstanceLink>>();
1053
1054 for (String listenerClassName : listenerClassNames) {
1055 listenersList.add((ModelListener<WorkflowInstanceLink>)InstanceFactory.newInstance(
1056 listenerClassName));
1057 }
1058
1059 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1060 }
1061 catch (Exception e) {
1062 _log.error(e);
1063 }
1064 }
1065 }
1066
1067 public void destroy() {
1068 EntityCacheUtil.removeCache(WorkflowInstanceLinkImpl.class.getName());
1069 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1070 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1071 }
1072
1073 @BeanReference(type = AccountPersistence.class)
1074 protected AccountPersistence accountPersistence;
1075 @BeanReference(type = AddressPersistence.class)
1076 protected AddressPersistence addressPersistence;
1077 @BeanReference(type = BrowserTrackerPersistence.class)
1078 protected BrowserTrackerPersistence browserTrackerPersistence;
1079 @BeanReference(type = ClassNamePersistence.class)
1080 protected ClassNamePersistence classNamePersistence;
1081 @BeanReference(type = ClusterGroupPersistence.class)
1082 protected ClusterGroupPersistence clusterGroupPersistence;
1083 @BeanReference(type = CompanyPersistence.class)
1084 protected CompanyPersistence companyPersistence;
1085 @BeanReference(type = ContactPersistence.class)
1086 protected ContactPersistence contactPersistence;
1087 @BeanReference(type = CountryPersistence.class)
1088 protected CountryPersistence countryPersistence;
1089 @BeanReference(type = EmailAddressPersistence.class)
1090 protected EmailAddressPersistence emailAddressPersistence;
1091 @BeanReference(type = GroupPersistence.class)
1092 protected GroupPersistence groupPersistence;
1093 @BeanReference(type = ImagePersistence.class)
1094 protected ImagePersistence imagePersistence;
1095 @BeanReference(type = LayoutPersistence.class)
1096 protected LayoutPersistence layoutPersistence;
1097 @BeanReference(type = LayoutPrototypePersistence.class)
1098 protected LayoutPrototypePersistence layoutPrototypePersistence;
1099 @BeanReference(type = LayoutSetPersistence.class)
1100 protected LayoutSetPersistence layoutSetPersistence;
1101 @BeanReference(type = LayoutSetPrototypePersistence.class)
1102 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1103 @BeanReference(type = ListTypePersistence.class)
1104 protected ListTypePersistence listTypePersistence;
1105 @BeanReference(type = LockPersistence.class)
1106 protected LockPersistence lockPersistence;
1107 @BeanReference(type = MembershipRequestPersistence.class)
1108 protected MembershipRequestPersistence membershipRequestPersistence;
1109 @BeanReference(type = OrganizationPersistence.class)
1110 protected OrganizationPersistence organizationPersistence;
1111 @BeanReference(type = OrgGroupPermissionPersistence.class)
1112 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1113 @BeanReference(type = OrgGroupRolePersistence.class)
1114 protected OrgGroupRolePersistence orgGroupRolePersistence;
1115 @BeanReference(type = OrgLaborPersistence.class)
1116 protected OrgLaborPersistence orgLaborPersistence;
1117 @BeanReference(type = PasswordPolicyPersistence.class)
1118 protected PasswordPolicyPersistence passwordPolicyPersistence;
1119 @BeanReference(type = PasswordPolicyRelPersistence.class)
1120 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1121 @BeanReference(type = PasswordTrackerPersistence.class)
1122 protected PasswordTrackerPersistence passwordTrackerPersistence;
1123 @BeanReference(type = PermissionPersistence.class)
1124 protected PermissionPersistence permissionPersistence;
1125 @BeanReference(type = PhonePersistence.class)
1126 protected PhonePersistence phonePersistence;
1127 @BeanReference(type = PluginSettingPersistence.class)
1128 protected PluginSettingPersistence pluginSettingPersistence;
1129 @BeanReference(type = PortletPersistence.class)
1130 protected PortletPersistence portletPersistence;
1131 @BeanReference(type = PortletItemPersistence.class)
1132 protected PortletItemPersistence portletItemPersistence;
1133 @BeanReference(type = PortletPreferencesPersistence.class)
1134 protected PortletPreferencesPersistence portletPreferencesPersistence;
1135 @BeanReference(type = RegionPersistence.class)
1136 protected RegionPersistence regionPersistence;
1137 @BeanReference(type = ReleasePersistence.class)
1138 protected ReleasePersistence releasePersistence;
1139 @BeanReference(type = ResourcePersistence.class)
1140 protected ResourcePersistence resourcePersistence;
1141 @BeanReference(type = ResourceActionPersistence.class)
1142 protected ResourceActionPersistence resourceActionPersistence;
1143 @BeanReference(type = ResourceCodePersistence.class)
1144 protected ResourceCodePersistence resourceCodePersistence;
1145 @BeanReference(type = ResourcePermissionPersistence.class)
1146 protected ResourcePermissionPersistence resourcePermissionPersistence;
1147 @BeanReference(type = RolePersistence.class)
1148 protected RolePersistence rolePersistence;
1149 @BeanReference(type = ServiceComponentPersistence.class)
1150 protected ServiceComponentPersistence serviceComponentPersistence;
1151 @BeanReference(type = ShardPersistence.class)
1152 protected ShardPersistence shardPersistence;
1153 @BeanReference(type = SubscriptionPersistence.class)
1154 protected SubscriptionPersistence subscriptionPersistence;
1155 @BeanReference(type = TicketPersistence.class)
1156 protected TicketPersistence ticketPersistence;
1157 @BeanReference(type = TeamPersistence.class)
1158 protected TeamPersistence teamPersistence;
1159 @BeanReference(type = UserPersistence.class)
1160 protected UserPersistence userPersistence;
1161 @BeanReference(type = UserGroupPersistence.class)
1162 protected UserGroupPersistence userGroupPersistence;
1163 @BeanReference(type = UserGroupGroupRolePersistence.class)
1164 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1165 @BeanReference(type = UserGroupRolePersistence.class)
1166 protected UserGroupRolePersistence userGroupRolePersistence;
1167 @BeanReference(type = UserIdMapperPersistence.class)
1168 protected UserIdMapperPersistence userIdMapperPersistence;
1169 @BeanReference(type = UserTrackerPersistence.class)
1170 protected UserTrackerPersistence userTrackerPersistence;
1171 @BeanReference(type = UserTrackerPathPersistence.class)
1172 protected UserTrackerPathPersistence userTrackerPathPersistence;
1173 @BeanReference(type = WebDAVPropsPersistence.class)
1174 protected WebDAVPropsPersistence webDAVPropsPersistence;
1175 @BeanReference(type = WebsitePersistence.class)
1176 protected WebsitePersistence websitePersistence;
1177 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
1178 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
1179 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
1180 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
1181 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink";
1182 private static final String _SQL_SELECT_WORKFLOWINSTANCELINK_WHERE = "SELECT workflowInstanceLink FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1183 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink";
1184 private static final String _SQL_COUNT_WORKFLOWINSTANCELINK_WHERE = "SELECT COUNT(workflowInstanceLink) FROM WorkflowInstanceLink workflowInstanceLink WHERE ";
1185 private static final String _FINDER_COLUMN_G_C_C_C_GROUPID_2 = "workflowInstanceLink.groupId = ? AND ";
1186 private static final String _FINDER_COLUMN_G_C_C_C_COMPANYID_2 = "workflowInstanceLink.companyId = ? AND ";
1187 private static final String _FINDER_COLUMN_G_C_C_C_CLASSNAMEID_2 = "workflowInstanceLink.classNameId = ? AND ";
1188 private static final String _FINDER_COLUMN_G_C_C_C_CLASSPK_2 = "workflowInstanceLink.classPK = ?";
1189 private static final String _ORDER_BY_ENTITY_ALIAS = "workflowInstanceLink.";
1190 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowInstanceLink exists with the primary key ";
1191 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowInstanceLink exists with the key {";
1192 private static Log _log = LogFactoryUtil.getLog(WorkflowInstanceLinkPersistenceImpl.class);
1193 }